GithubHelp home page GithubHelp logo

js-objects-stack-warmup's Introduction

General Assembly Logo

JavaScript Warm-Up: Stack

In computer science, a stack or LIFO (last in, first out) is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the last element that was added. -- Stack (abstract data type), Wikipedia

Instructions

  1. Fork and clone this repository.
  2. Change into the new directory.
  3. Follow the remaining instructions.

Create a custom JavaScript object modeling the stack using a constructor function and a prototype. Starter code has been provided for you in lib/stack.js.

Requirements

  • You should be able to create a new stack with var stack = Stack.new();.
  • Your stack should have two methods, push and pop.
    • push adds a new value to the stack's storage and returns the added value
    • pop removes the most recently added value from the stack's storage and returns it
  • You should not use Array.prototype.push() or Array.prototype.pop()

Bonus

Pre-fill the stack on instantiation.

var stack = Stack.new([1,2,3])
stack.pop() //=> 3

Which parts of each method are side-effects, and which are the "main" effect?

Source code distributed under the MIT license. Text and other assets copyright General Assembly, Inc., all rights reserved.

js-objects-stack-warmup's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.