본문 바로가기

코테연습185

9.Shortest Word Description: Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types. function findShort(s){ const words = s.split(' '); const short = words.reduce((previousValue, currentValue) => { return currentValue.length < previousValue.length ? currentValue : previousValue; }); return short.length; } 주어진.. 2022. 3. 18.
8.Exes and Ohs Description: Check to see if a string has the same amount of 'x's and 'o's. The method must return a boolean and be case insensitive. The string can contain any char. Examples input/output: XO("ooxx") => true XO("xooxx") => false XO("ooxXm") => true XO("zpzpzpp") => true // when no 'x' and 'o' is present should return true XO("zzoo") => false function XO(str) { const words = [...str.toLowerCase(.. 2022. 3. 18.
7.List Filtering Description: In this kata you will create a function that takes a list of non-negative integers and strings and returns a new list with the strings filtered out. Example filter_list([1,2,'a','b']) == [1,2] filter_list([1,'a','b',0,15]) == [1,0,15] filter_list([1,2,'aasf','1','123',123]) == [1,2,123] function filter_list(l) { return l.filter(num => Number.isInteger(num)); } 원래 맨 처음에 제출했던 코드는 func.. 2022. 3. 17.
6.Isograms Description: An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case. Example: (Input --> Output) "Dermatoglyphics" --> true "aba" --> false "moOse" --> false (ignore letter case) function isIsogram(str){ if (str.len.. 2022. 3. 16.