Skip to content

Instantly share code, notes, and snippets.

@dearshrewdwit
Last active March 1, 2022 11:42
Show Gist options
  • Save dearshrewdwit/57ca5bfa91916f462f862d68a75a9ac6 to your computer and use it in GitHub Desktop.
Save dearshrewdwit/57ca5bfa91916f462f862d68a75a9ac6 to your computer and use it in GitHub Desktop.
Development Process

Double the array!

You are going to be given an array of elements. Your job is to return an array which has duplicated each element

Examples:

[1,2] => [1, 1, 2, 2]
['a', 'b'] => ['a', 'a', 'b', 'b']

Extension

const array = ['a', 'b']
array.doubleUp() // => ['a', 'a', 'b', 'b']

Middle Characters

You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters.

Examples:

"test" => "es"
"testing" => "t"
"middle" => "dd"
"A" => "A"

Character Count

You are going to be a string. Your job is to return the count of each character in the string, in alphabetical order

Examples:

"edward" => {
  "a": 1,
  "d": 2,
  "e": 1,
  "r": 1,
  "w": 1,
}
"" => {
}

Find the difference between the lowest and highest numbers

You are going to be an array of integers. Your job is to return an integer which is the difference between the highest and lowest integers in the array.

Examples:

[3,1,7] => 6
[1721, 979, 366, 299, 675, 1456] => 1422

Extension

For each integer in the array, reorder the digits in ascending order before finding the difference between the lowest and highest.

[1721, 979, 366, 299, 675, 1456] => 1157

Build a React component that has random dice rolls

A user should see

  • a title “Dice Roll App”, and a button to click
  • three different random numbers from 1-6 every time they click the button.

No styling needed for this task.

Extension

  • When the number is a 6, a 🔥 emoji should be displayed next to the number
  • When the number is a 1, a 😭 emoji should be displayed next to the number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment