+ 2
Condition, term etc.
Colleagues, this is simple question for masters, but I’m not the one of them. I’ve got stuck in it. The task includes condition: if x=5, then “x” must to be changed into “0”. var x = (5 - (x % 5)); if (x === 5) ( '0' ); console.log (x); How should I write this code properly and not to broke the first line? Please help!
7 ответов
+ 6
if (x == 5) x = 0
?
+ 2
try this
if (x === 5){
x = 0;
}
console.log(x);
+ 1
Where do you get this expression
x = 5-(x%5) => 5-x = x%5
Which will not satisfied by any value of 0<= x<= infinite
What does it mean..
+ 1
It’s the task in JS learning. We have some groups of people wich consist of different number (0, 14, 3 20 and so long). Each number has to be divided in minor groups (everyone of 5 men).
The code must to test every number and show hom many people we need to add for this number could be divided by 5. If the answer is “0”, the code must show “0”.
+ 1
If you mean that you have remake the given uneven groups into groups of five member in each, you can add all the numbers and modulo with five it will give how much people left.
+ 1
Thank you all for help!
It’s working!
0
myjj7nrbqsSFgXR