You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a function that takes a string (a random name). If the last character of the name is an "n", return true, otherwise return false.
@@ -127,7 +157,11 @@ ES6: Destructuring Arrays III
127
157
You can assign variables from arrays with destructuring like this:
128
158
const arr = ["eyes", "nose", "lips", "ears"]
129
159
let [eyes, nose, lips, ears] = arr
160
+
NOTE: I used ",," to skip over items in the array being destrcutured: https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
161
+
NOTE: Each comma means equals one index (i.e. ",," equals index[1] and ",,," equals index[2])
130
162
*/
163
+
constarr=["eyes","nose","lips","ears"]
164
+
var[,,lips]=arr// skips over items
131
165
132
166
133
167
@@ -142,6 +176,7 @@ function stackBoxes(n) {
142
176
}
143
177
144
178
179
+
145
180
/*
146
181
Array of Word Lengths
147
182
Create a function that takes an array of words and transforms it into an array of each word's length.
@@ -150,4 +185,28 @@ function wordLengths(arr) {
150
185
returnarr.map(function(word){
151
186
returnword.length;
152
187
});
188
+
}
189
+
190
+
191
+
192
+
/*
193
+
Count the Syllables
194
+
Create a function that returns the number of syllables in a simple string. The string is made up of short repeated words like "Lalalalalalala" (which would have 7 syllables).
195
+
countSyllables("Hehehehehehe") ➞ 6
196
+
*/
197
+
functioncountSyllables(str){
198
+
returnstr.length/2;
199
+
}
200
+
201
+
202
+
/*
203
+
Add the Index
204
+
Given an array of numbers, create a function which returns the same array but with each element's index in the array added to itself. This means you add 0 to the number at index 0, add 1 to the number at index 1, etc...
0 commit comments