How can I get the integer equivalent of days of the week i.e monday
to 2
, tuesday
to 3
, wednesday
to 4
You could also use the "indexOf" function of javascript.
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
console.log(days.indexOf('Sunday')); // return 0
console.log(days.indexOf('Tuesday')); // return 2
But remember that "indexOf" is case sensitive and that it will return "-1", if the string is not in the array.