Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  108] [ 6]  / answers: 1 / hits: 5855  / 3 Years ago, thu, april 22, 2021, 12:00:00

I am trying to make sense of this line of code:


const loanPeriod: number = get(product, 'TermMonths', this.defaultTerm) / this.monthsInAYear;

defaultTerm and monthsInAYear are global variables. product is an object and TermMonths is a number property of product. I don't know why the product & 'TermMonths' is needed. Can't you just divide the defaultTerm by monthsInAYear?


More From » typescript

 Answers
4

You can find the official documentation here, with an example. Using your case, the assumption is that product may or may not have a property called TermMonths. If it does, _.get will retrieve the value of that property. If it does not, the default, this.defaultTerm, is returned.


[#1446] Wednesday, April 14, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yosefleod

Total Points: 113
Total Questions: 100
Total Answers: 115

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;