It’s that time, guys! The Debug Challenge has begun! Keep in mind, mildly skilled devs can probably skip this as this weeks’s challenge is oriented toward beginners. Here we go!
What’s wrong with this code?
Not just what’s broken; also what’s depreciated or just impolite syntax. The language for this week is JavaScript.
<script type="text/javascript">
function displaymessage {
var socks = "3"
alert(join("You have this many socks, plus 6: " + socks + 6))
}
</script>
<input type="button" value="Click me!" onclick="displaymessage" >
Please answer in the comments!
Top comments (6)
According to me the code should be -
Also consider replacing
onclick
withaddEventListener
Socks should be a const:)
Nice answer, and great job using the variable inside the string! However, you do have an extra parenthesis on line 4. :D
displaymessage should have bracket () at the end on line 2.
join function is undefined, replace line 4 with
The on click event should also be
onclick="displaymessage()"
instead ofonclick="displaymessage"
You could also set the onclick prop of the element in js to that function!