Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

</head>
<body>

<script src ="strings.js"></script>

</body>
</html>
21 changes: 21 additions & 0 deletions strings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


function reverseString(str) {
// Step 1. Use the split() method to return a new array
let splitString = str.split(""); // var splitString = "hello".split("");
// ["h", "e", "l", "l", "o"]

// Step 2. Use the reverse() method to reverse the new created array
let reverseArray = splitString.reverse(); // var reverseArray = ["h", "e", "l", "l", "o"].reverse();
// ["o", "l", "l", "e", "h"]

// Step 3. Use the join() method to join all elements of the array into a string
let joinArray = reverseArray.join(""); // var joinArray = ["o", "l", "l", "e", "h"].join("");
// "olleh"

//Step 4. Return the reversed string
return joinArray; // "olleh"
}

reverseString("Hello");
reverseString("SuperDeeDuper");