Length of string

Report a typo

The below function calculates the length of a given string. But some of the code is missing from it or contains errors. Please rectify the problem so the length of both strings is calculated correctly. Do not call the function again.

Sample Input 1:

Sample Output 1:

38
40
Write a program in JavaScript
function calculateLength(data) {
let strLength = string.len();
console.log(strLength);
}

calculateLength("JS is used to create web applications.");
calculateLength("This is a string, calculate its length. ");
___

Create a free account to access the full topic