how subtraction two number, without use minus operator (-)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

how subtraction two number, without use minus operator (-)?

use of other operators

20th Feb 2017, 10:28 PM
Mohammad Sahrayi
Mohammad Sahrayi - avatar
1 Answer
+ 2
You could use bitwise operators JS: var a =6; var b = 2; var subtract; var subtract = a + (~b +1); console.log(subtract); //4
20th Feb 2017, 10:51 PM
tida
tida - avatar