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
€88.11
List Price:  €123.36
You save:  €35.24
£74.28
List Price:  £104
You save:  £29.71
CA$137.39
List Price:  CA$192.35
You save:  CA$54.96
A$155.46
List Price:  A$217.65
You save:  A$62.19
S$129.10
List Price:  S$180.74
You save:  S$51.64
HK$784.02
List Price:  HK$1,097.66
You save:  HK$313.64
CHF 82.19
List Price:  CHF 115.07
You save:  CHF 32.88
NOK kr1,021.69
List Price:  NOK kr1,430.41
You save:  NOK kr408.72
DKK kr657.31
List Price:  DKK kr920.26
You save:  DKK kr262.95
NZ$167.68
List Price:  NZ$234.76
You save:  NZ$67.08
د.إ367.26
List Price:  د.إ514.17
You save:  د.إ146.91
৳12,211.42
List Price:  ৳17,096.48
You save:  ৳4,885.06
₹8,556
List Price:  ₹11,978.75
You save:  ₹3,422.74
RM425.60
List Price:  RM595.86
You save:  RM170.26
₦158,810.11
List Price:  ₦222,340.51
You save:  ₦63,530.40
₨28,173.45
List Price:  ₨39,443.96
You save:  ₨11,270.50
฿3,271.27
List Price:  ฿4,579.90
You save:  ฿1,308.63
₺3,919.18
List Price:  ₺5,487.02
You save:  ₺1,567.83
B$572.44
List Price:  B$801.44
You save:  B$229
R1,799.21
List Price:  R2,518.97
You save:  R719.75
Лв173.12
List Price:  Лв242.37
You save:  Лв69.25
₩138,285.30
List Price:  ₩193,604.95
You save:  ₩55,319.65
₪351.85
List Price:  ₪492.61
You save:  ₪140.75
₱5,576.44
List Price:  ₱7,807.24
You save:  ₱2,230.80
¥14,402.60
List Price:  ¥20,164.22
You save:  ¥5,761.62
MX$1,942.84
List Price:  MX$2,720.05
You save:  MX$777.21
QR364.62
List Price:  QR510.48
You save:  QR145.86
P1,342.26
List Price:  P1,879.23
You save:  P536.96
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£4,976.93
List Price:  E£6,967.91
You save:  E£1,990.97
ብር13,587.98
List Price:  ብር19,023.71
You save:  ብር5,435.73
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$94,336.56
List Price:  CLP$132,074.96
You save:  CLP$37,738.40
CN¥719.90
List Price:  CN¥1,007.90
You save:  CN¥287.99
RD$5,906.21
List Price:  RD$8,268.93
You save:  RD$2,362.72
DA13,217.09
List Price:  DA18,504.45
You save:  DA5,287.36
FJ$226.02
List Price:  FJ$316.44
You save:  FJ$90.41
Q768.23
List Price:  Q1,075.55
You save:  Q307.32
GY$20,908.75
List Price:  GY$29,273.08
You save:  GY$8,364.33
ISK kr12,723.72
List Price:  ISK kr17,813.72
You save:  ISK kr5,090
DH925.71
List Price:  DH1,296.03
You save:  DH370.32
L1,728.89
List Price:  L2,420.51
You save:  L691.62
ден5,420.80
List Price:  ден7,589.34
You save:  ден2,168.53
MOP$807.31
List Price:  MOP$1,130.26
You save:  MOP$322.95
N$1,785.87
List Price:  N$2,500.29
You save:  N$714.42
C$3,677.89
List Price:  C$5,149.20
You save:  C$1,471.30
रु13,686.64
List Price:  रु19,161.84
You save:  रु5,475.20
S/364.21
List Price:  S/509.90
You save:  S/145.69
K416.65
List Price:  K583.33
You save:  K166.67
SAR375.15
List Price:  SAR525.22
You save:  SAR150.07
ZK2,660.69
List Price:  ZK3,725.07
You save:  ZK1,064.38
L445.39
List Price:  L623.57
You save:  L178.17
Kč2,196.48
List Price:  Kč3,075.16
You save:  Kč878.68
Ft35,578.44
List Price:  Ft49,811.24
You save:  Ft14,232.80
SEK kr959.04
List Price:  SEK kr1,342.70
You save:  SEK kr383.65
ARS$118,350.26
List Price:  ARS$165,695.11
You save:  ARS$47,344.84
Bs690.49
List Price:  Bs966.71
You save:  Bs276.22
COP$411,376.19
List Price:  COP$575,943.13
You save:  COP$164,566.93
₡50,770.67
List Price:  ₡71,080.98
You save:  ₡20,310.30
L2,606.30
List Price:  L3,648.92
You save:  L1,042.62
₲799,282.75
List Price:  ₲1,119,027.83
You save:  ₲319,745.07
$U4,154.73
List Price:  $U5,816.79
You save:  $U1,662.06
zł374.57
List Price:  zł524.42
You save:  zł149.84
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.