Skip to content
AITermsLab
–points–day streak

What is a bug in code?

A bug is a mistake in code that makes a program do the wrong thing, like a button that does nothing. Fixing one is called debugging.

Last updated

In real life

Like a typo in a recipe: write "1 cup of salt" instead of "1 teaspoon", and the cake comes out wrong even though everything else is right.

Try it yourself

The demo has a bakery page with a yellow button. Switch on a one-letter typo, "backgroud" instead of "background", and the button loses its colour with no error message. Switch it off and the colour comes back.

Change a line

This lesson
Line 3: the button's colour

index.html (the code)

1<h1>Rosa's Bakery</h1>2<p>Fresh bread every morning</p>3<button style="background: yellow">Order now</button>

The preview (what visitors see)

Rosa's Bakery

Fresh bread every morning

Order now

Switch on the typo and watch the button. One missing letter breaks the colour, and nothing warns you. Finding that letter is debugging.

Bug vs error message

An error message is the computer telling you something went wrong. A bug can be silent: the code runs, but does the wrong thing, like the colour that vanished in the demo.

Common questions

Why is it called a bug?

Engineers called faults bugs long before computers. A famous 1947 logbook entry records a real moth stuck in a computer, taped in as the "first actual case of bug being found".

How do people find bugs?

By testing: trying the thing and checking it does what it should. Then they narrow down where it goes wrong, often by changing one thing at a time.

Where you will use this

Quick check: Bug

Question 1 of 3

What is a bug?

What is a bug?