Thursday, 25 May 2017

Write a javascript function that checks whether an element is in an array

When i run this function I get a syntax error unexpected number

    var numberList = [1, 5, 2, 20, 7, 90, 3];
    function inArray( numberList, 90 ) {
        for (var i = 0; i < numberList.length; i++) {
            if(numberlist[i] === 90){
                return true;
            } else {
                return false;
        }
        }
    }
    inArray();



via Jerry Hoglen

No comments:

Post a Comment