forked from The-Knowledge-House/js-types
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
135 lines (113 loc) · 3.85 KB
/
script.js
File metadata and controls
135 lines (113 loc) · 3.85 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//IMPORTANT: Type ls, to find the file to use npm!!!!! OJO
/**
* All of your answers should be stored in
* variables matching the question number (q1, q2, etc.)
*/
/**
* EXAMPLE
* QUESTION 1
* Assign q1 a value of type boolean
*/
const q1 = true;
/**
* QUESTION 2
* Assign q2 a value of type number
*/
const q2 = 45;
/**
* QUESTION 3
* Assign q3 a value of type string
*/
const q3 = "This is a string";
/**
* QUESTION 4
* Assign q4 a value of NaN (not a number). Produce NaN by performing
* an operation where neither of the operands are NaN
* (i.e. `const q4` = NaN * 5 does not count)
*/
const q4 = NaN;
/**
* QUESTION 5
* Assign q5 a value of type boolean. Produce the value by performing
* a comparison operation on two numbers.
*/
const q5 = 3 > 1 == true;
/**
* QUESTION 6
* Assign q6 a falsey value that is not the boolean false
*/
const q6 = 4 < 2 == true;
/**
* For use in the next few questions,
* here's the text of the Gettsyburg Address.
*/
const address = `
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
But, in a larger sense, we can not dedicate—we can not consecrate—we can not hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom—and that government of the people, by the people, for the people, shall not perish from the earth.
`
/**
* QUESTION 7
*
* Assign a version of the Gettysburg address converted to all capital letters.
*/
const q7 = address.toUpperCase();
/**
* QUESTION 8
* Assign the number of characters in the Gettysburg Address
*/
const q8 = address.length;
/**
* QUESTION 9
* Assign the result of splitting the Gettysburg Address on spaces
* (use the same variable `address` to get started)
*/
const q9 = address.split(' ');
/**
* QUESTION 10
* Assign q9 the number of words in the Gettysburg Address
* (use your answer from above)
*/
const q10 = address.split(' ').length;
/**
* QUESTION 11
* The array created in question 9 includes periods.
* Loop over that array and build a new array with the periods (.)
* removed from each word. Assign q11 the result.
*/
let q11 = q9
for (var i=0; i<q9; i++) {
q11 = q9.map(w => w.replace(/[.]+/g, ' '));
console.log(q11);
};
/**
* QUESTION 12
* The array created in question 11 is each word of the Gettysburg Address
* with no punctuation. Loop over that array and create a new array of each
* word's length. Assign q11 the result.
*/
const q12 = word,length;
for (var i=0; i<q11.length; i++) {
console.log(q11);
};
/**
* QUESTION 13
* Using the array created in question twelve, calculate the average word length
* the Gettysburg address. Assign q13 the result.
*/
const q13 = null;
module.exports = {
q1,
q2,
q3,
q4,
q5,
q6,
q7,
q8,
q9,
q10,
q11,
q12,
q13
};