File tree Expand file tree Collapse file tree 3 files changed +63
-36
lines changed Expand file tree Collapse file tree 3 files changed +63
-36
lines changed Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
2
< html lang ="en ">
3
- < head >
4
- < meta charset ="UTF-8 ">
5
- < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6
- < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
3
+ < head >
4
+ < meta charset ="UTF-8 " / >
5
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " / >
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " / >
7
7
8
- < link rel ="stylesheet " href ="./styles.css ">
8
+ < link rel ="stylesheet " href ="./styles.css " / >
9
9
< title > CodeWars Testing Suite</ title >
10
- </ head >
11
- < body >
10
+ </ head >
11
+ < body >
12
12
< div id ="container ">
13
- < div id ="challenge "> Challenge Text</ div >
14
- < div > Your input was: < span id ="input "> </ span > </ div >
15
- < div > Your output is: < span id ="primus "> error Will Robinson!</ span > </ div >
16
-
13
+ < div id ="challenge "> Challenge Text</ div >
14
+ < div >
15
+ < form action ="">
16
+ < label for ="input "> Your input:</ label >
17
+ < input type ="text " id ="input " name ="input " />
18
+ </ form >
19
+ </ div >
20
+ < div > Your output is: < span id ="primus "> error Will Robinson!</ span > </ div >
17
21
</ div >
18
- </ body >
19
- < script src ="./middlePermutation .js "> </ script >
20
- </ html >
22
+ </ body >
23
+ < script src ="./reverseWords .js " defer > </ script >
24
+ </ html >
Original file line number Diff line number Diff line change
1
+ // Complete the function that accepts a string parameter, and reverses each word in the string. All spaces in the string should be retained.
2
+
3
+ // Examples:
4
+ // "This is an example!" ==> "sihT si na !elpmaxe"
5
+ // "double spaces" ==> "elbuod secaps"
6
+ let output = document . getElementById ( 'primus' ) ;
7
+ let input = document . getElementById ( 'input' ) . innerText ;
8
+
9
+ function reverseWords ( string ) {
10
+ let array = string . split ( ' ' ) ;
11
+ let newString = [ ] ;
12
+ for ( i = array . length ; i > 0 ; i -- ) {
13
+ newString . push ( array [ i ] ) ;
14
+ }
15
+ output . innerText = newString . join ( ' ' ) ;
16
+ }
17
+
18
+ document
19
+ . getElementById ( 'input' )
20
+ . addEventListener ( 'change' , reverseWords ( input ) ) ;
21
+
22
+ // testing purposes, safely ignore the below
23
+ console . log ( 'world hello!' ) ;
Original file line number Diff line number Diff line change 1
1
@import url ('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap' );
2
2
3
3
body {
4
- background-color : black;
5
- color : # aaa ;
6
- margin : 0 ;
7
- padding : 0 ;
8
- font-size : 1rem ;
9
- font-family : Lato, sans-serif;
10
- display : flex;
11
- flex-flow : column nowrap;
12
- justify-content : center;
13
- align-items : center;
4
+ background-color : black;
5
+ color : # aaa ;
6
+ margin : 0 ;
7
+ padding : 0 ;
8
+ font-size : 1rem ;
9
+ font-family : Lato, sans-serif;
10
+ display : flex;
11
+ flex-flow : column nowrap;
12
+ justify-content : center;
13
+ align-items : center;
14
14
}
15
15
16
16
# container {
17
- width : 60% ;
18
- height : 100vh ;
19
- display : flex;
20
- flex-direction : column;
21
- justify-content : space-evenly;
22
- align-items : center;
23
- text-align : center;
17
+ width : 60% ;
18
+ height : 100vh ;
19
+ display : flex;
20
+ flex-direction : column;
21
+ justify-content : space-evenly;
22
+ align-items : center;
23
+ text-align : center;
24
24
}
25
25
26
- # input , # primus {
27
- color : white;
28
- font-size : 1.5rem ;
29
- font-weight : 800 ;
30
- }
26
+ # input ,
27
+ # primus {
28
+ font-size : 1.5rem ;
29
+ font-weight : 800 ;
30
+ }
You can’t perform that action at this time.
0 commit comments