Exiting Loops with breaks

In the learning section with the above title, I am curious as to the function of input.focus in the following code:

const contacts = ['Chris:2232322', 'Sarah:3453456', 'Bill:7654322', 'Mary:9998769', 'Dianne:9384975'];
const para = document.querySelector('p');
const input = document.querySelector('input');
const btn = document.querySelector('button');

btn.addEventListener('click', function() {
  let searchName = input.value.toLowerCase();
  input.value = '';


  for (let i = 0; i < contacts.length; i++) {
    let splitContact = contacts[i].split(':');
    if (splitContact[0].toLowerCase() === searchName) {
      para.textContent = splitContact[0] + '\'s number is ' + splitContact[1] + '.';
    } else {
      para.textContent = 'Contact not found.';

How does this affect the loop?

This does not affect the loop in any way.

focus() causes the element it is invoked on to receive focus (i.e. equivalent to if you clicked inside the form input, or tabbed to it, but done using JavaScript), provided it can receive focus.

In this case, it is just there so that after you’ve clicked the button and submitted a search, the input field is focused automatically, ready for the next search. It is a common usability enhancement that you see in lots of search forms and suchlike.