For example: var seatnum= [1,2,3,4,5]; I want to select a seatnum through command prompt Select your seatnum; 5 Then seatnum 5 change to 0 because this seatnum selected Then output seatnum [1,2,3,4,0 ];
You can use prompt
like this to receive input from user.
let arr = [...'123456']; const select = prompt('Select seat number') const output = arr.map(e=> (e === select ? '0' : e) ) console.log(output)
I suggest you to read more about prompt here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.