Post as many JavaScript errors as you can by breaking the provided code. Try to come up with explanation of the error you get. Prizes for the weirdest error.
Last active
May 24, 2017 14:29
-
-
Save airportyh/ad6abdadd2a480095e17af8ba26f6214 to your computer and use it in GitHub Desktop.
JavaScript Errors
Uncaught TypeError: Assignment to constant variable. haiku.js:9
at haiku.js:9
var haiku = [
'the wind of Fuji',
'I\'ve brought on my fan',
'a gift from Edo'
];
var resultLines = [];
for (const i = 0; i < haiku.length; i++) {
var line = haiku[i];
var words = line.split(' ');
var resultWords = [];
for (var j = 0; j < words.length; j++) {
var word = words[j];
var reversed = word.split('').reverse().join('');
resultWords.push(reversed);
}
resultLines.push(resultWords.join(' '));
}
console.log(resultLines.join('\n'));Updated var i = 0 to const i = 0
Temperature: 66.4°F
Hi: 68°F
Lo: 64.4°F
undefined //description
no error message in the console...
var APPID = 'd572e3897b56c1638fada0388125c161';
$(document).ready(function() {
$('#button').click(function() {
$.ajax({
method: 'GET',
url: 'http://api.openweathermap.org/data/2.5/weather',
data: {
q: $('#q').val(),
units: 'imperial',
APPID: APPID
},
success: function(data) {
$('#display').html(
// '<h2>Forecast for ' + data.name + ':</h2>' +
'Temperature: ' + data.main.temp + '°F<br>' +
'Hi: ' + data.main.temp_max + '°F<br>' +
'Lo: ' + data.main.temp_min + '°F<br>' +
data.weather.description + '<br>' + // error in line 19
'<img src="http://openweathermap.org/img/w/' + data.weather[0].icon + '.png">'
);
}
})
});
});
Here's the error:
Uncaught SyntaxError: Unexpected identifier weather.js:10
var APPID = 'd572e3897b56c1638fada0388125c161';
$(document).ready(function() {
$('#button').click(function() {
$.ajax({
method: 'GET',
url: 'http://api.openweathermap.org/data/2.5/weather',
data: {
q: $('#q').val(),
units: 'imperial'
APPID: APPID
},
success: function(data) {
$('#display').html(
// '<h2>Forecast for ' + data.name + ':</h2>' +
'Temperature: ' + data.main.temp + '°F<br>' +
'Hi: ' + data.main.temp_max + '°F<br>' +
'Lo: ' + data.main.temp_min + '°F<br>' +
data.weather.description + '<br>' +
'<img src="http://openweathermap.org/img/w/' + data.weather[0].icon + '.png">'
);
}
})
});
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uncaught TypeError: resultWords.push is not a function haiku.js:16
at haiku.js:16
Replaced var resultWords = [] with var resultWords = {}