The Code for Reverse

// Validation on user input
function isValid() {
	// Get Values from Page
	let usrInput = document.getElementById('usrInput').value;

	// Call Empty Table

	// Validates input (makes sure numbers are within rage, start:1-20 | end 21-1,000,000)
	if (usrInput === '') {
		alert('Please enter a word or phrase');
	} else {

// Empty the Table of values on the page
function emptyTable() {
	let table = document.getElementById('result');
	while (table.firstChild) {

// Takes the user input string and makes it an array
function arrayify(usrInput) {
	let usrArray = [];

	for (let i = 0; i < usrInput.length; i++) {

// Takes the array and pops off each letter into a reverse string
function reversify(usrArray) {
	let reverse = '';

	while (usrArray.length > 0) {
		reverse += usrArray.pop().toString();

// Output Reverse to Page
function printOutput(reverse) {
	let tr = document.createElement('tr');
	let td = document.createElement('td');

	document.getElementById('result').appendChild(tr).appendChild(td).innerHTML = reverse;


The Code is structured in the following functions:


This function checks to see if the user input is valid and not just an empty string Also tucked in here is a clearing of any previous tables generated by the user by calling the emptyTable function


This function loops through the table children and deletes each one until the table is empty. Can be called upon by the user from the page as well.


This function takes in the user input and loops through each letter and adds it to an array for manipulation. It then sends it to the reversify function.


This function takes the array and pops off each of the last letters until there aren't anymore and adds them to a new string. It them calls the printOutput and passes the new string.


This function creates table row, table data, and appends them to the current table the new string that was passed to it.