My while loop is not working. Pls help

This is what I am trying to accomplish in javascript,

Write a while loop that will prompt the user if they would like to print their name. If the
answer is yes, log their name to the console then prompt them if they would like to print
their name again. If yes, log their name to the console again but this time add an
exclamation point at the end of the string. Continue to add an exclamation point for every
time the user agrees to wanting to print his or her name.
Prompt: ‘Would you like to print your name?’ > ‘yes’
Output: ‘Hello. My name is Adam’
Prompt: ‘Would you like to print this again?’ > ‘yes’
Output: ‘Hello. My name is Adam!’
Prompt: ‘Would you like to print this again?’ > ‘yes’
Output: ‘Hello. My name is Adam!!’
Prompt: ‘Would you like to print this again?’ > ‘no’

This is what I have so far but it wont loop back and I am not sure how to make a string that will add the exclamation point.

var a= prompt(“would you like to print your name”);
while(a===“yes”, c===“yes”);{
var b= prompt(“what is your name?”);
var c= prompt(“would you like to print this again?”);
}
console.log(b + “!”);

Start with a minimal loop, maybe count 1-10 or copy an example (google mdn while loop)
Then add the other stuff one part at a time, test each time you add something.
Don’t forget to compare and figure out the mistake afterwards, and consider how it came to be and how you could have detected and fixed it. Isolating the individual parts and testing them is a pretty good strategy when everything else fails

1 Like

Good advice. Thank you

I was also facing the same issue while coding…Thanks for sharing this…