Understanding DRY Code

Modern JavaScript Using Control Structures
1 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€90.04
List Price:  €126.06
You save:  €36.02
£75.71
List Price:  £106
You save:  £30.29
CA$139.83
List Price:  CA$195.77
You save:  CA$55.94
A$155.90
List Price:  A$218.27
You save:  A$62.36
S$130.49
List Price:  S$182.69
You save:  S$52.20
HK$779.30
List Price:  HK$1,091.05
You save:  HK$311.75
CHF 84.20
List Price:  CHF 117.88
You save:  CHF 33.68
NOK kr1,042.39
List Price:  NOK kr1,459.39
You save:  NOK kr416.99
DKK kr671.77
List Price:  DKK kr940.51
You save:  DKK kr268.73
NZ$169.59
List Price:  NZ$237.43
You save:  NZ$67.84
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,125.34
List Price:  ৳16,975.97
You save:  ৳4,850.62
₹8,531.13
List Price:  ₹11,943.92
You save:  ₹3,412.79
RM433.80
List Price:  RM607.34
You save:  RM173.54
₦160,159.98
List Price:  ₦224,230.38
You save:  ₦64,070.40
₨28,094.32
List Price:  ₨39,333.17
You save:  ₨11,238.85
฿3,322.46
List Price:  ฿4,651.58
You save:  ฿1,329.12
₺3,878.43
List Price:  ₺5,429.96
You save:  ₺1,551.52
B$568.79
List Price:  B$796.33
You save:  B$227.54
R1,831.17
List Price:  R2,563.71
You save:  R732.54
Лв176.02
List Price:  Лв246.44
You save:  Лв70.41
₩142,334.04
List Price:  ₩199,273.35
You save:  ₩56,939.31
₪357.47
List Price:  ₪500.48
You save:  ₪143
₱5,572.44
List Price:  ₱7,801.64
You save:  ₱2,229.19
¥14,807.31
List Price:  ¥20,730.83
You save:  ¥5,923.52
MX$1,957.70
List Price:  MX$2,740.85
You save:  MX$783.15
QR364.15
List Price:  QR509.83
You save:  QR145.67
P1,362.44
List Price:  P1,907.48
You save:  P545.03
KSh12,926.07
List Price:  KSh18,097.01
You save:  KSh5,170.94
E£5,040.22
List Price:  E£7,056.51
You save:  E£2,016.29
ብር13,354.24
List Price:  ብር18,696.47
You save:  ብር5,342.23
Kz91,640.83
List Price:  Kz128,300.83
You save:  Kz36,660
CLP$94,479.86
List Price:  CLP$132,275.58
You save:  CLP$37,795.72
CN¥720.25
List Price:  CN¥1,008.38
You save:  CN¥288.13
RD$5,876.36
List Price:  RD$8,227.14
You save:  RD$2,350.78
DA13,376.37
List Price:  DA18,727.45
You save:  DA5,351.08
FJ$230.45
List Price:  FJ$322.64
You save:  FJ$92.19
Q767.60
List Price:  Q1,074.68
You save:  Q307.07
GY$20,881.03
List Price:  GY$29,234.28
You save:  GY$8,353.24
ISK kr13,210.67
List Price:  ISK kr18,495.47
You save:  ISK kr5,284.80
DH933.50
List Price:  DH1,306.94
You save:  DH373.43
L1,723.16
List Price:  L2,412.50
You save:  L689.33
ден5,537.79
List Price:  ден7,753.13
You save:  ден2,215.34
MOP$801.04
List Price:  MOP$1,121.49
You save:  MOP$320.44
N$1,829.41
List Price:  N$2,561.24
You save:  N$731.83
C$3,673.85
List Price:  C$5,143.54
You save:  C$1,469.69
रु13,564.30
List Price:  रु18,990.57
You save:  रु5,426.26
S/364.56
List Price:  S/510.40
You save:  S/145.84
K410.63
List Price:  K574.90
You save:  K164.26
SAR375.04
List Price:  SAR525.07
You save:  SAR150.03
ZK2,627.71
List Price:  ZK3,678.89
You save:  ZK1,051.18
L459.67
List Price:  L643.56
You save:  L183.88
Kč2,246.07
List Price:  Kč3,144.60
You save:  Kč898.52
Ft36,458.20
List Price:  Ft51,042.94
You save:  Ft14,584.74
SEK kr974.35
List Price:  SEK kr1,364.13
You save:  SEK kr389.77
ARS$113,039.21
List Price:  ARS$158,259.42
You save:  ARS$45,220.20
Bs692.12
List Price:  Bs969
You save:  Bs276.87
COP$421,156.04
List Price:  COP$589,635.31
You save:  COP$168,479.26
₡50,685.88
List Price:  ₡70,962.27
You save:  ₡20,276.38
L2,584.74
List Price:  L3,618.74
You save:  L1,034
₲797,405.45
List Price:  ₲1,116,399.53
You save:  ₲318,994.08
$U4,177.30
List Price:  $U5,848.39
You save:  $U1,671.08
zł382.63
List Price:  zł535.70
You save:  zł153.06
Already have an account? Log In

Transcript

In this movie, I want to step aside for just a minute from JavaScript to talk about dry code. And how dry code applies to JavaScript. Dry code is a good thing is something you want to try to do when you're coding DRI stands for don't repeat yourself. So when we're talking about dry code, we want to write code where we're not repeating ourselves while loops. The control structure of loops is something that we have as a tool to help us write dry code. There are additional things in JavaScript that will allow us to do that, for example, functions, but we've just encountered loops and so I wanted to bring up this concept.

So if you are writing a program and you find that you're repeating yourself, well stop for a minute. Maybe there's a better way to do that. Maybe there isn't. Maybe it needs to be like Like it is. And JavaScript is flexible. You can accomplish things in multiple different ways.

But it's good to stop and think about what you're doing. Because there may be a better way to do that. You may be able to use a loop or use some other sort of control structure so that your code becomes much more maintainable. This is part of becoming a modern JavaScript developer is making sure that you ask ask those questions. So keep the concept of dry in your mind as you work on your projects. Alright, let's now do some exercises for loops.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.