I tried creating a simple JavaScript file based on my adaption of source code from MDN.
My JavaScript code (loughshore_clubs.js) is as follows
<!--
var Club = “Ballinderry” ;
function ClubType(name){
if (name == “Ardboe”){
return name ;
} else{
return “I'm not from “+ name + “.”;
}
}
var clubs {myClub: ClubType(“Ardboe”), club2: ClubType(Club),
club3:
ClubType(“Moortown”)}
console.log(clubs.myClub); //Ardboe
console.log(clubs.club2); //Ballinderry
console.log(clubs.club3); //Moortown
/-->
And the HTML source (test.html) is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
<title></title>
<meta name="generator" content="LibreOffice 4.2.4.2 (Linux)">
<meta name="created" content="20150514;0">
<meta name="changed" content="20150514;211357234273120">
<style type="text/css">
<!--
@page { margin: 2cm }
p { margin-bottom: 0.25cm; color: #000000; line-height:
120% }
a:link { so-language: en-US }
-->
</style>
</head>
<body>
<script src="scripts/loughshore_clubs.js" />
</body>
</html>
What's the matter? One thing I do realise is that I should avoid saving HTML files using LibreOffice and stick with Bluefish. (which I have on Mac o/s X Yosemite)
Remove the first and last lines of your script. HTML comment tags make no sense in a
.js
file.Then replace each of your
”
characters with a proper"
.You're also missing an
=
betweenclubs
and{
here:var clubs {myClub:...
After these changes you should have: