Posts

[Javascript Tutorial 4/4] For loop

1. Record Collection You are given an object literal representing a part of your musical album collection. Each album has a unique id number as its key and several other properties. Not all albums have complete information. You start with an updateRecords function that takes an object literal, records, containing the musical album collection, an id, a prop (like artist or tracks), and a value. Complete the function using the rules below to modify the object passed to the function.. 2. Iterate with JavaScript While Loops You can run the same code multiple times by using a loop. The first type of loop we will learn is called a while loop because it runs while a specified condition is true and stops once that condition is no longer true. const ourArray = [ ] ; let i = 0 ; while ( i < 5 ) { ourArray . push ( i ) ; i ++ ; } In the code example above, the while loop will execute 5 times and append the numbers 0 through 4 to ourArray. Let me add the numbers 5 through 0 (in...