Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Bracket Notation Example

let cargoHold = ['oxygen tanks', 'space suits', 'parrot', 
                 'instruction manual', 'meal packs', 'slinky', 
                 'security blanket'];

/*a) Use bracket notation to replace ‘slinky’ with ‘space tether’. 
Print the array to confirm the change.*/

cargoHold[5] = "space tether"; 
console.log(cargoHold); 

//OR// cargoHold.splice(5,1, 'space tether');
// console.log(cargoHold); 
Source by education.launchcode.org #
 
PREVIOUS NEXT
Tagged: #Bracket #Notation #Example
ADD COMMENT
Topic
Name
7+3 =