Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function whileDemo(input) {
- let w = Number(input[0]);
- let l = Number(input[1]);
- let h = Number(input[2]);
- let freeSpace = w * l * h;
- let index = 3;
- let command = input[index];
- while (command !== 'Done') {
- let numberOfBoxes = Number(command);
- freeSpace -= numberOfBoxes;
- if (freeSpace < 0) {
- console.log(`No more free space! You need ${Math.abs(freeSpace)} Cubic meters more.`);
- break;
- }
- index++;
- command = input[index];
- }
- if (freeSpace >= 0) {
- console.log(`${freeSpace} Cubic meters left.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement