Search code examples
javascriptreactjsangularwebconsole

using Prompt to add a value to function


function add (digit){

var figure = digit * 1.5;

console.log("Answer is " + figure);

}

add() = parseInt(prompt(''));

I need help from someone I want o use the prompt to add a value to the add function parameter I was expecting the prompt will pop up an input dialogue box in which I will input a value that will be placed in the add() function.


Solution

  • This should work just fine:

    function add (digit) {
        let figure = digit * 1.5;
        console.log("Answer is", figure);
    }
    
    let value = parseInt(prompt());
    
    add(value);