generated from freeCodeCamp/template
-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathcurriculum-helpers-javascript.ts
More file actions
94 lines (79 loc) · 2.31 KB
/
curriculum-helpers-javascript.ts
File metadata and controls
94 lines (79 loc) · 2.31 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const jsCodeWithSingleAndMultLineComments = `
function nonMutatingPush(original, newItem) {
/* This is a
multi-line comment
that should be removed. */
return original.push(newItem);
}
var first = [1, 2, 3];
// This is a single line comment
var second = [4, 5];
nonMutatingPush(first, second);`;
const jsCodeWithSingleAndMultLineCommentsRemoved = `
function nonMutatingPush(original, newItem) {
return original.push(newItem);
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingPush(first, second);`;
const jsCodeWithUrl = `
function nonMutatingPush(original, newItem) {
var url = 'https://freecodecamp.org'; // this comment should vanish
return original.push(newItem);
}`;
const jsCodeWithUrlUnchanged = `
function nonMutatingPush(original, newItem) {
var url = 'https://freecodecamp.org';
return original.push(newItem);
}`;
const jsCodeWithNoCall = `function myFunc() {
return Math.random();
}
`;
const jsCodeWithNoArgCall = `function myFunc() {
return Math.random();
}
myFunc();
`;
const jsCodeWithArgCall = `function myFunc() {
return Math.random();
}
myFunc('this shouldn't be here');
`;
const jsCodeWithCommentedCall = `function myFunc() {
return Math.random();
}
/*
myFunc();
*/
`;
const functionDeclaration =
"function myFunction(param1, param2 = 'default', param3) {";
const constFunction =
"const myFunction = (param1, param2 = 'default', param3) => {";
const letFunction =
"let myFunction = function(param1, param2 = 'default', param3) {";
const arrowFunction = `const myFunc = name => console.log("Name")`;
const destructuredArgsFunctionDeclaration = `function printFruits({a, b},c = 1, ...rest) {`;
// eslint-disable-next-line no-template-curly-in-string
const jsCodeTemplateCurlyComment = "const v = /*a*/`/*b*/${/*c*/12}`";
// eslint-disable-next-line no-template-curly-in-string
const jsCodeTemplateCurlyNoComments = "const v = `/*b*/${12}`";
const testValues = {
jsCodeWithSingleAndMultLineComments,
jsCodeWithSingleAndMultLineCommentsRemoved,
jsCodeWithUrl,
jsCodeWithUrlUnchanged,
jsCodeWithNoCall,
jsCodeWithNoArgCall,
jsCodeWithArgCall,
jsCodeWithCommentedCall,
functionDeclaration,
constFunction,
letFunction,
arrowFunction,
destructuredArgsFunctionDeclaration,
jsCodeTemplateCurlyComment,
jsCodeTemplateCurlyNoComments
};
export default testValues;