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

[Codewars] Sort and Star (8 kyu) / JavaScript

by fluss 2023. 3. 9.

https://www.codewars.com/kata/57cfdf34902f6ba3d300001e

 

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:

You will be given a list of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.

The returned value must be a string, and have "***" between each of its letters.

You should not remove or add elements from/to the array.

 

코드

function twoSort(s) {
  return s.sort()[0].split('').join('***');
}

댓글