简体   繁体   中英

Javascript Alert box not displaying

Ok so I still pretty new to programming but I can not wrap my head around why this code on jsbin doesn't work. I would think an alert box should pop up with with first value of the array which is the string "red" but nothing happens. I don't understand what the warnings are telling me either. I am sure its something simple but I just can't get it.

Live demo: http://jsfiddle.net/XZbnr/

Code:

var colors = [“red”, “blue”, “green”]; 
alert(colors[0]);

Looks like you have some special characters in there:

var colors = [“red”, “blue”, “green”]; 

Those quotes appear to be pasted from Microsoft Word, or similar.

Replace them with " and it will work:

var colors = ["red", "blue", "green"]; 
alert(colors[0]);

http://jsfiddle.net/XZbnr/1/

用普通引号替换“:”或“

Looks like you're using the wrong kind of quotation marks. Try just using " or '

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM