I am learning Javascript. I wrote a JS to return a Json-type value.
var generateUrl = function(Name, Letter, rootUrl, V1) {
rootUrl = rootUrl || Letter;
return {
classname: 'mycss-' + Letter,
text: Name,
url: rootHref.replace(Rex, "$1" + rootUrl + "."),
onclick: {
fn: clickFn,
obj: V1
}
};
};
I want to add a if statement inside url:.
For example, if Name = google, url won't use this logic rootHref.replace(Rex, "$1" + rootUrl + "."), instead it will directly return an url.
I have searched for an answer quite a while but still have no luck. May someone tell me how to add a if statement logic in my code.
if (thing == "google") myObj.url = "google-specific URL";)