0

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....

4
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by revathyrace
0

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;
    }
0

Hi,

always mark thread as solved, when you get solution, as it will help others if they are searching for a solution.

0

<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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.