document.log(): "undefined is not a function"

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?

3

2 Answers

You need to use:

console.log("yay");

instead of:

document.log("yay");

Fiddle Demo

Try console.log() and not document.log()

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like