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))
Also in JavaScript:
- basic javascript
- jquery test div exists
- how to create a package.json file in npm
- javascript merge two array with spread operator
- js conditional key
- orderbychild firebase react
- package json add git repo
- jquery alert
- js array map
- urlencode jquery
- date compare in js
- react web worker
- set multiple attributes javascript
- angularjs filter array of objects based on name prop
- how to use if else inside jsx in react
- ran ctrl c and npm server is still running
- electronjs ipc doesn't work
- Javascript string compression
- multiple event with javascript
- how to change a variables value in javascript
- how to make a show password button
- asynchronous javascript
- stripe subscription node js
- generate random password