アルゴリズム73-バイナリAddition//進数


Q.


Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition.
The binary number returned should be a string.
Examples:(Input1, Input2 --> Output (explanation)))
1, 1 --> "10"(1 + 1 = 2 in decimal or 10 in binary)
5, 9 --> "1110"(5 + 9 = 14 in decimal or 1110 in binary)

A)

function addBinary(a,b) {
  return (a + b).toString(2)
}
少し前にヒューパから教わった振子を変える方法を思い出しました…!私はこの日だけを待っています!使うタイミング…!!!😆
parseInt(a, b)       // 표시된 수(a)를 진법(b)에 맞춰 10진법으로 변환한다.
parseInt(100, 2)     // 4  
parseInt('a', 16)    // 10

(a).toString(b)      //표시된 10진법 수(a)를 진법(b)에 맞춰 변환한다.
(4).toString(2)      // '100' 
(10).toString(16)    // 'a'