I'm starting to learn javascript for front-end programming, being python my first language to learn completely.
So I'm trying to solve a while loop excersise that console-logs every number from 50-300 that is divisble by 5 and 3.
So in python i would do this:
i = 50
while i < 301:
if i % 5 == i % 3 == 0:
print(i)
i += 1
And works flawlessly. I know you could use and and
operator but the whole point of this question is to avoid using it.
So I try the same thing in javascript
var i = 50;
while (i < 301){
if (i % 5 === i % 3 === 0){
console.log(i);
}
i ++;
}
And somehow that wont work. However, with an &&
operator it does. Are double equalities in javascript not allowed? If they are, what am I missing?
Aucun commentaire:
Enregistrer un commentaire