DEV Community

Discussion on: Reverse a string: awful answers only

Collapse
mdbetancourt profile image
Michel Betancourt • Edited on

so easy

function reverse(val: string) {
  if(val==='a'){
    return 'a'
  } else if(val==='aa') {
    return 'aa'
  } else if(....) {} // 75 years later
  else if (val === 'aucn') {
    return 'ncua'
  }  else if(....) {} // 2000 years later
  else if (val === 'asynchronous') {
    return 'suonorhcnysa'
  }
}
console.log(reverse('asynchronous'))
Enter fullscreen mode Exit fullscreen mode

this works for any amount of chars xd