javascript for beginners ^^
Posted: Wed Nov 05, 2008 6:33 pm
Hey guys,
first: I'm an absolute beginner in things like coding, crypto and so on.
But I'm very interested at all. I have basics in html and tried to learn javascript.
So i began solving the challenges a few days ago. I wrote a little hexa-deci-bin program and was able to solve some of the elementary challenges.
Just a question I didn't find an answer for in Internet:
i.e: I have a decimal number. I divide it with 2 and "save" the rest in a var named savednumber.
var input;
var savednumber;
var number;
input = prompt("Decimal number, to convert in binary system:");
number = input;
savednumber = (number % 2);
alert (savednumber)
to get the whole binary number I have to repeat this step as often as number isnt smaller than 1 or better isnt 0
var input;
var savednumber;
var number;
input = prompt("Decimal number, to convert in binary system:");
number = input;
if (number >= 1)
{savednumber = (number % 2);
alert (savednumber);
number = parseInt (number / 2);}
so far so good ... but the problem is that this program alerts a number, i have to press ok, it alerts the next number ... an so on ... it isnt ablr to present me the whole string of the binary number ...
can you help me to solve this problem ?
and if you know javascript better than me, which shouldn't be too hard you could please tell me a way (like using different variables like integers or sth. like that) to calculate with more than 20 charakters or sth like this ...
thank you
first: I'm an absolute beginner in things like coding, crypto and so on.
But I'm very interested at all. I have basics in html and tried to learn javascript.
So i began solving the challenges a few days ago. I wrote a little hexa-deci-bin program and was able to solve some of the elementary challenges.
Just a question I didn't find an answer for in Internet:
i.e: I have a decimal number. I divide it with 2 and "save" the rest in a var named savednumber.
var input;
var savednumber;
var number;
input = prompt("Decimal number, to convert in binary system:");
number = input;
savednumber = (number % 2);
alert (savednumber)
to get the whole binary number I have to repeat this step as often as number isnt smaller than 1 or better isnt 0
var input;
var savednumber;
var number;
input = prompt("Decimal number, to convert in binary system:");
number = input;
if (number >= 1)
{savednumber = (number % 2);
alert (savednumber);
number = parseInt (number / 2);}
so far so good ... but the problem is that this program alerts a number, i have to press ok, it alerts the next number ... an so on ... it isnt ablr to present me the whole string of the binary number ...
can you help me to solve this problem ?
and if you know javascript better than me, which shouldn't be too hard you could please tell me a way (like using different variables like integers or sth. like that) to calculate with more than 20 charakters or sth like this ...
thank you