Skip to content

Commit 2c0563a

Browse files
committed
completed add without + [issue akshitagit#2]
1 parent 0c3e274 commit 2c0563a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

DailyCode/add/add-without-plus.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
function add(a, b){
2-
while(b!=0){
3-
carry = a & b
4-
5-
a = a ^ b
6-
7-
b = carry << 1
1+
function add(num1, num2){
2+
while(num2!=0){
3+
carry = num1 & num2 //carry
4+
num1 = num1 ^ num2
5+
num2 = carry << 1
86
}
9-
return a
7+
return num1
108
}
119

1210
console.log(add(5, 7))

0 commit comments

Comments
 (0)