HELP Modify Array Data With Indexes

HELP Modify Array Data With Indexes
0

#1

Tell us what’s happening:
hello!!!
could someone please help me understand what I am doing wrong and how to fix my problem with the
correct index

Your code so far


// Example
var ourArray = [18,64,99];
ourArray[1] = 45; // ourArray now equals [18,45,99].

// Setup
var myArray = [18,64,99];

// Only change code below this line.
correct index in myArray = [45,64,99];

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/modify-array-data-with-indexes


#2

Take a look at the example code, this is the syntax used to modify an element in a given index. In this case it’s index 1.

You will be doing the same thing. You are changing a value at a index 0 to 45.


#3

I am still totally stuck


#4

Did you make any changes to your original code? If so, post the new code in a reply to this existing thread.


#5
// Example
var ourArray = [18,64,99];
ourArray[1] = 45; // ourArray now equals [18,45,99].

// Setup
var myArray = [18,64,99];

// Only change code below this line.

var ourArray = [18,64,99];
ourArray[0] = 45;

#6

You need to modify myArray variable in the setup, instead modifying ourArray in the example.


#7

yay that worked