Menu
Coddy logo textTech

function clearDisplay

Lesson 12 of 14 in Coddy's DOM Project - Calculator course.

challenge icon

Challenge

Easy
  1. Write a function clearDisplay() that clears all the text written in 'display'.
  2. For a button with the text ‘C’ set an attribute onclick with the function clearDisplay() so that it can work after each time we click on the button.
  3. Test it: Refresh the web, and after clicking on numbers, click on the button 'C' to see if it works!

Try it yourself

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="styles.css">
</head>
    <body>
        <!-- Write HTML code here -->
        <script src="script.js"></script>
    </body>
</html>

All lessons in DOM Project - Calculator