Arrays and Strings #5
-
bro string and arrays aa kuduthu atha reverse panni katunga bro , antha sentece la oru space irukkura maathiri like "Hello World" ==>"olleH dlroW" |
Beta Was this translation helpful? Give feedback.
Answered by
anburocky3
Jan 10, 2024
Replies: 1 comment
-
You can do like this: const message = 'Hello World'
// Method: 1 using reduce()
const method1 = Array.from(message).reduce((accumulator, currentValue) => {
return [currentValue].concat(accumulator)
})
console.log('Method 1:', method1.join(''))
// Method: 2 using reverse()
const method2 = Array.from(message).reverse()
console.log('Method 2:', method2.join('')) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
anburocky3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do like this: