Stacks Stack.push: The stack.push places the data on the top and the rest are queued. Stack.pop: The pop method removes the top data instead of the bottom. stack.peek: Displays the top data stack.length: Displays the # of data inside an array or object. Ex 1.) var letters = []; [] === arrays where the data is going to be stored var word = "101" var rword = ""; // put letters of word into stack for (var i = 0; i < word.length; i++) { This will push the letters in the string letters.push(word[i]); } // pop off the stack in reverse order for (var i = 0; i < word.length; i++) { This will pop the letters in the pushed output rword += letters.pop(); } if (rword === word) { console.log(word + " is a palindrome."); This will determine if the word is a ...
Here's my entire code for the website I built. Resources: Javascript the definitive guide : https://www.amazon.com/JavaScript-Definitive-Guide-Activate-Guides/dp/0596805527 W3SCHOOL: https://www.w3schools.com/ Stack Overflow: https://stackoverflow.com/ YouTube: https://www.youtube.com/ This code is before 10/3/2019 7:44PM <!doctype html> <html> <head> <link href="main.css" rel="stylesheet" type="text/css"/> <title>D a v i d Y a s u d a </title> </head> <body id="e2"> <style> #e2 { overflow:visible; font-family: "Lato", sans-serif; } .sidenav { height: 100%; width: 0; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; overflow-x: hidden; transition: 0.5s; padding-top: 60px; } .sidenav a { padding: 8px 8px 8px 32px; ...
Comments
Post a Comment