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.
Introduction to String
Length of string
Report a typo
Sample Input 1:
Sample Output 1:
38
40Write 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. ");
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.