js variable with numbers code example
Example 1: var javascript
var is a keyword to define the varible in js but as of es-6 we, use let and const keywords for the same
Example 2: primitive numbers javascript coding sample increas by 1
function test_prime(n){
if (n===1) {
return false;
}else if(n === 2){
return true;
}else{
for(var x = 2; x < n; x++){
if(n % x === 0){
return false;
}
}
return true;
}
}
console.log(test_prime(37));