Write the details of a function that prompts the user for a color and uses what the user typed to set the link color within the existing web page

Tell us what’s happening:
Describe your issue in detail here.

Write the details of a function that prompts the user for a color and uses what the user typed to set the link color within the existing web page
Your code so far


<h1>Hello</h1>
<h1>Hello world!</h1>

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; TECNO KC8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.88 Mobile Safari/537.36

Challenge: Say Hello to HTML Elements

Link to the challenge:

Hi @Ngbeken1monday !

I don’t understand what you need help with.
This doesn’t relate to the challenge you posted.

1.Write the details of a function that prompts the user for a color and uses what the user typed to set the link color within the existing web page.

function changeLinkColor (){var color = prompt (“Enter a color '','''');document.link = color;}

Monday:
Question-.Write a function that generates a complete web page containing a list with 50 items. The items should be item1 through item50

<script>function genList()  {    document.open();    document.write("<html><head></head><body>");    document.write("<ul>");    for (var i=1; i <= 50; i++)    {      document.write("<li> item" + i + "</li>");    }    document.write("</ul></body></html>");    document.close();  }</script>

Help me resolve and give correct answer

format:

<body ID="bdy"><p>Pick a background color for this page.</p><form name="form1">     <b> Color </b>     <input type="text" name="body"><br>     <input type="button" value="Change color onclick="changeBgColor()"><br></form></body>and then uses that color to set the background color of the web page.function changeBgColor()  {  }function changeBgColor(){var bodycolor = document.form1.body.value;document.getElementById("bdy").style.backgroundColor = bodycolor;}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

.Write and test run the details of a function that prompts the user for a color and uses what the user typed to set the link color within the existing web page.

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://www.freecodecamp.org/learn.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

It looks like you are asking for help with three different challenges

One for how to change the link color.
One for how to create a list of 50 items.
One for how to change the background color.

I think it would be best to just focus on one of these.

Maybe just pick the first one you asked about.


A couple of things I see with the code here.

No.1:
It would be easier to read if you were to format it.

function changeLinkColor() {
    var color = prompt(“Enter a color '', '''');
    document.link = color;
}

No.2:
You should be getting an error message here

No.3:
I think you meant document.links here.

You could also use something like querySelector

No.4:
It doesn’t look like you are calling the function anywhere.

Test Input function changeLinkColor (){var color = prompt (“Enter a color '','''');document.link = color;} function display(){alert (document.exam.first.value + " " +document.exam.last.value);} function genList() { document.open(); document.write(""); document.write("
    "); for (var i=1; i <= 50; i++) { document.write("
  • item" + i + "
  • "); } document.write("
"); document.close(); } < /SCRIPT>

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