Why d (variable)is treated as string | Sololearn: Learn to code for FREE!

+3

Why d (variable)is treated as string

I don't know why it's happening d is treated as string https://code.sololearn.com/WruS83awNHHw/?ref=app

11/15/2017 10:51:47 AM

Vaibhav Kushwaha

5 Answers

New Answer

+3

That's because prompt accepts strings only. Do like the following: var y = Number(prompt("Enter year"));

+5

use parseInt to convert it to integer.

+2

+2

how to split a numeric data input like I have to use 3 of 5340

0

Covert it to a string, then get the index of your number and catch it with substr. For example, var x = 5340 alert(x.toString().substr(1,1))