Javascript · Strings
Challenge
The full text of this chapter, to read or revisit. To practise, do the exercises.
▶ Do the exercises
Exercise 1 — Codémon Profile Creator
A wild Aquachu appears! Time to create its profile.
Create Aquachu's profile: 1.
name
is
"Aquachu"
2.
type
is
"Water"
3.
level
is
12
4. Use a template literal to display the three data in one sentence
Starter code
// Create Aquachu's profile
Exercise 2 — Clean Codémon Data
The Codémon scanner is buggy! The data is messy.
Clean up the data: 1. Use Pyrochu's messy
name
(from starter code) 2. Remove extra spaces 3. Format the name: first letter uppercase, rest lowercase 4. Create a message using template literals:
"Codémon: [NAME]"
5. Display the clean message
Starter code
let name = " pyrochu "; // Clean the data
Exercise 3 — Codémon Data Parser
Success! Pyrochu is caught 🎉 But wait... You found an encrypted Codémon database!
Decode the data: 1. The string is
"FLORACHU-plant-055"
2. Extract the name (first 8 characters) 3. Extract the type (characters 9 to 14) 4. Extract the level (last 2 characters) and convert to number 5. Display:
"Name: FLORACHU | Type: plant | Level: 55"
Starter code
let data = "FLORACHU-plant-055"; // Decode the data
Back to the course