0

I am very new to coding, I started taking a programming class a month ago and we were recently assigned our first project. I am trying to get my javascript code into my index.html. So far I have this in my html page:

<script src="/project1/prices.js" type='Javascript/text></script>`   

My javascript page currently has this in it:

var price1Name = "Tickets for 18 and under";
var price2Name = "Tickets for 18 and over"; 
var price3Name = "T-shirt (all sizes)";
var price4Name = "Jackets (all sizes)"; 


var price1price = "$5.00";
var price2price = "$10.00";
var price3price = "$15.00";
var price4price = "$20.00";


document.write(price1Name);
document.write(price1price);
document.write(price2Name);
document.write(price2price);
document.write(price3Name);
document.write(price3price);
document.write(price4Name);
document.write(price4price);

All I am trying to do is input this code into my Html page so that I am able to display the items and their prices. I can't seem to figure out what I am doing wrong. Thanks for your time, anything helps!

3

2 Answers 2

2

Looks like your script tag has a couple errors

<script src="/project1/prices.js" type="text/javascript"></script> 
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks! Changed that however nothing is still popping up on my HTML.
@kl next thing I'd do is verify the directory location on the js file (make sure it's actually being loaded)
Just did, it's in the same folder as my html
@kl in that case your src can just be "prices.js"
@snapjs changed that sa well, still not getting any text in my html
|
0
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
</head>
<body>
<script>
//code
</script>
</body>
</html>

You can paste your JavaScript code between the script tags in the body. This will allow you to insert JavaScript code into your HTML page.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.