1.
What is the output of the following code?
function reverseString(str) {
return str.split('').reverse().join('');
}
console.log(reverseString('hello'));
ohlle
lloeh
olleh
hello
Correct: C
The reverseString function takes a string as input and uses the split method to convert the string into an array of characters. It then uses the reverse method to reverse the order of the elements in the array. Finally, it uses the join method to convert the array back into a string. In this case, the input string is hello and the output is olleh, which is the reversed version of the input string.
1 / 32