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
€85.21
List Price:  €119.30
You save:  €34.08
£73.75
List Price:  £103.26
You save:  £29.50
CA$138.34
List Price:  CA$193.69
You save:  CA$55.34
A$150.37
List Price:  A$210.53
You save:  A$60.15
S$128.25
List Price:  S$179.56
You save:  S$51.30
HK$778.15
List Price:  HK$1,089.44
You save:  HK$311.29
CHF 79.64
List Price:  CHF 111.51
You save:  CHF 31.86
NOK kr987.08
List Price:  NOK kr1,381.95
You save:  NOK kr394.87
DKK kr636.05
List Price:  DKK kr890.50
You save:  DKK kr254.44
NZ$167.91
List Price:  NZ$235.09
You save:  NZ$67.17
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,116.02
List Price:  ৳16,962.91
You save:  ৳4,846.89
₹8,825.33
List Price:  ₹12,355.82
You save:  ₹3,530.48
RM420.45
List Price:  RM588.65
You save:  RM168.20
₦150,080.99
List Price:  ₦210,119.39
You save:  ₦60,038.40
₨28,260.46
List Price:  ₨39,565.77
You save:  ₨11,305.31
฿3,169.68
List Price:  ฿4,437.68
You save:  ฿1,268
₺4,136.62
List Price:  ₺5,791.44
You save:  ₺1,654.81
B$538.95
List Price:  B$754.56
You save:  B$215.60
R1,734.74
List Price:  R2,428.71
You save:  R693.96
Лв166.84
List Price:  Лв233.59
You save:  Лв66.74
₩139,040.13
List Price:  ₩194,661.75
You save:  ₩55,621.61
₪332.67
List Price:  ₪465.76
You save:  ₪133.08
₱5,713.92
List Price:  ₱7,999.72
You save:  ₱2,285.79
¥14,773.67
List Price:  ¥20,683.73
You save:  ¥5,910.06
MX$1,846.33
List Price:  MX$2,584.94
You save:  MX$738.60
QR362.89
List Price:  QR508.07
You save:  QR145.17
P1,334.16
List Price:  P1,867.87
You save:  P533.71
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£4,814.47
List Price:  E£6,740.46
You save:  E£1,925.98
ብር14,295.16
List Price:  ብር20,013.80
You save:  ብር5,718.63
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$95,218.47
List Price:  CLP$133,309.67
You save:  CLP$38,091.20
CN¥712.02
List Price:  CN¥996.86
You save:  CN¥284.84
RD$6,345.27
List Price:  RD$8,883.63
You save:  RD$2,538.36
DA12,972.42
List Price:  DA18,161.90
You save:  DA5,189.48
FJ$223.89
List Price:  FJ$313.46
You save:  FJ$89.56
Q765.69
List Price:  Q1,072
You save:  Q306.30
GY$20,829.37
List Price:  GY$29,161.95
You save:  GY$8,332.58
ISK kr12,184.78
List Price:  ISK kr17,059.18
You save:  ISK kr4,874.40
DH898.97
List Price:  DH1,258.59
You save:  DH359.62
L1,660.83
List Price:  L2,325.23
You save:  L664.40
ден5,243.91
List Price:  ден7,341.68
You save:  ден2,097.77
MOP$801.94
List Price:  MOP$1,122.74
You save:  MOP$320.80
N$1,747.34
List Price:  N$2,446.35
You save:  N$699
C$3,663.48
List Price:  C$5,129.02
You save:  C$1,465.54
रु14,084.95
List Price:  रु19,719.49
You save:  रु5,634.54
S/346.43
List Price:  S/485.02
You save:  S/138.58
K421.99
List Price:  K590.81
You save:  K168.81
SAR375.13
List Price:  SAR525.20
You save:  SAR150.06
ZK2,372
List Price:  ZK3,320.90
You save:  ZK948.89
L432.07
List Price:  L604.92
You save:  L172.84
Kč2,071.77
List Price:  Kč2,900.56
You save:  Kč828.79
Ft33,306.29
List Price:  Ft46,630.15
You save:  Ft13,323.85
SEK kr932.45
List Price:  SEK kr1,305.48
You save:  SEK kr373.02
ARS$143,257.44
List Price:  ARS$200,566.15
You save:  ARS$57,308.71
Bs687.94
List Price:  Bs963.15
You save:  Bs275.20
COP$390,754.47
List Price:  COP$547,071.89
You save:  COP$156,317.42
₡50,381.24
List Price:  ₡70,535.76
You save:  ₡20,154.51
L2,607.98
List Price:  L3,651.28
You save:  L1,043.29
₲715,980.77
List Price:  ₲1,002,401.72
You save:  ₲286,420.95
$U4,005.02
List Price:  $U5,607.19
You save:  $U1,602.16
zł362.40
List Price:  zł507.38
You save:  zł144.97
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.