How to get the Length of a String in JavaScript-Code Examples

Radu TM

How to get the Length of a String in JavaScript

JavaScript by Radu TM June 21, 2022

// Declare and assign a string variable
const string = "🍕🍔🍟";
// Get the length of the string
const length = string.length;
// Output the length to the console
console.log(length);

0

18.963

How to get the Length of a String in JavaScript

JavaScript by Radu TM June 21, 2022

let str = '💩💩💩';

// Get the length of the string
let len = str.length;

// Log the length of the string
console.log(len); // 3

0

18.963

Related JavaScript Queries

Latest JavaScript Queries

Explore code examples by categories