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
€86.14
List Price:  €120.60
You save:  €34.46
£75.77
List Price:  £106.09
You save:  £30.31
CA$140.05
List Price:  CA$196.08
You save:  CA$56.02
A$152.75
List Price:  A$213.86
You save:  A$61.10
S$129.79
List Price:  S$181.71
You save:  S$51.92
HK$778.59
List Price:  HK$1,090.06
You save:  HK$311.47
CHF 80.48
List Price:  CHF 112.68
You save:  CHF 32.19
NOK kr1,015.54
List Price:  NOK kr1,421.80
You save:  NOK kr406.25
DKK kr643.39
List Price:  DKK kr900.77
You save:  DKK kr257.38
NZ$175
List Price:  NZ$245.02
You save:  NZ$70.01
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,228.73
List Price:  ৳17,120.71
You save:  ৳4,891.98
₹8,994.18
List Price:  ₹12,592.21
You save:  ₹3,598.03
RM413.15
List Price:  RM578.43
You save:  RM165.28
₦144,745.52
List Price:  ₦202,649.52
You save:  ₦57,904
₨28,176.09
List Price:  ₨39,447.65
You save:  ₨11,271.56
฿3,203.67
List Price:  ฿4,485.27
You save:  ฿1,281.60
₺4,242.17
List Price:  ₺5,939.21
You save:  ₺1,697.03
B$537.12
List Price:  B$751.99
You save:  B$214.87
R1,712.97
List Price:  R2,398.23
You save:  R685.25
Лв168.52
List Price:  Лв235.93
You save:  Лв67.41
₩146,901.96
List Price:  ₩205,668.62
You save:  ₩58,766.66
₪325.43
List Price:  ₪455.62
You save:  ₪130.18
₱5,865.61
List Price:  ₱8,212.09
You save:  ₱2,346.47
¥15,602.16
List Price:  ¥21,843.65
You save:  ¥6,241.48
MX$1,831.60
List Price:  MX$2,564.31
You save:  MX$732.71
QR366.07
List Price:  QR512.51
You save:  QR146.44
P1,336.69
List Price:  P1,871.42
You save:  P534.72
KSh12,928.70
List Price:  KSh18,100.70
You save:  KSh5,172
E£4,753.35
List Price:  E£6,654.88
You save:  E£1,901.53
ብር15,640.38
List Price:  ብር21,897.16
You save:  ብር6,256.77
Kz91,234.01
List Price:  Kz127,731.27
You save:  Kz36,497.25
CLP$92,959.70
List Price:  CLP$130,147.30
You save:  CLP$37,187.60
CN¥706.90
List Price:  CN¥989.70
You save:  CN¥282.79
RD$6,257.36
List Price:  RD$8,760.56
You save:  RD$2,503.19
DA13,031.68
List Price:  DA18,244.87
You save:  DA5,213.19
FJ$227.30
List Price:  FJ$318.23
You save:  FJ$90.93
Q767.59
List Price:  Q1,074.66
You save:  Q307.06
GY$20,952.92
List Price:  GY$29,334.92
You save:  GY$8,382
ISK kr12,766.72
List Price:  ISK kr17,873.92
You save:  ISK kr5,107.20
DH926.11
List Price:  DH1,296.60
You save:  DH370.48
L1,699.08
List Price:  L2,378.78
You save:  L679.70
ден5,308.64
List Price:  ден7,432.31
You save:  ден2,123.66
MOP$803.45
List Price:  MOP$1,124.87
You save:  MOP$321.41
N$1,710.78
List Price:  N$2,395.16
You save:  N$684.38
C$3,685.51
List Price:  C$5,159.87
You save:  C$1,474.35
रु14,346.56
List Price:  रु20,085.75
You save:  रु5,739.19
S/336.70
List Price:  S/471.40
You save:  S/134.69
K430.39
List Price:  K602.56
You save:  K172.17
SAR375.34
List Price:  SAR525.50
You save:  SAR150.15
ZK2,295.99
List Price:  ZK3,214.48
You save:  ZK918.49
L438.46
List Price:  L613.87
You save:  L175.40
Kč2,081.70
List Price:  Kč2,914.46
You save:  Kč832.76
Ft32,846.48
List Price:  Ft45,986.39
You save:  Ft13,139.90
SEK kr945.94
List Price:  SEK kr1,324.36
You save:  SEK kr378.41
ARS$145,114.23
List Price:  ARS$203,165.73
You save:  ARS$58,051.50
Bs694.55
List Price:  Bs972.40
You save:  Bs277.84
COP$375,380.15
List Price:  COP$525,547.23
You save:  COP$150,167.07
₡49,318.20
List Price:  ₡69,047.45
You save:  ₡19,729.25
L2,637.25
List Price:  L3,692.26
You save:  L1,055
₲700,071.99
List Price:  ₲980,128.80
You save:  ₲280,056.80
$U3,927.20
List Price:  $U5,498.24
You save:  $U1,571.03
zł365.38
List Price:  zł511.55
You save:  zł146.16
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.