[문제] Write a function toWeirdCase (weirdcase in Ruby) that accepts a string, and returns the same string with all even indexed characters in each word upper cased, and all odd indexed characters in each word lower cased. The indexing just explained is zero based, so the zero-ith index is even, therefore that character should be upper cased.
The passed in string will only consist of alphabetical characters and spaces(' '). Spaces will only be present if there are multiple words. Words will be separated by a single space(' ').
Examples:
toWeirdCase( "String" );//=> returns "StRiNg"
toWeirdCase( "Weird string case" );//=> returns "WeIrD StRiNg CaSe"
map((x,i)) x는 배열 내 현재값, i는 배열내 현재 값의 index
출처: https://im-developer.tistory.com/36?category=831367 [Code Playground]
'알고리즘' 카테고리의 다른 글
JS 삼각형인지 확인하기 (0) | 2020.08.26 |
---|---|
JS 제곱근, 제곱수 구하기 (0) | 2020.08.26 |
JS 카드번호 마지막 4글자 빼고 #으로 변환 (0) | 2020.08.26 |
JS 특정 문자를 공백으로 치환 (0) | 2020.08.26 |
JS 입력받은 단어중 가장 짧은 단어의 길이값 구하기 (0) | 2020.08.26 |