본문 바로가기
알고리즘/Codewars

[Codewars] Name Shuffler (8 kyu) / JavaScript

by fluss 2023. 3. 31.

https://www.codewars.com/kata/559ac78160f0be07c200005a

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

Write a function that returns a string in which firstname is swapped with last name.

Example(Input --> Output)

"john McClane" --> "McClane john"

 

코드

function nameShuffler(str){
  return str.split(' ').reverse().join(' ');
}

댓글