Need help with getElementByID in Project – JavaScript – SitePoint - Freelance Find

Breaking

Sunday, August 21, 2022

Need help with getElementByID in Project – JavaScript – SitePoint

Hi Everyone!

I’m new to Javascript and taking a course. I completed my assignment and hope it’s correct.
I would GREATLY appreciate you help! :slight_smile:

My assignment is the following:

  1. Create an if function that will display the result, with the following criteria:

a. If the user has completed their name in the prompt window, the paragraph with id “result” must display the message “Hello STUDENT! Your result is SCORE out of 10.”

i. Replace STUDENT with the name the user captured in the prompt window.

ii. Replace SCORE with the user’s score.

b. If the user has not completed their name in the prompt window, the paragraph with id “result” must display the message “Your result is SCORE out of 10.”

Replace SCORE with the user’s score.

Here is my Project Result.

I have an HTML file with the paragraph id attribute .
Therefore, I created one variable with outputx and another with outputy. One is for a student input and the other one is without a name.

From HTML File.

var response = prompt(“What is your name?”);
var outputx = document.getElementById(“result”);
var outputy = document.getElementById(“result”);

var score1 = 10;

var response = prompt(“What is your name?”);
if (response) {
outputx.innerHTML =
“Hello” + response + “!. You have is +score1+ out of 10.”;
}
if (response !=null) {
outputy.innerHTML =
“Your result is +score1+ out of 10.”;
}

Techyrack Website stock market day trading and youtube monetization and adsense Approval

Adsense Arbitrage website traffic Get Adsense Approval Google Adsense Earnings Traffic Arbitrage YouTube Monetization YouTube Monetization, Watchtime and Subscribers Ready Monetized Autoblog



from Web Development – My Blog https://www.techyrack.com/syndication/2022/08/21/need-help-with-getelementbyid-in-project-javascript-sitepoint/
via IFTTT

No comments:

Post a Comment