I need someone to help explain what the line temp <<= y; does in this bit of javascript code and how i could recreate this program in Little Man Computer.
var temp = 14;
var y = 2;
temp <<= y;
document.write(temp);
I need someone to help explain what the line temp <<= y; does in this bit of javascript code and how i could recreate this program in Little Man Computer.
var temp = 14;
var y = 2;
temp <<= y;
document.write(temp);
It is the left shift assignment operator. It shifts the number in binary format to the left and adds that many zeros to the end. So, in your case:
var temp = 14; // which is 1110 in binary
temp <<= y; // transforms it in 111000
document.write(temp) // the number in base 10 is 56