I'm a total newbie to coding and currently working on a calculator for a school project. I'm stuck because the display function keeps giving me the error "display is not defined," even though I've set it up in my code. Here's a snippet of my HTML structure: I have an input box for the output and buttons to input numbers and operations. I've also included a JavaScript script where I define the display function, but it seems something's off. I'm using this script for the display: `function display('1') { print(value) }`. Can anyone help me figure out what's wrong?
1 Answer
You're definitely heading in the right direction! First off, it looks like you've mixed up how to use the script tag. If your JavaScript is in a separate file, you should use it like this: ``. But if you want to write the code directly in the script tag, just leave out the `src` attribute, like so: ` ...your code... `. Also, for the `display` function, it should take a variable as a parameter, not a string like you've got now. Change it to `function display(value) { print(value) }`. Just a heads up, `print()` might not work the way you think it does, but you’ll get it sorted out!
Thanks for the tip! But that didn’t really solve my issue... 🙁