Someone help a newbie out

function showcurrency() {
	var Currencybycountry = new	Array();
	Currencybycountry(US) = 100;
	Currencybycountry(Europe) = 88.85;
	Currencybycountry(GreatBritian) = 79.95;
	Currencybycountry(India) = 6840;
	Currencybycountry(Australia) = 143.61;
	Currencybycountry(Canada) = 130.73;
	for (var i = 0; i < Currencybycountry.length; i++) {
		var thecurrency = Currencybycountry[i] ;
		var id="Currency" + i;
		var li = document.getElementbyld(id) ;
		if (i == 0) {
			li.innerHTML = "The Currency in the US was " + theCurrency;
		} else {
			li.innerHTML = "The Currency at " + i + " was " + theCurrency;
		}
	}
}
window.onload = showcurrency;



<h1>Currency</h1>

	<li id="CurrencyUS"></li>
	<li id="CurrencyEurope"></li>
	<li id="CurrencyGreatBritian"></li>
	<li id="CurrencyIndia"></li>
	<li id="CurrencyAustralia"></li>
	<li id="CurrencyCanada"></li>

Here is my problem, I am new to JavaScript and I need to create basically a bullet point list that uses the code to generate the currency. Meaning I need it to pop up with the title and then The currency in the US is 100. Currently all I can get it the title and bullet points to come up, it wont pull up the rest. Can someone please tell me what I am doing wrong?

Please format your JS code too using MarkDown syntax, like this:

```
function showcurrency() {
  var Currencybycountry = new Array();
  Currencybycountry(US) = 100;
  Currencybycountry(Europe) = 88.85;
  Currencybycountry(GreatBritian) = 79.95;
  Currencybycountry(India) = 6840;
  Currencybycountry(Australia) = 143.61;
  Currencybycountry(Canada) = 130.73;
  for (var i = 0; i < Currencybycountry.length; i++) {
    var thecurrency = Currencybycountry[i] ;
    var id = “Currency” + i;
    var li = document.getElementbyld(id) ;
    if (i == 0) {
      li.innerHTML = "The Currency in the US was " + theCurrency;
    } else {
      li.innerHTML = "The Currency at " + i + " was " + theCurrency;
    }
  }
}
window.onload = showcurrency;
```

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 easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

The HTML goes in a seperate code block, right?

Hmmm…how are you trying to populate your array? Your syntax looks like it’s kinda close to the one used here: http://www.scriptingmaster.com/javascript/populating-array.asp

VSC is giving me a syntax error:

  1 |  var Currencybycountry = new Array(); 
> 2 | Currencybycountry(US) = 100; 
    | ^ SyntaxError: Assigning to rvalue (2:0) 
  3 | Currencybycountry(Europe) = 88.85; 
  4 | Currencybycountry(GreatBritian) = 79.95; 
  5 | Currencybycountry(India) = 6840;

image
I need it to look like this except with the currency

<!doctype html>
<html lang="en">
<head>
<title>Temperatures</title>
<meta charset="utf-8">
<script>
function showTemps() {
     var tempByHour = new ____________;
     tempByHour[0] = 59.2;
     tempByHour[1] = 60.1;
     tempByHour[2] = 63;
     tempByHour[3] = 65;
     tempByHour[4] = 62;
     for (var i = 0; i < ___________________; _____) {
          var theTemp = _____________[i];
          var id = "__________" + i;
          var li = document.__________________(id);
          if (i == ____) {
              li.______________ = "The temperature at noon was " + theTemp;
          } else {
              li.innerHTML = "The temperature at " + ______ + " was " + _________;
          }
     }
}
window.onload = showTemps;
</script>
</head>
<body>
<h1>Temperatures</h1>
<ul>
         <li id="temp0"></li>
         <li id="temp1"></li>
         <li id="temp2"></li>
         <li id="temp3"></li>
         <li id="temp4"></li>
</ul>
</body>

This is the example i was given to use but to fill in the blanks and change it from tempurature to currency

Yeah you’re definitely not populating your array then, which is probably why nothing is returning. I would say try to refactor your code to match the example and/or the syntax from the page I linked. For instance, you need to denote an index for each country [0], [1], [2] and so on.