DEV Community

Discussion on: Debug Challenge Week 1

Collapse
 
coolshaurya profile image
Shaurya

According to me the code should be -

<script type="text/javascript">
  function displaymessage() {
    let socks = 3
    alert(`You have this many socks, plus 6: ${socks +6}`))
  }
 </script>
 <input type="button" value="Click me!" onclick="displaymessage()" >

Also consider replacing onclick with addEventListener

Collapse
 
micahlt profile image
Micah Lindley • Edited

Nice answer, and great job using the variable inside the string! However, you do have an extra parenthesis on line 4. :D

Collapse
 
mateiadrielrafael profile image
Matei Adriel • Edited

Socks should be a const:)

  • u have an extra )