hi all....
i want to add 01+1 and my desired output is 02.
my code is
var t=01;
var t2=t+1;
alert(t2);
the alert value is 2.
I want 02....what will i do?
thanks in advance....
hi all....
i want to add 01+1 and my desired output is 02.
my code is
var t=01;
var t2=t+1;
alert(t2);
the alert value is 2.
I want 02....what will i do?
thanks in advance....
Hi,
you can sumply use
t2 = "0"+t2;
but if you also want to give a condition that a 0 will be prefixed only for numbers less than 10.
then
if(t2<10)
{
t2 = "0"+t2;
}
thank you Mr:Vicky.....thanks a lot..............
Hi,
always mark thread as solved, when you get solution, as it will help others if they are searching for a solution.
<script language="javascript">
var a,b,c;
a=prompt("enter 1st no");
b=prompt("enter 2nd no");
c=a*b
document.write(c);
</script>
</body>
</html>
0r
c=a-b
or
c=a\b
or
but a+b is not working...
do you know how to add two numbers?
pls 919895698898
hai are you know adding two numbers in javascript
for addition of two numbers in javascript, use the following
sum=parseInt(a)+parseInt(b);
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.