0

Im running this code and it's only saving the last element of the list. Each time it prints out I only get the price.

addThing(whichList){

    let link = prompt("whats the link");
    let item = prompt("whats name of the item");
    let price = prompt("whats the price, only put in numbers otherwise will causes error")
    
    let whyNoWork=[link,item,price]
    price = parseInt(price);
    //TODO have this line working console.log(this.state[whichList]);
    this.setState({whichList:whyNoWork})
    console.log(whyNoWork)
    // https://stackoverflow.com/questions/29886552/why-are-objects-not-iterable-in-javascript look at this to add object into state

    //  okay I think to by pass I can just run it as a list:[(da link here),(name be here),(price)]
}

Note that works in a normal envoriment, but when i put this into a

0 Answers0