June 1, 2023
Program to use JavaScript String .length
let a = "Hello World in JavaScript";
let b = a.length;
console.log("String length =",b);
Output
String length = 25
Steps Description
- Declare two variable
a
andb
- Initialize two variable with value of string
a = "Hello World in JavaScript"
andb
- String
.length
Calculates the length of a string by counting its characters and output it as a number. - The value of
b
variable is displayed with the help of console.log inbuilt function
by : Suhel Akhtar
Quick Summary:
JavaScript String length example