Refer to the code snippet below:

Refer to the code snippet below:
Let array = [1, 2, 3, 4, 4, 5, 4, 4];
For (let i =0; i < array.length; i++) if (array[i] === 4) { array.splice(i, 1);
}} What is the value of array after the code executes?
A. [1, 2, 3, 4, 5, 4, 4]
B. [1, 2, 3, 4, 4, 5, 4]
C. [1, 2, 3, 5]
D. [1, 2, 3, 4, 5, 4]

Download Printable PDF. VALID exam to help you PASS.

One thought on “Refer to the code snippet below:

  1. Correct option is D

    try next code
    let array = [1, 2, 3, 4, 4, 5, 4, 4];

    for (let i =0; i < array.length; i++){
    console.log('array[i]: '+array[i]);
    if (array[i] === 4) {
    array.splice(i, 1);
    console.log(array);
    } }
    console.log('array: ' + array);

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.