Which of the followingfunction is used to reverse the string
Answers
Answered by
0
Answer:
As long as you're dealing with simple ASCII characters, and you're happy to use built-in functions, this will work:
function reverse(s){
return s.split("").reverse().join("");
}
If you need a solution that supports UTF-16 or other multi-byte characters, be aware that this function will give invalid unicode strings, or valid strings that look funny. You might want to consider this answer instead.
[...s] is Unicode aware, a small edit gives:-
function reverse(s){
return [...s].reverse().
Similar questions
Math,
4 months ago
Science,
4 months ago
Geography,
8 months ago
World Languages,
8 months ago
English,
1 year ago