forked from HackYourFuture/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstep2-3.js
More file actions
47 lines (34 loc) · 1.1 KB
/
step2-3.js
File metadata and controls
47 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
// Use a 'for' loop
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);
return result;
}
console.log('for', repeatStringNumTimesWithFor('abc', 3));
// Use a 'while' loop
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);
return result;
}
console.log('while', repeatStringNumTimesWithWhile('abc', 3));
// Use a 'do...while' loop
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);
return result;
}
console.log('do-while', repeatStringNumTimesWithDoWhile('abc', 3));
// Do not change or remove anything below this line
module.exports = {
repeatStringNumTimesWithFor,
repeatStringNumTimesWithWhile,
repeatStringNumTimesWithDoWhile,
};