News from the Field
A channel with tips on modern AI development. Join!
⊗jsPmArMst 79 of 504 menu
◀ ▶

Finding mistakes in code with arrays in JavaScript

In the following tasks, some programmer has written code and may have made mistakes in it. You should check if the code performs what is described. If the code doesn't work correctly, you have to correct the errors.

The code should output the last element of the array:

let arr = [1, 2, 3, 4, 5]; console.log(arr[arr.length]);

The code should find the sum of the array elements:

let arr = [1, 2, 3, 4, 5]; console.log(arr[1] + arr[2] + arr[3] + arr[4] + arr[5]);

The code should output the length of the array:

let arr = {1, 2, 3, 4, 5}; console.log(arr.length]);

The code should output the length of the array:

let arr = [1, 2, 3, 4, 5]; console.log(arr.lenght);
← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline