
TL DR: Whatever is inside the for loop, run it 20 times beginning from 0 (starting value of i) to 19 (ending value of i) and increment i by 1. Point 3: Since you want to check for every element in the array, you increment i by 1. The length of the array is 20! Therefore, with this stop condition we make sure that i will never be greater than 19, which is the index of the last Object in the array. Therefore, you would always want i to be less than or equal to the last position of the array.
Point 2: You want to run the loop for all the individuals in the array. To do that, you initialize a new variable i with the value 0. We need to run the if code block for every element in the array from index 0 to index 19 (length is 20).
Length of the array can be accessed by array.length. You index an element with square brackets, for example: individuals will return the details for Aaron. The position of the first element is denoted by 0. Let is also used to declare variables(new way)Ĭonst is used to declare const values. Var is used to declare variables(old way of declaring variables) Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc. Embedded along with HTML and makes web pages alive. Javascript is required to design the behaviour of the web pages. Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. The editor shows sample boilerplate code when you choose language as Javascript and start coding. Getting started with the OneCompiler's Javascript editor is easy and fast. It's one of the robust, feature-rich online compilers for Javascript language.
Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free.