title: How do i replace a specific element in a JavaScript array without knowing the index?
body: <p>hi ive looked at similar questions but they weren't helpful.</p>
  <p>I am creating a guestlist that takes 10 people, if the user tries to add an 11th name to the array, the program should say, “You have already added 10 people to your guest list. Would you like to replace someone on the list with this person? y/n: ”</p>
  <p>If the user enters “y”, the program should output the current guest list and then
  asks, “Who would you like to replace?”</p>
  <p>this is my code:</p>
  <pre><code>
  let i = 0;
  let input = names;
  do {
     
     input = names.push(prompt(&quot;Who would you like to invite to your dinner party?&quot;));
  
   i++;
  }
  while (names.length &lt; 11);
  
  if (names.length == 11 ){
     input2 = prompt(`You have already added 10 people to your guest list. Would you like to
     replace someone on the list with this person? Y/N:`)
  }
  
  let yes = &quot;Y&quot;;
  let no = &quot;N&quot;;
  
  if (input2 === yes){
     replaceInput = prompt((`Your guests are:${names}
    
    Who would you like to replace?`));
  } 
  
  alert(`your new guests are: ${names}`)
  </code></pre>
  <p>now how do i make the program replace the person the user specifies with the 11th
  person given and output the updated list?</p>