Skip to content

Commit

Permalink
Replace var by const
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalTassel committed Oct 29, 2021
1 parent a3ac8ba commit 90d32f4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var pricingComponent = {
const pricingComponent = {
offers: {
'10K': 8,
'50K': 12,
Expand Down Expand Up @@ -30,14 +30,14 @@ var pricingComponent = {
},
onRangeChange: function () {
// Get range position
var position = Number(this.value);
const position = Number(this.value);
// Get offer name
var index = position - 1;
const index = position - 1;
pricingComponent.currentOffer = Object.keys(pricingComponent.offers)[index];
// Get offer price
var pricing = pricingComponent.offers[pricingComponent.currentOffer];
const pricing = pricingComponent.offers[pricingComponent.currentOffer];
// Store range background sizes
var backgroundPositions = [0, 25, 50, 75, 100];
const backgroundPositions = [0, 25, 50, 75, 100];
// Set range background size
this.style.backgroundSize = `${backgroundPositions[index]}% 100%`;
// Display offer name
Expand All @@ -58,9 +58,9 @@ var pricingComponent = {
},
displayOfferPrice: function () {
// Get current price
var price = this.offers[this.currentOffer];
const price = this.offers[this.currentOffer];
// Has discount ?
var discountAmount = this.discount ? ((this.discountPercent * price) / 100) : 0;
const discountAmount = this.discount ? ((this.discountPercent * price) / 100) : 0;
// Display price
this.offerPriceElement.innerText = `$${price - discountAmount}.00`;
}
Expand Down

0 comments on commit 90d32f4

Please sign in to comment.