Introduction

In this lesson we will look at:

  • the length property and trim() method.
  • the addEventListener function.
  • the onkeyup event.

length and trim()

We can use the length property to count the number of characters in a string.

The trim() method is used to remove the spaces at the beginning and end of strings.

Scrimba video

addEventListener

The Scrimba below explains how to use the addEventListener method to add event listeners to elements.

Scrimba video

onkeyup event

The following explores the onkeyup event by building a character counter for a message input.

Code from the video.


Lesson Task

Brief

There are practice questions in the master branch of this repo.

Attempt to answer the questions before checking them against the answers in the answers branch of the repo.

Tags: