0

How can I use input information?

It's possible to store a number you get from an input in a variable and then use it to do operations (multiply and sum)? I'm creating a web with html and JavaScript, that's my code if you wanna take a look. If you do and you found what's wrong it would be great!! https://code.sololearn.com/WkFdIbvCKxd3/?ref=app

21st Feb 2020, 8:12 PM
Miquel
2 ответов
0
Miquel Hola, Yes you can store that in an array. You will have to declare one empty array first and then use the push method to store it inside. Example: let myValues=[]; let value=document.getElementById("something").value; myValues.push(value); Each new entries will add in the array and then you could access an handle it by its index...
23rd Feb 2020, 2:41 AM
EmmanueLZ.
EmmanueLZ. - avatar
0
Also,I m not very sure with js but from what I see you put your script at the end in your html which is good if you insert your js code within your script tags, untill now I never specified a src for a script written in the sololearn playground, as it is I think it is useless here and while you use external js,one problem I encountered sometime with executing scripts has been solved by adding in the js file at the beginning: window.onload=function(){ ...Your whole code inside... } it makes the js file executing only once the html has been loaded. You can test that maybe... Have a good day.
23rd Feb 2020, 2:58 AM
EmmanueLZ.
EmmanueLZ. - avatar