Boss lesson · Unit 03
A text toolkit
A palindrome check, a vowel counter and a Caesar shift
What you practise
- Small typed functions built and combined: a palindrome check, a vowel counter, a Caesar shift, each checked against answers you know
Try a question from this lesson
Pick one
A palindrome reads the same backwards: level, noon. Plan before you code. Which steps check any word?
Correct answer
Build the word backwards, then compare with the original
Why
A palindrome is defined by reading backwards, so build the backwards word and ask whether it equals the original. The other ideas fail on real words: noon has an even count, and level has a letter that appears once.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Positions in a string
The characters of a string are numbered, and the numbering starts at 0, not 1. The number is called a position, or index.
abc.indexOf("d") asks: at which position is this character?
abc[3] asks the opposite: which character is at this position?
With 26 letters, the positions run from 0 to 25.
const abc = "abcdefghijklmnopqrstuvwxyz";
console.log(abc.indexOf("a")); // 0
console.log(abc.indexOf("d")); // 3
console.log(abc[3]); // d
console.log(abc[25]); // z11 more exercises in the app
- 4× type the answer
- 1× order the lines
- 3× multiple choice
- 1× true or false
- 2× fill the blanks
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.