I know, I know, is a common error and you should look at others and blah blah blah. I have and I could not have found a solution.
This is my ENTIRE code.
<div></div>
<script>
function item(id, price, name, icon){ this.id = id; this.initPrice = 0; this.price = price; this.name = name; this.icon = icon; document.getElementById("div").innerHTML += this.name + " = $" + price + " <input id=\"itemNum" + this.id + "\" onchange=\"item" + this.id + ".calc()\" type=\"number\" style=\"width: 40px;\" value=\"1\"></input><br>"; this.calc = function(){ document.log("yay"); }
}
var item1 = new item(1, 700, "Barrel #1", "");
item1.calc();
</script>I get the error at line 14 and when I change the input I get the same error at line 14 again. What am I doing wrong? How can I fix this?
32 Answers
You need to use:
console.log("yay");instead of:
document.log("yay"); Try console.log() and not document.log()