Ben Hemmings Ben Hemmings - 1 month ago 7
Javascript Question

I am being given a syntax error with no obvious reason in dreamweaver

<script>
function changeLight(){
lightOne
lightTwo
lightThree
}
function lightOne(){

}
var list1=[
"../../../Pictures/lights/red.png"
"../../../Pictures/lights/red.png"
"../../../Pictures/lights/red.png"
"../../../Pictures/lights/red.png"
"../../../Pictures/lights/lit red.png"
]
var list2=[
"../../../Pictures/lights/orange.png"
"../../../Pictures/lights/lit orange.png"
"../../../Pictures/lights/orange.png"
"../../../Pictures/lights/lit orange.png"
"../../../Pictures/lights/lit orange.png"
]
var list3=[
"../../../Pictures/lights/green.png"
"../../../Pictures/lights/green.png"
"../../../Pictures/lights/lit green.png"
"../../../Pictures/lights/green.png"
"../../../Pictures/lights/green.png"
]
</script>


This is a screenshot of the error message and code in dreamweaver

.

I dont see any reason for there to be an error on this line since it is not finding an error on the line above.

I am a begginer in javascript so this code is messy.

Answer

This should be:

<script>
function changeLight(){
    lightOne();
    // lightTwo();
    // lightThree();
}
function lightOne(){

}
var list1=[
    "../../../Pictures/lights/red.png",
    "../../../Pictures/lights/red.png",
    "../../../Pictures/lights/red.png",
    "../../../Pictures/lights/red.png",
    "../../../Pictures/lights/lit red.png"
    ];
var list2=[
    "../../../Pictures/lights/orange.png",
    "../../../Pictures/lights/lit orange.png",
    "../../../Pictures/lights/orange.png",
    "../../../Pictures/lights/lit orange.png",
    "../../../Pictures/lights/lit orange.png"
];
var list3=[
    "../../../Pictures/lights/green.png",
    "../../../Pictures/lights/green.png",
    "../../../Pictures/lights/lit green.png",
    "../../../Pictures/lights/green.png",
    "../../../Pictures/lights/green.png"
];
</script>