Ho Ho Ho! Welcome to Day 1 of our special 3-day Christmas Coding Challenge! Each day holds a festive coding challenge AND a secret message piece. Collect all pieces to unlock a special Christmas surprise on Day 3! 🎅
1. Take an array of arrays, where each inner array contains:
- A child's name (string)
- Their good deed score (number from 1-10)
2. Sort the children by their scores from highest to lowest
3. When children have the same score, sort them alphabetically by name
4. Return an array containing just the names of the top 5 children
Examples
To find it:
1. First, solve the sorting challenge correctly
2. Look at your sorted output for Test Case 3
3. Some names are special - their first letters spell out today's message piece
4. Look for a 5-letter word that feels festive!
5. Write this word down - you'll need it for Day 5!
Remember: This is just Part 1 of 3 of our Christmas message. Keep solving each day's challenge to collect all the pieces!
Good luck, and may your code be merry and bright! 🎄✨
---
The true spirit of Christmas is in the joy of coding! Even if your solution isn't perfect, what matters is the fun you have along the way!* 🎅
The Story
Santa's workshop is in chaos! His magical list of children and their good deed scores got shuffled when an excited elf accidentally spilled hot cocoa all over Santa's sorting machine. Now Santa needs YOUR help to reorganize everything before Christmas Eve!The Challenge
Write a function calledsortSantasList that helps Santa organize his special list. The function should:1. Take an array of arrays, where each inner array contains:
- A child's name (string)
- Their good deed score (number from 1-10)
2. Sort the children by their scores from highest to lowest
3. When children have the same score, sort them alphabetically by name
4. Return an array containing just the names of the top 5 children
Examples
Code:
[
["name", score],
["name", score],
...
]
Code:
Input:
[
["Buddy", 7],
["Star", 9],
["Bell", 9],
["Joy", 8],
["Angel", 7]
]
Output:
["Bell", "Star", "Joy", "Angel", "Buddy"]
CODE]
[HEADING=2]Test Cases[/HEADING]
Make sure your function works with these magical test cases:
[CODE]
// Test Case 1 - The Workshop Warmup
const test1 = [
["Holly", 8],
["Eggnog", 7],
["Lights", 9],
["Parade", 8]
];
// Test Case 2 - The North Pole Party
const test2 = [
["Sugar", 10],
["Tinsel", 8],
["Angel", 10],
["Rudolf", 9],
["Star", 8]
];
// Test Case 3 - The Midnight Magic
const test3 = [
["Mistle", 7],
["Encore", 9],
["Ribbon", 9],
["Ruby", 9],
["Yule", 8],
["Carol", 7],
["Helper", 8],
["Icy", 7],
["Santa", 10],
["Tree", 8]
];
Extra Challenge
For extra holiday cheer, try to solve it without using any built-in sorting methods! 🎄Hints
- Remember that strings can be compared alphabetically using normal comparison operators
- Think about how bubble sort or selection sort might help
- Don't forget to handle the case when there are fewer than 5 children in the list!
🌟 Finding Today's Secret Message Piece 🌟
Each day's challenge contains part of a special Christmas message. Today's piece is hidden in Test Case 3!To find it:
1. First, solve the sorting challenge correctly
2. Look at your sorted output for Test Case 3
3. Some names are special - their first letters spell out today's message piece
4. Look for a 5-letter word that feels festive!
5. Write this word down - you'll need it for Day 5!
Remember: This is just Part 1 of 3 of our Christmas message. Keep solving each day's challenge to collect all the pieces!
Submission
Submit your code solution AND the secret word you found. But shhh... keep the secret word to yourself - everyone needs to solve it on their own! 🤫Good luck, and may your code be merry and bright! 🎄✨
---
The true spirit of Christmas is in the joy of coding! Even if your solution isn't perfect, what matters is the fun you have along the way!* 🎅