JSFiddle - React, Tailwind, and code Playground

by Lucille Kenney

JavaScript

console.clear();

/*
 * This function checks to see if the parameter is a string.
 *
 * @param element - the element in the array to check
 * @return boolean - true is the param is a string
 */
var checkForString = function(element) {
    var isString = true;    
    
    if (typeof element == "string") {
        console.log(element + " is a string.");
    } else {
        console.log(element + " is NOT string, it is a " + typeof element + ".");
        isString = false;
    }

    return isString;
}

// init an array
var myArray = ["one", "two", "three", 4, "five", "six"];

// Call Array.every() for element in the array
console.log(myArray.every(checkForString));