Advertisement
Spocoman

10. Build a Wall

Feb 10th, 2022
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function buildAWall(wall) {
  2.     wall = wall.filter(x => x !== 30);
  3.     let cubicPerDay = [];
  4.     let wallPrice = 0;
  5.  
  6.     while (wall.length !== 0) {
  7.        cubicPerDay.push(wall.length * 195);
  8.        wallPrice += cubicPerDay[cubicPerDay.length - 1] * 1900;
  9.        for (let i = 0; i < wall.length; i++){
  10.             wall[i]++;
  11.         }
  12.         wall = wall.filter(x => x !== 30);
  13.     }
  14.     console.log(cubicPerDay.join(', '));
  15.     console.log(`${wallPrice} pesos`);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement