skip to Main Content

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.

2

Answers


  1. This should work just fine:

    function add (digit) {
        let figure = digit * 1.5;
        console.log("Answer is", figure);
    }
    
    let value = parseInt(prompt());
    
    add(value);
    
    Login or Signup to reply.
  2. In your code only problem is following part

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

    instead of above code just use this way

    add(parseInt(prompt()))
    
    function add(digit){
    
        var figure = digit * 1.5;
    
        alert("Answer is " + figure);
    
    }
    
    add(parseInt(prompt()))
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search