Ok. I make a program for calculating the power of 2. I have the html code . But i describe it for you first. There is one input with id='inputin' and below there is a button. In the input you write a number . This number will be the exponent of two and after you push the button it appears a console.log window with the result
here the html :
<div id='main'>
<input type="number" name="power2" placeholder='Enter the power' id='inputin'><br/>
<button id="submit" onclick="binaryS()">Do it!</button>
</div>
and the javascript:
binaryS = function() {
x = document.getElementById("inputin").value;
y=1;
for(i=1;i<=x;i++) {
y=y*2;
}
console.log (y);
};
Why it doesnt work? Any help? and if you could suggest instead of an ugly console.log window how can i appear it in a new div somewhere in the page? Thnx
alert(y)for a quick check (nothing fancy)console.log()doesn't open a window automatically? You have to view the log manually using Developer Tools.