Skip to content

Instantly share code, notes, and snippets.

@ldco2016
Created October 1, 2018 21:13
Show Gist options
  • Save ldco2016/fe8a49536bb545755bcce7669be8b251 to your computer and use it in GitHub Desktop.
Save ldco2016/fe8a49536bb545755bcce7669be8b251 to your computer and use it in GitHub Desktop.
const and let
var statuses = [
{ code: 'OK', response: 'Request successful' },
{ code: 'FAILED', response: 'There was an error with your request' },
{ code: 'PENDING', response: 'Your reqeust is still pending' }
];
var message = '';
var currentCode = 'OK';
for (var i = 0; i < statuses.length; i++) {
if (statuses[i].code === currentCode) {
message = statuses[i].response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment