Please guide me through this problem, where I am not what I am doing wrong

Steps 32

Spreadsheet software typically uses = at the beginning of a cell to indicate a calculation should be used, and spreadsheet functions should be evaluated.

Use the && operator to add a second condition to your if statement that also checks if the first character of value is =.

My solution

const update = event => {
  const element = event.target;
  const value = element.value.replace(/\s/g, "");
  console.log(typeof(value))
  if (!value.includes(element.id)  &&  value.startsWith('=')) {}
}

Problem

I don’t know what I am doing wrong here

You need startWith(). Make a simple condition:
First character of value equal to a equal string.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

Remove the console log you have added.

console.log(typeof(value))
1 Like

@lasjorg Still not working. Same error. Can you please tell me what else I am doing wrong.

@hasanzaib1389 it’s not working, I have also tried it with value.charAt(0) and value.startsWith(“=”), getting same error :thinking:

if (!value.includes(element.id) && value.startsWith('=')) {

  }

Suddenly, with same code it started working, and I’m not sure why. Could someone please explain the difference between my previous code and the current code? Thank you!

const update = event => {
  const element = event.target;
  const value = element.value.replace(/\s/g, "");
  console.log(typeof(value))
  if (!value.includes(element.id)  &&  value.startsWith('=')) {}
}

In the previous code, you had a console.log().

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