Answers for "undefined value check in javascript"

20

javascript check for undefined

if (typeof myVariable === 'undefined'){
    //myVariable is undefined
}
Posted by: Guest on July-22-2019
0

undefined value check in javascript

function divisors(integer) {
    let  i, flag = true; 
       let arr=[];       
           
            
            for(i = 2; i <= integer - 1; i++) {
                if (integer % i == 0) { 
                    flag = false; 
                     arr.push(i)
                } 
            }
            if (flag == true) 
              console.log(integer + " is prime"); 
            else
                console.log(arr)
}
console.log(divisors(15))
Posted by: Guest on October-11-2020

Code answers related to "undefined value check in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language