const strings = ['a', 'b', 'c', 'd'];
// 4 * 4 = 16 bytes of storage
strings[2];
strings.push('e');
// Create a function that reverses a string:
// 'Test this'
// 'siht tset'
// Input: String
// Output: String with characters in reverse
// Plan: Take the input string, separate each characters and insert into an array,
// create an empty array variable, loop through the input array backwards,
// insert those characters into the empty array variable
// Time complexity: O(n)
let firstWord = 'Test this';
function reverseString(word) {
const splitWord = word.split('');
let reverseWord = '';
for (let i = splitWord.length - 1; i >= 0; i--) {
reverseWord += splitWord[i];
}
console.log(reverseWord);
return reverseWord;
}
reverseString(firstWord);