You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Chris 5ff30bcf33 discovery-piscine: add subjects and tests 4 years ago
..
README.md discovery-piscine: add subjects and tests 4 years ago

README.md

Swapy

Like we did with Objects, we can modify our arrays.

replacing an Array value

Let's look at an example of code:

let weekDays = [
  'Monday',
  'Tuesday',
  'Wednesday',
  'Thursday',
  'Friday',
  'Saturday',
  'Sunday',
]

// Let's say I don't want Monday but a Second Sunday
weekDays[0] = 'Second Sunday'

In this example, we select the element at index 0 (with weekDays[0]) and then assign it using the = (assign operator) the value 'Second Sunday'

Now my array look like this:

;[
  'Second Sunday',
  'Tuesday',
  'Wednesday',
  'Thursday',
  'Friday',
  'Saturday',
  'Sunday',
]

Instructions

  • You must replace the third element of the provided replaceMe array by the string 'great'
  • You must swap the first and second element of the provided swapMe array.

Example:

['pif','paf','pom'] -> ['paf','pif','pom'] // last element is untouched

You must modify the swapMe array, not create a new one !