'How do I debug a userscript by printing its variable in the console?

I am trying to create a userscript for Firefox (to run in greasemonkey) and this following code doesn't work for a userscript

userscript.js

var myfruit = "apples"

Firefox Console

console.log(myfruit);

I get this error

Uncaught ReferenceError: myfruit is not defined

Using Ctrl + Shift + J to open the browser console doesn't work either.

I'm using Firefox 98



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source