Skip to content

Instantly share code, notes, and snippets.

  1. Write a method that combines two Arrays passed in as arguments, and returns a new Array that contains all elements from both Array arguments, with the elements taken in alternation. You may assume that both input Arrays are non-empty, and that they have the same number of elements.
  interleave([1, 2, 3], ['a', 'b', 'c']) 
  // returns [1, 'a', 2, 'b', 3, 'c']
  1. Refactor your method to handle two Arrays of different lengths and empty Arrays. The new array should always start with an element from the first array if possible.
  interleave([1, 2], ['a', 'b', 'c' ,'d']) 
  // returns [1, 'a', 2, 'b', 'c', 'd'] 
  1. Write a function that takes an array of characters and returns an array of just the character names (as strings) that are superheroes:
    const characters = [
      { character: 'Superman', hero: true },
      { character: 'Sinestro', hero: false },
      { character: 'Wonder Woman', hero: true },
      { character: 'Lex Luthor', hero: false },
      { character: 'Green Lantern', hero: true }
    ]
  1. Write a function spinWords that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed. Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.
spinWords("Welcome")              // "emocleW"
spinWords("Hey fellow warriors")  // "Hey wollef sroirraw"
spinWords("This is a test")       // "This is a test"
spinWords("This is another test") // "This is rehtona test"
Bonus

Matrix Checksum

Problem Statement

You are given a matrix (an array of arrays) which consists of rows of seemingly-random numbers. We need you to determine the matrix's checksum, which is calculated as followed:

For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences.

Example

Here's an example of a 3-by-3 matrix:

@thuyanduong
thuyanduong / README.md
Last active February 17, 2021 20:53
Build your first AJAX Webpage

Create Studio Ghibli Webpage!

You are allowed to copy and paste the code below from today's lecture. You should use it to create a similar web page with the following user story:

As a user, when I click on the button, I should see a list of Studio Ghibli characters.

You should use the Stuido Ghibli API:

@thuyanduong
thuyanduong / README.md
Created February 21, 2021 21:20
Marcy Lab School Lesson on REST and JSON Server

Lesson: REST and JSON Server

Key Terms

  • REST
  • GET
  • POST
  • DELETE
  • PUT
  • PATCH
  • JSON Server
@thuyanduong
thuyanduong / index.js
Created February 23, 2021 15:48
This is a simple gist
console.log("I want to write some notes in this file")
@thuyanduong
thuyanduong / README.md
Last active March 10, 2021 13:57
Wheel Of Fortune Game

Wheel of Fortune: Putting it All Together

For this lesson, we're going to build on everything you've learned during this unit by building a simplified version of America's favorite game show: Wheel of Fortune! Here's how it will work.

  1. Your application should choose a random word. You can use the getRandomWord function in the starter code. When called with no arguements, the function will return a random word of five letters or more.
  2. Display the word to the user using underscores (or empty divs) to replace each letter. For example, if the word is "horse", you would dispaly "- - - - - ".
  3. There should be a start button. When the user clicks start, reveal any instances of the letters R,S,T,L,N, or E. Using the "horse" example above, we would then display: "_ _ R S E"
  4. Via some form, the user can then guess 3 constanants and one vowel. For example, the user might enter "B C D O" and press "Submit Letters". You MUST validate each field to make sure that they enter a valid letter!
  5. After th
@thuyanduong
thuyanduong / todolist.sql
Last active March 30, 2021 20:20
MarcyLab Express API To Do List database script
DROP TABLE IF EXISTS tasks;
DROP TABLE IF EXISTS users;
-- CREATE TABLE users
-- INSERT some data into users
-- CREATE TABLE tasks
-- INSERT some data into tasks
@thuyanduong
thuyanduong / example.md
Last active April 2, 2021 16:08
Documentation Temple

Name of the App

Description of the App

Write a paragraph describing what your app is and how a user would use it. A user can do the following things...

API Endpoints

GET /cats

Responds with a JSON array of all cats.