for loop III - abort running loop
breakstatement to achieve this. You can place the
breakstatment anywhere inside the code-block of a loop. As soon as
breakis evaluated, the loop is terminated. Usually, you would place
ifcondition. Then, the loop will only abort if a certain condition met. In the example below, we iterate through the elements of the array mixed. In each iteration, we append the current element of mixed to the new array newArray. But, in this exercise we want to abort the loop if the current element is not of type number. Complete the
ifstatement below and execute
breakif the current element is not of type number.
Get a premium membership to access this content: