Showing my code in browser?

hie! im currently 43% in on Ivans JS course, its time to do proper exercises.

but I can’t get my JS code to show in my safari browser, and not the picture we put in our html document either.
using atom, saved project as a html file, the html code and heading is showing when I open it up in safari/chrome but not any of my JS code. Is it some more program I need to download or some adjustment I should do?

please help so I can start with my loop exersises.

best// J

Hey @JonBen, hope you are ok.

Please provide your code in the following way so we can help you understand how to solve your issue :face_with_monocle:

Carlos Z

<html>

<head>
  <title> Detta är en hemsida </title>
</head>

<body>
  <h1>this is the title</h1>

<script>

// boolean true/false (vad är true o false definiera med if

var shoiuldContinue = true;

  var textToDisplay = "hello!!";
//while loop är infinite
while (counter)
//en loop för hello upp till 100 ggr, bestämt slut
for (var counter = 0; counter<100; counter=counter+1;){
document.write("<h2>" + textToDisplay + "</h2>");

if (counter>500)
{shoiuldContinue >500 = false;
}


  </script>
  </body>
  </html>
1 Like
<html>

<head>
  <title> Detta är en hemsida </title>
</head>

<body>
  <h1>this is the title</h1>

<script>

  var textToDisplay = "hello!!";


for (var counter = 0; counter<100; counter=counter+1;){
document.write("<h2>" + textToDisplay + "</h2>");

}


  </script>
  </body>
  </html>

the script above is the newest, I tried to do a new html document to see if it was a problem with my first html doc

Hey @JonBen, hope you are well.

I think you just have a minor syntax issue in your for loop, and you just forgot to import jquery so you can use custom scripts like that one.

Here is your code but I just remove ; at the end of you loop arguments and I added jquery.

<html>

<head>
  <script type="text/javascript" src="assets/js/utils/jquery-3.4.1.js"></script>
  <title> Detta är en hemsida </title>
</head>

<body>
  <h1>this is the title</h1>

<script>

  var textToDisplay = "hello!!";


for (var counter = 0; counter<100; counter=counter+1){
document.write("<h2>" + textToDisplay + "</h2>");

}


  </script>
  </body>
  </html>

Carlos Z

magic! thank you Carlos, now I can keep going, great

1 Like