So I currently have JavaScript that asks for user prompts and inputs the data into a table, it’s a simple credit limit calculator. I know I can use something else like a button, but is there a way to pause and load in-between prompts? From testing I know loading separate javascript files will load in-between them, but is there another way?
Here’s a codepen link if anyone is interested, but I just want to know if I’m missing something, or if I just need to move onto another method here!
So it initially asks for your credit limit and balance, and then will keep prompting you for balance changes until you reach the credit limit, in-between the balance change prompts, I’d like to have it update the HTML table. I don’t necessarily need a time limit in-between them, outside of how long it takes to update the table.
instead of creating a new table everytime, write a function that returns some divs and takes the table values as variables.
const createTable = (value) => {
let table = <div>value</div> // create your table here
return table
}
create a variable that updates after user submits required data
let creditLimit = 0; // initialize variable
let input = (() => {
return +prompt("whats your credit limit?") /// plus sign in front (+prompt) converts string to float or number
})() // self executing function
const updateCreditLimit = (value) => {
creditLimit += value
}
then enter the value of createTable into the div that you want it.