Advertisement
vladovip

BuildAWall-JS Fund_Arr Advance Ex

Feb 17th, 2022
720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function buildWall(arrayOfStrings) {
  2.   let numArrHeightSections = arrayOfStrings.map(Number);
  3.  
  4.   let totalCubicYardsOfConcrete = 0;
  5.   let tempArr = [];
  6.   let sumofSectionHeight = 0;
  7.  
  8.   for (let index = 0; index < numArrHeightSections.length; index++) {
  9.     sumofSectionHeight += numArrHeightSections[index];
  10.   }
  11.  
  12.   while (sumofSectionHeight < numArrHeightSections.length * 30) {
  13.     let concreteUsedForDay = 0;
  14.     for (let index = 0; index < numArrHeightSections.length; index++) {
  15.       if (numArrHeightSections[index] == 30) {
  16.         continue;
  17.       } else {
  18.         numArrHeightSections[index]++;
  19.         totalCubicYardsOfConcrete += 195;
  20.         concreteUsedForDay += 195;
  21.       }
  22.     }
  23.     tempArr.push(concreteUsedForDay);
  24.    
  25.      sumofSectionHeight=0;
  26.      for (let sectionHeight of numArrHeightSections) {
  27.         sumofSectionHeight += sectionHeight;
  28.      }
  29.   }
  30.     console.log(tempArr.join(', '));
  31.     console.log(`${totalCubicYardsOfConcrete * 1900} pesos`);
  32. }
  33.  
  34. buildWall([21, 25, 28]);
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement