ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 28 - Certified JavaScript Developer I discussion

Report
Export

A developer creates a simple webpage with an input field. When a user enters text in the input field and clicks the button, the actual value of the field must be displayed in the console.

Here is the HTML file content:

<input type =" text" value="Hello" name ="input">

<button type ="button" >Display </button>

The developer wrote the javascript code below:

Const button = document.querySelector('button'); button.addEvenListener('click', () => ( Const input = document.querySelector('input'); console.log(input.getAttribute('value')); When the user clicks the button, the output is always "Hello".

What needs to be done make this code work as expected?

A.
Replace line 04 with console.log(input .value);
Answers
A.
Replace line 04 with console.log(input .value);
B.
Replace line 03 with const input = document.getElementByName('input');
Answers
B.
Replace line 03 with const input = document.getElementByName('input');
C.
Replace line 02 with button.addEventListener("onclick", function() {
Answers
C.
Replace line 02 with button.addEventListener("onclick", function() {
D.
Replace line 02 with button.addCallback("click", function() {
Answers
D.
Replace line 02 with button.addCallback("click", function() {
Suggested answer: A
asked 23/09/2024
Vilfride Lutumba
41 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first