scrimba
Note at 0:51
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:51
AboutCommentsNotes
Note at 0:51
Expand for more info
index.js
run
preview
console
const xmasGifts = ['guitar 🎸', 'skates ⛸️', 'bear 🧸', 'magnet 🧲', 'laptop 💻', 'games console 🎮 ', 'jewellery 💍', 'kite 🪁']

/**
* Challenge:
* 1. Sort the array twice. Alphabetically and reverse alphabetically.
**/

const sortedAZ = xmasGifts.toSorted() /* write code here */
// toSorted() returns a new array with the elements sorted in ascending order

console.log('A-Z: ', sortedAZ)
//["bear 🧸", "games console 🎮 ", "guitar 🎸", "jewellery 💍", "kite 🪁", "laptop 💻", "scarf 🧣", "skates ⛸️"]

const sortedZA = sortedAZ.reverse()/* write code here */
console.log('Z-A: ', sortedZA)
//["skates ⛸️", "scarf 🧣", "laptop 💻", "kite 🪁", "jewellery 💍", "guitar 🎸", "games console 🎮 ", "bear 🧸"]
Console
"A-Z: "
,
[
"bear 🧸"
,
"games console 🎮 "
,
"guitar 🎸"
,
"jewellery 💍"
,
"kite 🪁"
,
"laptop 💻"
,
"magnet 🧲"
,
"skates ⛸️"
]
,
"Z-A: "
,
[
"skates ⛸️"
,
"magnet 🧲"
,
"laptop 💻"
,
"kite 🪁"
,
"jewellery 💍"
,
"guitar 🎸"
,
"games console 🎮 "
,
"bear 🧸"
]
,
/index.html
LIVE