Calling the contract function through web3js is not successful, but it can be done on remix ide

the front end uses web3js, to call a simple contract function with an error. But it can be successful on remix.
here is the contract function, which is a simple loop, but there is also an error. What"s going on? Thank you.

clipboard.png

metamask

clipboard.png

clipboard.png

Mar.14,2021
Menu