I’ve got an array holding various notifications, which includes their individual title and description. I want to access a certain notification by its title, but I’m not seeming to be able to find a match in the array, even though there should be.
NotificationMenu = function()
{
var NotificationItems = new Array();
this.Application = function(title, description, functionName)
{
this.mTitle = title;
this.mDescription = description;
this.mFunction = functionName;
this.mIsActive = true;
}
this.registerNotification = function(title, description, functionName)
{
NotificationItems.push(new this.Application(title, description, functionName));
}
this.activateNotification = function(title)
{
console.log("-NotificationMenu: Activating notification " + title);
// Check through the list of notifications for the one called to be shown
for(var i = 0; i < NotificationItems.length; ++i)
{
if (NotificationItems[i].mName === title)
{
// This is never getting called
console.log("-NotificationMenu: Successful entry");
}
}
}
}
What is wrong with the way I’m accessing my array so that it cannot match two titles? In particular the line if(NotificationItems[i].mName === title) is not ever returning true.
There’s no
mNamedefined in theApplication()constructor. Perhaps you mean to usemTitle: