File tree 3 files changed +21
-17
lines changed
3 files changed +21
-17
lines changed Original file line number Diff line number Diff line change 3
3
// from - returns Array Object from any object with a length property or an iterable object
4
4
// from turns array-like/ish into array - string,nodeList,Set
5
5
6
- /* String */
7
- const person = "peter" ;
8
- console . log ( Array . from ( person ) ) ;
6
+ const paragraphs = document . querySelectorAll ( "p" ) ;
7
+ const result = document . getElementById ( "result" ) ;
8
+ const second = document . getElementById ( "second" ) ;
9
9
10
- /* Arguments */
11
- function countTotal ( ) {
12
- console . log ( arguments ) ;
13
- let total = Array . from ( arguments ) . reduce (
14
- ( total , current ) => ( total += current )
15
- ) ;
16
- console . log ( "Total:" , total ) ;
17
- }
18
- countTotal ( 20 , 30 , 40 , 100 ) ;
10
+ let text = Array . from ( paragraphs ) ;
11
+ text = text
12
+ . map ( ( item ) => {
13
+ return `<span>${ item . textContent } </span>` ;
14
+ } )
15
+ . join ( " " ) ;
16
+ result . innerHTML = text ;
17
+
18
+ const newText = Array . from ( document . querySelectorAll ( "p" ) , ( item ) => {
19
+ return `<span>${ item . textContent } </span>` ;
20
+ } ) . join ( " " ) ;
21
+ second . innerHTML = newText ;
Original file line number Diff line number Diff line change 11
11
< link rel ="stylesheet " href ="./styles.css " />
12
12
</ head >
13
13
< body >
14
- < h1 > ES6</ h1 >
15
- < h1 > JavaScript </ h1 >
16
- < h1 > CSS </ h1 >
17
- < h1 > HTML </ h1 >
14
+ < h1 style =" text-align: center " > ES6</ h1 >
15
+ < p > john </ p >
16
+ < p > susan </ p >
17
+ < p > peter </ p >
18
18
< h2 id ="result "> </ h2 >
19
+ < h1 id ="second "> </ h1 >
20
+
19
21
<!-- Link to JavaScript -->
20
22
< script src ="./app.js "> </ script >
21
23
</ body >
Original file line number Diff line number Diff line change 5
5
}
6
6
7
7
h1 {
8
- text-align : center;
9
8
letter-spacing : 2px ;
10
9
}
11
10
You can’t perform that action at this time.
0 commit comments