What is wrong here


#1

function checkModule(){

for (var num = 1; num < 55; num++){
if (num %3 === 0){
console.log("Divided by 3");
} else if (num %5 === 0){
console.log("Divided by 5");
} else if (num %3 === 0 && num %5 === 0){
console.log("Divided by both 5 and 3");
} else {
console.log(num);
}
}
}
checkModule();

do you have any idea why this wont return "Divided by both 5 and 3". if divisible by 3, it returns "Divided by 3", if by 5, it returns "Divided by 5" but by both 3 and 5, i cant tell why it wont return "Divided by both 5 and 3"


#2

HI read this post it explain why this doesn't work


#3

i did few debugging using notepad++, my code ran the expected output but on the console .it keeps giving script error


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.