I'm working on a small javascript project. I'd like to receive a users console input and furthermore use the input to calculate some values.
I capture the users input in a variable called answer.
when using console.log(answer) the answer get printed.
let's say the user's answer was MILK
my current (working and hardcoded) call looks something like this:
let p = 0;
call.prices('MILKPRICE', (err, tic) => { p = tic.MILKPRICE; });
now I'd like to replace the word 'milk' with the user's answer
let p = 0;
call.prices(answer+'PRICE', (err, tic) => { p = tic.answer+'PRICE'; });
which returns undefined. is there a way to actually use the user's input and not hardcoding all possible records?
thank you very much
call.pricesfunction? can you share the definition of this function?call.prices, however, it's mainly the issue that I cannot getp = tic.answer+'PRICE'this to actually use the user's input