Currently, I am in the process of learning Javascript. My latest project involves writing a JS script 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
}
};
};
My current challenge is adding an if statement
inside the url:
section of my code. Specifically, I want the url
logic to behave differently if the Name = google
. In this case, I don't want to use the existing
rootHref.replace(Rex, "$1" + rootUrl + ".")
logic but rather directly return a different url
.
I've been searching for a solution for some time now without success. Can someone please guide me on how to incorporate an if statement
logic into my code?