Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function buildWall(arr) {
- arr = arr.map(Number);
- let wallSections = arr.length;
- let workingDays = 30 - Math.min(...arr);
- let concrete = [];
- for(let i = 0; i < workingDays; i++) {
- if(arr.includes(30)) {
- arr.splice(arr.indexOf(30), 1);
- wallSections = arr.length;
- }
- concrete.push(wallSections * 195);
- arr = arr.map(x => x + 1);
- }
- let totalConcrete = 0;
- for(let el of concrete) {
- totalConcrete += el;
- }
- console.log(concrete.join(', '));
- console.log(`${totalConcrete * 1900} pesos`);
- }
- buildWall([17, 22, 17, 19, 17]);
Advertisement
Add Comment
Please, Sign In to add comment