Sift through Text with Regular Expressions

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

The test itself is checking what andCount is.

Don’t I have to call ‘andCount’ to make the ‘testString.match(regularExpression).length’ happen?

Yes. And andCount is 2. That’s why you are seeing 2 when you run the tests.

What I thought was that var ‘andCount = testString.match(regularExpression).length’ set ‘andCount’ equal to 2, but, ‘var andCount = testString.match(regularExpression).length’ doesn’t show the programmer that ‘andCount’ is equal to 2.
Therefore, it seems like I should add a ‘console.log(andCount)’ to make the program show me the result.

You can do that if you want to see it in the console. The test is checking the value of andCount, not reading the console, so your code will pass in either case.