Mark As Completed Discussion

Are you sure you're getting this? Click the correct answer from the options.

What will the following pseudocode do to an input string?

1function reverseStr(str) {
2    let start = 0;
3    let end = str.length - 1;
4    let strCopy = Array.from(str);
5    while (start < end) {
6        let temp = strCopy[start];
7        strCopy[start] = strCopy[end];
8        strCopy[end] = temp;
9        start++;
10        end--;
11    }
12    return strCopy.join('');
13}

Click the option that best answers the question.

  • Make a copy
  • Reverse the string
  • Swap the first and last letters
  • Infinite loop