アルゴリズム42-Square Every Digit
1583 ワード
Q.
Welcome. In this kata, you are asked to square every digit of a number and concatenate them.
For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1.
Note: The function accepts an integer and returns an integer
A) function squareDigits(num){
return +String(num).split('').map(el => el * el).join('')
}
初めてmapを使う具体的な使い方はまだ分かりません.高次関数を学んだ私は再認識しなければならない.
Reference
この問題について(アルゴリズム42-Square Every Digit), 我々は、より多くの情報をここで見つけました
https://velog.io/@tamagoyakii/알고리즘-42-Square-Every-Digit
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
function squareDigits(num){
return +String(num).split('').map(el => el * el).join('')
}
初めてmapを使う具体的な使い方はまだ分かりません.高次関数を学んだ私は再認識しなければならない.Reference
この問題について(アルゴリズム42-Square Every Digit), 我々は、より多くの情報をここで見つけました https://velog.io/@tamagoyakii/알고리즘-42-Square-Every-Digitテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol