jQuery addClass example

Change class name on click in jQuery

by sanat gupta

JavaScript

$(function(){
	inputAnalysis();
});

// prompt user for input and return output
function inputAnalysis(list) {
  var input = prompt('Which city would you like to look up?');

  if (list.hasOwnProperty(input)) {
    console.log('The area code for ' + input + ' is: ' + list[input]) // <--- to avoid [object object] error.
  }
}