+ 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 Answers
+ 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