Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
The length
property returns the length of a string or and the count of an array.
let string1 = "Hello World";
let length1 = string1.length;
document.getElementById("demo1").innerHTML = `The length of the string1 is ${length1}.`;
let array1 = ["apple", "banana", "pineapple"];
let length2 = array1.length;
document.getElementById("demo2").innerHTML = `The length of the array1 is ${length2}.`;