Build a Roman Numeral Converter Project - Build a Roman Numeral Converter

Tell us what’s happening:

it was showing like cannot read properties of null (reading ‘addEventListener’)

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html>
  <head>
    <meta charset ="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ROMAN NUMERAL CONVERTOR</title>
    <script src="script.js"></script>
  </head>
  <body>
    <h1> freeCodeCamp</h1>
    <h3> Enter a Number:</h3>
    <input type="number" id="number"></input><br>
    <br><button id="convert-btn">Convert</button>
   <div id="output"></div> 
</body>
</html>

/* file: styles.css */

/* file: script.js */
const button = document.getElementById('convert-btn');

const inputNumber = document.getElementById('number');


const outputElement = document.getElementById('output');

button.addEventListener('click',()=> {
  
})


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Build a Roman Numeral Converter Project - Build a Roman Numeral Converter

This error means here, that at the time JS code runs, there isn’t yet an element with id convert-btn.

move this as last thing before the closing </body> tag

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.