Skip to content

Commit 6bc4c62

Browse files
updates, still not functional
1 parent e833dae commit 6bc4c62

File tree

3 files changed

+63
-36
lines changed

3 files changed

+63
-36
lines changed

index.html

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<!DOCTYPE html>
22
<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" />
77

8-
<link rel="stylesheet" href="./styles.css">
8+
<link rel="stylesheet" href="./styles.css" />
99
<title>CodeWars Testing Suite</title>
10-
</head>
11-
<body>
10+
</head>
11+
<body>
1212
<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>
1721
</div>
18-
</body>
19-
<script src="./middlePermutation.js"></script>
20-
</html>
22+
</body>
23+
<script src="./reverseWords.js" defer></script>
24+
</html>

reverseWords.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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!');

styles.css

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap');
22

33
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;
1414
}
1515

1616
#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;
2424
}
2525

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+
}

0 commit comments

Comments
 (0)