Convert A String To A New String Flashcards

1
Q

First Step

A

create a variable that holds the string value and ignores case:
let word = str.toLowerCase();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Second Step

A

Create a variable to hold the finished string to return after it’s looped through
let unique = ‘’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Third Step

A

Loop through all letters in the string:
for (let i = 0; i < words.length; i++) {

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fourth Step (Inside the loop)

A

//check for letters that repeat:

if (word.lastIndexOf(word[i]) === word.indexOf(word[i]) {

//for each character that never duplicates, place ‘(‘
unique += ‘(‘;
} else {
//for each that is a duplicate, place ‘)’
unique += ‘)’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Final Step

A

return unique;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly