Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Here we are going to use arrays
- // Iteration will be for loop
- // Author : Clement Mahlangu
- var itemWeight = [12.3,15.6,20.9,33.33,51.2];
- var totalMass = 0;
- //Now lets just check out the total
- for (i=0; i < itemWeight.length; i++) {
- totalMass = totalMass + itemWeight[i];
- }
- //Display the total mass of all your items
- console.log("The total mass is " + totalMass);
Add Comment
Please, Sign In to add comment