Prompt when hitting cancel

So, I have a prompt box in my program (using JavaScript) asking the user to enter their name (for this example), which will loop 5 times to gather 5 names. If they hit cancel, I want it to come up with an additional prompt box telling the user that a name was not supplied. How would I go about doing this?

for (let i = 0; i < 5; i++) {
        let name = '';
 while (name === '') {
          name = prompt('Enter name', '');
        }

I am thinking you want an “EventListener” for the cancel button. Inside that listener use an “alert” and then set maybe a boolean for your while statement .

 for(let i = 0, i < 5; i++){
      let name = '';
      noNameProvided: false
}

while(name ===  ' ' || noNameProvided === false){}