var i =10; var j =0; while (i > 0){ j++; i=i/2; };
1/27/2019 11:47:11 AM
Sara Hadj-Ali3 Answers
New AnswerI haven't used JavaScript in a while, but I'm gonna guess that i is treated as a floating-point number instead of an integer. So, every time you execute the loop, the following happens: i j 10 0 5 1 2.5 2 1.25 3 0.625 4 . . . . . . You get the idea. The way around that problem is: i=Math.floor(i/2); inside the while loop.
var data =41; var o ={data : 42}; o.print =function(){ console.log(this.data); var print2 = function(){ console.log(this.data); } print2() ; }; var data =43 ; o.print() May you please look at the code below ,i didn't really understand the" this " notation and why the result we obtained is 42 43 ? Thank you souch 🙏🙏🙏🙏
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message