Guest User

Untitled

a guest
Jun 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Here we are going to use arrays
  2. // Iteration will be for loop
  3. // Author : Clement Mahlangu
  4. var itemWeight = [12.3,15.6,20.9,33.33,51.2];
  5. var totalMass = 0;
  6.  
  7. //Now lets just check out the total
  8. for (i=0; i < itemWeight.length; i++) {
  9.     totalMass = totalMass + itemWeight[i];
  10. }
  11.  
  12. //Display the total mass of all your items
  13. console.log("The total mass is " + totalMass);
Add Comment
Please, Sign In to add comment