The NDEFWriter write()-method currently returns a promise which is resolved on a successful write operation and rejected on a failed write operation, so you would need to use async-await to be able to loop those writes like that. Here is a reference to the Web NFC API Write-operation: https://w3c.github.io/web-nfc/#writing-to-an-nfc-tag