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
€96.45
List Price:  €135.04
You save:  €38.58
£80.67
List Price:  £112.95
You save:  £32.27
CA$145.41
List Price:  CA$203.58
You save:  CA$58.17
A$160.44
List Price:  A$224.63
You save:  A$64.18
S$135.70
List Price:  S$189.99
You save:  S$54.28
HK$779.01
List Price:  HK$1,090.65
You save:  HK$311.63
CHF 91.12
List Price:  CHF 127.58
You save:  CHF 36.45
NOK kr1,131.84
List Price:  NOK kr1,584.63
You save:  NOK kr452.78
DKK kr720.12
List Price:  DKK kr1,008.20
You save:  DKK kr288.08
NZ$177.42
List Price:  NZ$248.40
You save:  NZ$70.97
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,209.14
List Price:  ৳17,093.29
You save:  ৳4,884.14
₹8,668.26
List Price:  ₹12,135.92
You save:  ₹3,467.65
RM445.45
List Price:  RM623.65
You save:  RM178.20
₦154,534.54
List Price:  ₦216,354.54
You save:  ₦61,820
₨27,925.69
List Price:  ₨39,097.08
You save:  ₨11,171.39
฿3,369.60
List Price:  ฿4,717.57
You save:  ฿1,347.97
₺3,568.14
List Price:  ₺4,995.54
You save:  ₺1,427.39
B$584.14
List Price:  B$817.82
You save:  B$233.68
R1,866.88
List Price:  R2,613.71
You save:  R746.83
Лв188.70
List Price:  Лв264.19
You save:  Лв75.48
₩145,763.42
List Price:  ₩204,074.62
You save:  ₩58,311.20
₪358.60
List Price:  ₪502.05
You save:  ₪143.45
₱5,841.51
List Price:  ₱8,178.35
You save:  ₱2,336.84
¥15,517.94
List Price:  ¥21,725.74
You save:  ¥6,207.80
MX$2,068.05
List Price:  MX$2,895.35
You save:  MX$827.30
QR364.95
List Price:  QR510.94
You save:  QR145.99
P1,394.50
List Price:  P1,952.36
You save:  P557.85
KSh12,915.47
List Price:  KSh18,082.17
You save:  KSh5,166.70
E£5,022.22
List Price:  E£7,031.31
You save:  E£2,009.09
ብር12,824.92
List Price:  ብር17,955.40
You save:  ብር5,130.48
Kz91,190.88
List Price:  Kz127,670.88
You save:  Kz36,480
CLP$98,724.98
List Price:  CLP$138,218.93
You save:  CLP$39,493.94
CN¥718.60
List Price:  CN¥1,006.08
You save:  CN¥287.47
RD$6,185.14
List Price:  RD$8,659.45
You save:  RD$2,474.30
DA13,527.05
List Price:  DA18,938.41
You save:  DA5,411.36
FJ$232.27
List Price:  FJ$325.18
You save:  FJ$92.91
Q774.44
List Price:  Q1,084.25
You save:  Q309.80
GY$20,946.52
List Price:  GY$29,325.96
You save:  GY$8,379.44
ISK kr14,155.39
List Price:  ISK kr19,818.12
You save:  ISK kr5,662.72
DH1,004.97
List Price:  DH1,407
You save:  DH402.03
L1,852.87
List Price:  L2,594.10
You save:  L741.22
ден5,937.16
List Price:  ден8,312.26
You save:  ден2,375.10
MOP$803.67
List Price:  MOP$1,125.17
You save:  MOP$321.50
N$1,868.79
List Price:  N$2,616.38
You save:  N$747.59
C$3,684.07
List Price:  C$5,157.84
You save:  C$1,473.77
रु13,868.82
List Price:  रु19,416.90
You save:  रु5,548.08
S/372.45
List Price:  S/521.44
You save:  S/148.99
K407.67
List Price:  K570.76
You save:  K163.08
SAR375.05
List Price:  SAR525.09
You save:  SAR150.03
ZK2,800.87
List Price:  ZK3,921.34
You save:  ZK1,120.46
L480.09
List Price:  L672.14
You save:  L192.05
Kč2,431.78
List Price:  Kč3,404.59
You save:  Kč972.81
Ft39,450.77
List Price:  Ft55,232.66
You save:  Ft15,781.88
SEK kr1,109.56
List Price:  SEK kr1,553.44
You save:  SEK kr443.87
ARS$105,250.16
List Price:  ARS$147,354.43
You save:  ARS$42,104.27
Bs691.84
List Price:  Bs968.61
You save:  Bs276.76
COP$415,852.26
List Price:  COP$582,209.80
You save:  COP$166,357.54
₡50,503.94
List Price:  ₡70,707.54
You save:  ₡20,203.59
L2,550.48
List Price:  L3,570.77
You save:  L1,020.29
₲789,694.67
List Price:  ₲1,105,604.13
You save:  ₲315,909.46
$U4,333.83
List Price:  $U6,067.53
You save:  $U1,733.70
zł406.58
List Price:  zł569.24
You save:  zł162.65
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.