This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Lincoln
almost 9 years

[resolved] Why won't my js code work on anything exept codecademy??(Windows 7)

This is my code:

 var red = [0, 100, 44
];
var orange = [0, 100];
var green = [0, 101];
var blue = [0, 102];
var purple = [0, 103];

var myName = "Lincoln";
letterColors = [blue, red, green];



drawName(myName, letterColors);
bounceBubbles(myName);
if(10 > 3)

    bubbleShape = "square"; 

I cant seem to be able to get my code to work on anything exept Codecademy. I was trying to use Notepad to paste the code onto and to save it as a js file, and I was trying to use Microsoft Windows Script Based Host to run the code. But continually got tons of syntax, Object Unidentified errors and so on. My code works with Codecademy But not with anything else.

Answer 5586f39576b8fe27ba000609

2 votes

Permalink

You need all the files saved onto your computer in order to run the examples ‘offline’.

Files needed:

  • index.html
  • style.css
  • app.js (the one you make)
  • jquery.min.js (the jQuery library)
points
Submitted by K43
almost 9 years

5 comments

Lincoln almost 9 years

How do you get them to be linked together instead of four individual files that have nothing to do with each other.

Lincoln almost 9 years

I mean, how do you connect them??

K43 almost 9 years

I had to add as a new comment.

K43 almost 9 years

Also it might be worth you trying Notepadd++, it’s free. https://notepad-plus-plus.org/

Lincoln almost 9 years

Ok

Answer 5588b211937676de460001f6

2 votes

Permalink

Save them all in the same folder and then edit the .html file so the 3 files (.css and both .js) are linked in-between the < head > and < /head > tags. Because they aren’t in separate folders you can just link the file names i.e. < DOCTYPE HTML > < head > < link rel=”stylesheet” type=”text/css” href=”**style.css**” > < script type=”text/javascript” src=”**jquery.min.js**”>< /script > < script type=”text/javascript” src=”**app.js**” >< /script > < /head >

You create index.html, style.css and app.js but will need to download jQuery (jquery.min.js) if you haven’t already done so. Remember to make sure to change the name of the file you link to this.

points
Submitted by K43
almost 9 years

Answer 5589ecfc9376766e5500024b

0 votes

Permalink

Thanks!!

points
Submitted by Lincoln
almost 9 years

1 comments

K43 almost 9 years

No problem ☺