Create two programs differ uses parsefloat


Discuss the below:

Q: The following two programs differ in that one uses parseFloat and the other does not. What will be the output from each program if the user inputs 4 followed by 2?

Give your reasons.

Program 1

var first;
var second;
first = window.prompt('Enter a digit','0');
second = window.prompt('Enter a second
digit','0');
document.write(first + second);

Program 2

var first;
var second;
first = window.prompt('Enter a digit','0');
second = window.prompt('Enter a second
digit','0');

first = parseFloat(first);

second = parseFloat(second);

document.write(first + second);

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create two programs differ uses parsefloat
Reference No:- TGS01938173

Now Priced at $25 (50% Discount)

Recommended (91%)

Rated (4.3/5)