We have a JavaScript function declaration as such:function itemIncludesTotal(item){    var includeItem = false;    if (item.lineItem.hasOwnProperty(details)      && item.lineItem.details.hasOwnProperty(total)      && item.lineItem.details[total]      && !item.lineItem.restricted    ){      includeItem = true;    }    return includeItem;  };Where the function's argument (item) would be:var item = {lineItem: {details: {total: $5.00}, restricted: true}};The function call and return values would be:itemIncludesTotal(item); => TRUE || FALSEOur team is in a discussion regarding its structure:Should it be left alone?Should it be refactored?How would you refactor this function?Why did you refactor the way you did?What if anything do you personally find pleasing about the function?What if anything do you personally find unpleasing about the function?Does this function match current industry practices?What industry practices, if any, does this function lack?
itemIncludesTotal()
javascript
I'd implement trivial things trivially if the data is as plain and simple as shown in the question.function includesTotal(item) {    return item.lineItem.details        && item.lineItem.details.total        && !item.lineItem.restricted ? true : false;}The last ? true : false is simply to make it obvious that the return value is boolean.For a generic function I'd check the path fully though:function includesTotal(item) {    return item        && item.lineItem        && item.lineItem.details        && item.lineItem.details.total        && !item.lineItem.restricted ? true : false;}