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.
 
 
 
 
 
 
Clement Denis d3a8b56646 discovery-js: add more exercises 4 years ago
..
README.md discovery-js: add more exercises 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'

Example:

let replaceMe = ['pif', 'paf', 'pom']
//    expect -> ['pif','paf','great']
  • You must swap the first and second element of the provided swapMe array.

Example:

let swapMe = ['pif', 'paf', 'pom']
// expect -> ['paf','pif','pom'] (last element is untouched)

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