User Input in JS
JavaScript can accept user input through browser prompts or HTML form elements.
Prompt Input
window.prompt() is quick for small practice examples, but it is not used much in real interfaces.
let username = window.prompt("What is your username?")
console.log(username)HTML Input
For real UI, read input from an HTML element.
<label for="username">Username:</label>
<input id="username" />
<button id="submit">Submit</button>
<script>
document.getElementById("submit").onclick = function () {
const username = document.getElementById("username").value
console.log(username)
}
</script>