GoConqr has a new look! Let us know what you think.

Module 10 of 18 · Media

Break Keyword

Kostas Diakogiannis

Break Keyword

The Break keyword

The break keyword can exit the body loop whenever we specify. It is heavily used when we want to stop the loop process under a when condition is met, usually when an exception occurs.

There is no specific syntax, we just throw the word 'break' inside the body of the loop context and if the code finds itself inside there, and reaches the 'break' line the loop exits!

L-5. In the previous container problem. The captain is tremendously superstitious and will not accept the ship to travel if it contains more than 112 containers! Find a way to stop adding more containers when we reach the 112 containers and ship the shipment right away! You may want to apply what you have learned today.

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?