Tell us what’s happening:
Describe your issue in detail here.
can some one please tell me why my code does not pass the following test:
When you click on the #convert-btn
element without entering a value into the #number
element, the #output
element should contain the text Please enter a valid number
.
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Roman Numerical Convertor</title>
</head>
<body>
<input id="number">
<button id="convert-btn">Convert</button>
<div id="output">
</div>
<script src = 'script.js'></script>
</body>
</html>
/* file: styles.css */
/* file: script.js */
const convertBtn = document.getElementById('convert-btn');
const numInput = document.getElementById('number').value.trim();
const outputDiv = document.getByElementById('output');
convertBtn.addEventListener('click',()=>{
if(!numInput){
outputDiv.textContent = 'Please enter a valid number';
} else{
outputDiv.textContent = ''
}
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Challenge Information:
Build a Roman Numeral Converter Project - Build a Roman Numeral Converter