Learn Form Validation by Building a Calorie Counter - Step 34

Tell us what’s happening:

I have tried every way to solve this. Need a tip. Tried “return result;” at the bottom after refactoring the code from the example. Then directly as: “return result = str.match(regex);” at the bottom.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

function isInvalidInput(str) {
  const regex = /\d+e\d+/i;
  const result = str.match(regex);
  return result;
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 34

do not create the result variable, return the output of the match method directly

1 Like

I’ve tried
function isInvalidInput(str) {
const regex = /\d+e\d+/i;
return result = str.match(regex);
}

Here is an example:

function returnsRandomNumber() {
  return Math.random();
}

Thank you. That makes much more sense now.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.