I have the following javascript enum:
// Rooms
var rooms = {
1: 'First Room',
2: 'Second Room',
3: 'Third Room',
};
I can easily get the room description as follows:
// Get Room Description
var roomOne = 1;
var roomdesc = rooms[roomOne];
How about if I have the room description 'First Room' and I want to get the room number?
I tried:
// Get room number
var roomIndex = rooms.indexOf('First Room');
var roomNum = rooms[roomIndex];
But indexOf is undefined. How can I get the room number by room description?
Thanks
PS: Forgot to mention. I cannot change the rooms object. It is being used in other areas already! Also, I would like to do this without using prototype or jquery. Thanks.