I'm new to programming. I'm trying to call a function in html, but it isn't working. What's the problem? Thanks in advance. (Don't ask about the whole integration thing).
My HTML code:
<!DOCTYPE html>
<html>
<head>
<script src="IntegrationCalculator.js"></script>
<script>
integrationCalculator(7);
</script>
</head>
<body>
<p id="tester">
Didn't work :(
</p>
</body>
My javascript code:
var integrationCalculator = function (variable1) {
if (variable1 = 7) {
document.getElementById("tester").innerHTML="WORKED";
}
};
if (variable1 = 7) {should beif (variable1 == 7) {. The first one does assignment, the second does comparison. Consider using a JavaScript validator to look for these sorts of bugs. jshint.com