0

Write a java script program to swap the 3 number without function

26th Oct 2018, 4:19 AM
sayma
3 Answers
+ 3
Mike Utty you are right, but only in ES6 Use array destructuring in ES6 https://code.sololearn.com/WTvgbMwzi2Gg/?ref=app
26th Oct 2018, 8:33 AM
CalviÕ²
CalviÕ² - avatar
+ 2
uh been awhile. I think [a,b,c] = [c,b,a] works also. I may be wrong.
26th Oct 2018, 5:18 AM
Mike Utty
Mike Utty - avatar
0
I think "swap" is defined for two elements only. One can't swap simultaneously among three elements just like you can't add three numbers simultaneously. You'll have to add two of them and then third to their result. So, swap the two numbers and then exchange third with any of the exchanged two. a= a+b b= a-b a= a-b similarly among c & a or c & b.
26th Oct 2018, 4:33 AM
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½ - avatar