Explore BrainMass
Share

Explore BrainMass

    Javascript

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    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);

    © BrainMass Inc. brainmass.com October 10, 2019, 2:56 am ad1c9bdddf
    https://brainmass.com/computer-science/javascript/javascript-parsefloat-400498

    Solution Preview

    Program 1

    The program script will output 42 on the webpage; the program considers ...

    Solution Summary

    The solution provides to the point answer to the problem stated.

    $2.19