What I did (in code):
const character = 'a'
const timesRepeated = 50
let answer = ''
for (let i = 0; i < timesRepeated; i++) {
answer += character
}
console.log(answer)
console.log(answer.length)
Logs: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Logs: 50
What I did (in English):
- Assign the string
'a'to the variablecharacter. - Assign
50to the variabletimesRepeated. - Assign
''(an empty string, i.e., a string with a length equal to 0) to the variableanswer. - The
forloop: Set the variableito start at0, run the loop as long asiis less thantimesRepeated, and at the end of each iteration of the loop, incrementiby 1. Each iteration of the loop, storeanswer + characterinanswer(i.e., updateanswer). - Log to the console
answer. - Log to the console
answer.length.
What I practiced:
- Same as above.
What I learned:
- From the above code, I didn't learn anything new.
- For this section, there was no instruction outside of the exercise itself.
What I still might not understand:
- Nothing for this section.
Top comments (0)