Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finished 2.3
  • Loading branch information
jshortz committed Jul 13, 2019
commit d67d07e6a4aea271383af65a579dd1c089ccb1a6
25 changes: 13 additions & 12 deletions Week3/homework/step2-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
function repeatStringNumTimesWithFor(str, num) {
// eslint-disable-next-line prefer-const
let result = '';

// Replace this comment and the next line with your code
console.log(str, num, result);

for (let i = 0; i < num; i++) {
result += str;
}
return result;
}

Expand All @@ -17,10 +16,11 @@ console.log('for', repeatStringNumTimesWithFor('abc', 3));
function repeatStringNumTimesWithWhile(str, num) {
// eslint-disable-next-line prefer-const
let result = '';

// Replace this comment and the next line with your code
console.log(str, num, result);

let counter = 0;
while (counter < num) {
result += str;
counter++;
}
return result;
}

Expand All @@ -30,10 +30,11 @@ console.log('while', repeatStringNumTimesWithWhile('abc', 3));
function repeatStringNumTimesWithDoWhile(str, num) {
// eslint-disable-next-line prefer-const
let result = '';

// Replace this comment and the next line with your code
console.log(str, num, result);

let i = 0;
do {
result += str;
i++;
} while (i < num);
return result;
}

Expand Down