Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

JS Arithmetic Operators

0 votes
26 views
added Jul 12 in Javascript by LC Marshal Lieutenant (14,830 points)
edited Jul 13 by LC Marshal
+	Addition
-	Subtraction
*	Multiplication
/	Division
%	Modulus (Division Remainder)
++	Increment
--	Decrement


//e.g 1
console.log('Year 5 gross/loan = ' + (Math.round((l5 - case200) + case200)).toLocaleString() + s + '-' + (Math.round(annual * y5)).toLocaleString()); 

//e.g 2
console.log('%cRM50K Loan | ' + y5 + ' years at RM1,099/mth' + ' | dividend= ' + x + '%' + ' | Interest rate= ' + kuwaitRate + '%', 'color: blue');

//e.g 3
console.log('Year 20 gross/loan = ' + (Math.round(kf20)).toLocaleString() + s + loan10);

3 Responses

0 votes
responded Jul 13 by LC Marshal Lieutenant (14,830 points)

Exponentiation (**)

let case200 = 200000, // loan amount
     x = 1.07, //7% dividend
     y5 = 5, y10 = 10, y15 = 15, y20 = 20, y25 = 25; //years

function dividendFunc5(value, years = y5) { //dividend function
  if(years > 0)
    return dividendFunc5(value*x, years - 1);
  else
  return value;
}

let case200k5y = dividendFunc5(case200), //5 years
    case200k10y = case200k5y * x ** y5; // 10 years - amount of 5years * 7% dividend = total * total * total * total * total 
    console.log('200k in 10 years ' + case200k10y); // output 200k in 10 years 393430.2714579133

 

0 votes
responded Jul 26 by LC Marshal Lieutenant (14,830 points)
// get 2% of total amount
let purchaseCost = 58000;

console.log(formatPrice((2 / 100) * this.purchaseCost));//output 1160
0 votes
responded Jul 26 by LC Marshal Lieutenant (14,830 points)
// Get total number plus dividend amount . example 7%

let investment = 2000, // investment amount
    dividend = 1.07; //7% dividend

console.log(investment * dividend); //output 2140

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...