Search code examples
javascripthtmlarraysformsvar

Error: 'comment' is assigned a value but never used - Javascript


var comment = [
{"name": "name", "date": "00-00-0000", "body": "comment here"}];

When trying to make a variable for my comments to add to my comments form on html i seem to get this ESLint error. I've been following a guide and this does the exact same thing but received no error.

I haven’t defined comment within my style or html, would this affect this at all?

Can anyone help out pls


Solution

  • This is an ESLint error. It doesn't have any impact on running code whatsoever, it just warns you that you have some code style issues in your code.

    What it means is that you never seem to use that particular comment assignment within that file so it assumes that it's safe to just remove it.

    Make sure you don't import that file anywhere else; from where you actually access that comment value. If you don't then just remove that assignment since it's unnecessary and ESLint will stop complaining.