본문 바로가기

코테연습185

25.Create Phone Number Description: Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number. Example createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890" The returned format must be correct in order to complete this challenge. Don't forget the space after the closing parentheses! function createPhoneNumber.. 2022. 4. 2.
24.Bit Counting Description: Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case var countBits = function(n) { let sum = 0; n.toString(2).split('').map(str => { sum += N.. 2022. 4. 1.
23.Who likes it? Description: You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item. Implement the function which takes an array containing the names of people that like an item. It must return the display text as shown in the examples: [] --> "no one likes this" ["Peter"] .. 2022. 4. 1.
22.Array.diff Description: Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result. It should remove all values from list a, which are present in list b keeping their order. arrayDiff([1,2],[1]) == [2] If a value is present in b, all of its occurrences must be removed from the other: arrayDiff([1,2,2,2,3],[2]) == [1,3] function arrayDiff(a, b).. 2022. 3. 31.