Update the “i” in lowercase on the all the iPhone models.
view file
_.extend(HeaderMenuView.prototype, {
getContext: _.wrap(HeaderMenuView.prototype.getContext, function wrappedInitialize(fn, options) {
var getContextRet = fn.apply(this, _.toArray(arguments).slice(1));
var categ = Configuration.navigationData || [];
_.map(categ, function (value) {
value.isbrands = false;
if(value.href == "/brands") {
_.map(value.categories, function (valuein) {
if (valuein.href == "/brands/iphone") {
_.map(valuein, function (valueeach, key) {
if (key == "categories") {
_.map(valueeach, function (valueeachin) {
try {
var text = valueeachin.text.trim().toLowerCase();
var text1 = text.substring(0, 6)
if (text1 == "iphone") {
text1 = "iPhone"
var text2 = self.titleCase((text.substring(6, (text.length))).trim())
console.log("text", text2)
var finalText = text1 + ' ' + text2;
valueeachin.text = finalText
console.log('iphonecheck', text1)
valueeachin.iphone = true;
}
} catch (err) {
console.log("value.href", err)
}
return valuein;
});
}
return valueeach
})
}
return valuein;
});
}
return value;
});
getContextRet.categories = categ;
return getContextRet;
})
});
}
},
titleCase: function titleCase(str) {
var splitStr = str.toLowerCase().split(' ');
for (var i = 0; i < splitStr.length; i++) {
// You do not need to check if i is larger than splitStr length, as your for does that for you
// Assign it back to the array
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
}
// Directly return the joined string
return splitStr.join(' ');
},