Why does this program return 2 when nothing is returned? ‘testString.match(regularExpression).length’ is just assigned to a variable. Nothing is ever ‘returned’ to make it happen.
I don’t know if I am using the right wording, but, I hope someone understands.
Your code so far
// Setup
var testString = "Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.";
// Example
var expressionToGetSoftware = /software/gi;
var softwareCount = testString.match(expressionToGetSoftware).length;
// Only change code below this line.
var regularExpression = /and/gi; // Change this Line
// Only change code above this line
// This code counts the matches of expression in testString
var andCount = testString.match(regularExpression).length;
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/sift-through-text-with-regular-expressions