Q:

Write a JavaScript program to test whether an array of integers of length 2 contains 1 or a 3

0

Write a JavaScript program to test whether an array of integers of length 2 contains 1 or a 3.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function contains13(nums) {

    if (nums.indexOf(1) != -1 || nums.indexOf(3) != -1){
       return true
    } 
    else
    {
       return false
    }
}
console.log(contains13([1, 5]));  
console.log(contains13([2, 3]));  
console.log(contains13([7, 5])); 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now