my mission is : write numbers 1-100. if the number can divide with 3 then write it into the console next to the number " it can be divided with 3 ". if the number is 5 also write it into the console next to the number " it can be divided with 5 " and if it cant be divided with 3 also with 5 just leave it and write nothing
for (var listing=1;listing<=30;listing++){
if (listing % 3 != 0) {
console.log(" A(z) " + listing + " ");
} else if (listing % 5 == 0) {
console.log(" A(z) " + listing + " it can be divided with 3 and 5 ");
} else if (listing % 3 == 0){
console.log(" A(z) " + listing + " it can be divided with 3 ");
}
}
if the number can divided by both of them its okay. but i dont know the command for write it " it can be divided by 5 " if the number can be divided by five. because this is the last thing what cant be showed please help
I'm not entirely sure what you want. Does this help you?
for (var listing = 1; listing <= 100; listing++) {
if (listing % 3 != 0 && listing % 5 != 0) {
console.log(" A(z) " + listing + " ");
} else if (listing % 3 == 0 && listing % 5 == 0) {
console.log(" A(z) " + listing + " it can be divided with 3 and 5 ");
} else if (listing % 3 == 0) {
console.log(" A(z) " + listing + " it can be divided with 3 ");
} else if (listing % 5 == 0) {
console.log(" A(z) " + listing + " it can be divided with 5 ");
}
}