Join the first and last name with a space.
Acceptance criteria
- 1.#out should show Ada Lovelace.
JavaScript Tutorial · JavaScript Strings
These 10 tasks go with the JavaScript String Concatenation chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Concatenation joins strings together into a longer one.” .
1.Join two namesexercise · easy · 10 min
Join the first and last name with a space.
Passes when: #out should show Ada Lovelace.
2.Add to a stringexercise · easy · 10 min · practice plan
Build the text up with the plus-equals operator.
Passes when: #out should show Ada Grace Alan.
3.Repeat a stringexercise · easy · 10 min · practice plan
Repeat the pair of letters three times.
Passes when: #out should show ababab.
4.Force the addition firstexercise · easy · 10 min · practice plan
Use brackets so the numbers add before joining.
Passes when: #out should show Total: 8.
5.Join an arrayexercise · medium · 10 min · practice plan
Use join rather than a loop to build the list.
Passes when: #out should show Ada, Grace, Alan.
6.Fix the missing spacebug fix · easy · 8 min
The names have run together.
Passes when: #out should show Ada Lovelace.
7.Fix the numbers joined as textbug fix · easy · 8 min · practice plan
Brackets are needed so the addition happens first.
Passes when: #out should show Total: 8.
8.Fix the total started as textbug fix · easy · 8 min · practice plan
Starting at an empty string joins the numbers instead of adding.
Passes when: #out should show 60.
9.Fix repeat used with joinbug fix · easy · 8 min · practice plan
repeat takes a count, not a separator.
Passes when: #out should show ababab.
10.Fix the loop that leaves a separatorbug fix · easy · 8 min · practice plan
The trailing separator should not be there.
Passes when: #out should show clean ending.
Between them these tasks cover Concatenation, repeat and Coercion.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.