-2

Task Instructions Your task in this activity is to create a function called isString that takes three arguments (a, b, c). This function does the following: It uses the typeof operator and strict equality comparison to check if the type of all three parameters a, b and c is string. If each argument is a string it returns the message strings. If any of the three parameters is not a string, then it returns the message not strings

I'm unsure how to create the function called isString and then put three arguments under it. I am also unsure how to use typeof operator to complete the comparison. Need more details.

/*
Follow the instructions - Create a function called "isString" that takes 3 arguments (x1, x2, x3)
- check if each argument is a string using typeof.
- If each argument is a string, return "strings"
- If each argument is NOT a string, return "not strings"

*/


//Write your code here
////////////////////////////////////////

////////////////////////////////////////

//open the browser console to check results
console.log('results: ', isString('a', 'b', 'c'));

//don't change this line
if (typeof module !== 'undefined') {
  module.exports = isString;
}
HackAttack101
  • 35
  • 2
  • 7
  • You should first make sure your asking a right question. You could ask something like : How to use typeof operator to check if argument is a string ? – Aggestor Jul 19 '21 at 18:56
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof – epascarello Jul 19 '21 at 18:59

1 Answers1

0

You can get the typeof of a variable and compare if it is "string". Check this example to see how it is:

const isString=(a,b,c)=>{
if( ((typeof a)=="string") && ((typeof b)=="string") && ((typeof c)=="string")){
   return "strings";
}
   return "not strings";
}
Skatox
  • 4,237
  • 12
  • 42
  • 47
Zein
  • 571
  • 4
  • 24