Can I use the propertie .lenght to count numbers in a string? ( console.log(’ 3+4’ . lenght);
You can, but you are probably running into an error because of the spelling.
length is the correct one
thank very much, details are very important in coding.
Welcome to the forums!
.length is a property that will tell you how many characters there are in a string, not only how many numbers there are.
console.log("3 + 4".length); // prints 5
In the above example, 5 is printed because there are five characters in the string:
+, another space, and
Let’s say you wanted to count the number of occurrences of numerical digits in a string. How could you go about doing that?