Skip to content

Instantly share code, notes, and snippets.

@kiliankoe
Created May 1, 2014 19:09
Show Gist options
  • Save kiliankoe/9dc5a1a00356eebab264 to your computer and use it in GitHub Desktop.
Save kiliankoe/9dc5a1a00356eebab264 to your computer and use it in GitHub Desktop.
Javascript Roadtrip 3 - 2.11
===== Mine =====
"Incorrect Submission
Check out your syntax for semicolon, parentheses, or bracket issues."
function warningMaker( obstacle ){
var count = 0;
var zones = [];
return function ( number, location ) {
count++;
zones.push(location);
var zonemessage = "";
for (var i = 0; i < zones.length; i++){
zonemessage = zonemessage + "\n" + zones[i];
}
alert("Beware! There have been " +
obstacle +
" sightings in the Cove today!\n" +
number +
" " +
obstacle +
"(s) spotted at the " +
location +
"!\n" +
"This is Alert #" +
count +
" today for " +
obstacle +
" danger.\nCurrent danger zones are:"+zonemessage
);
};
}
===== Yours =====
function warningMaker( obstacle ){
var count = 0;
var zones = [];
return function ( number, location ) {
count++;
zones.push(location);
var list = "";
for(var i = 0; i<zones.length; i++){
list = list + "\n" + zones[i];
}
alert("Beware! There have been " +
obstacle +
" sightings in the Cove today!\n" +
number +
" " +
obstacle +
"(s) spotted at the " +
location +
"!\n" +
"This is Alert #" +
count +
" today for " +
obstacle +
" danger.\n" +
"Current danger zones are:" +
list
);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment