How to use product from the 'Prompt' command

Good morning Forum,

I am starting to get the hang of writing functions and understanding how a program is constructed. I am working through the practice questions on lesson 11 of 38 within the ‘Javascript Programming for Blockchain Developers’ course and all I want to know is how do I use the product of a Prompt command.

For instance, I would like to use a Prompt command to ask the user to enter two numbers. That part I can do but how do I then capture what they have written so that I can use it within the next stage of the function? I would like to do something like this (the syntax probably is not 100%):

const askUserA=(prompt(“Enter a number to represent x”));
const askUserB=(prompt(“Now please enter a number to represet y”));

–> The user then enters in their numbers which are returned to the Console…
–> I would then like to be able to capture their answer so that it can inform the following element of the function. So, something like this:

Function addNumbers=(askUserA, askUserB); {

–> The Console would then display the result. I just want to understand how I would actually get this to work so that I can create more complex functions and play around a bit.


Many thanks for reading.

1 Like

Cannot believe I am replying to my own post but pretty pleased with this little program as I can use it in my work (I am a civil engineer):


And it works! Happy boy :slight_smile:


I’m just getting into the programming side and I’m nervous… I have been reading eloquent JavaScript, practicing on an app I downloaded on my phone, but I feel myself trying to skimp on just doing it… this post is great, thanks for sharing