Open console to see the results (Press Command + Option + J (Mac) or Control + Shift + J (Windows, Linux, Chrome OS))
// Hello user
function greeting(name) {
return "Welcome " + name;
}
console.log(greeting("Annie"));
// What type?
function checkType(arg) {
return typeof(arg);
}
console.log(checkType(12));
let typeOf = "this is a string";
console.log(checkType(typeOf));
// Bonus: Examine the output we get when we check the type of an array. Why does this happen?
//Because arrays are not primitive data types
// Check length
function stringLength(str) {
return str.length;
}
const theLength = stringLength("Around the World");
console.log(theLength);
console.log(stringLength("One More Time"));
//Bonus: Can we use the length property on other types of variable? What else might this be useful for?
//We can also use it on arrays