0

why is this code giving the answer 5

const t = { val: 2 }; const c1 = () => t.val +=1; const c2 = () => t.val *=2; c2(); c1(); console.log(t.val);

4th Dec 2021, 5:46 PM
Steve Nova
Steve Nova - avatar
1 Antwort
+ 1
Steve Nawa 🇳🇦 c2() = t.val = t.val * 2 = 2 * 2 = 4 c1() = t.val = t.val + 1 = 4 + 1 = 5
4th Dec 2021, 6:27 PM
A͢J
A͢J - avatar