This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enum TrafficLightColors { | |
Red = "#ff0000", | |
Yellow = "#fff600", | |
Green = "#37ff00" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enum TrafficLightColors { | |
Red, | |
Yellow, | |
Green | |
} | |
const passingTrafficLight: TrafficLightColors = TrafficLightColors.Red; // this will pass | |
const failingTrafficLight: TrafficLightColors = "green" // :( This will fail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You and your teammate have been working on a project for two and a half | |
// weeks. Everything is going well except you notice that one of the functions | |
// your teammate wrote is failing a test case, which you know to be correct. | |
// Unfortunately, your teammate is sick today and to make matters worse, you | |
// realize that you need to demo your project in ten minutes. So you decide | |
// to try and fix the function. Can you fix it in time for your demo? | |
//////////////////////////////////////////////////////////////////////////////// | |
const SYMBOLS = [ 'AAPL', 'AMZN', 'MONY', 'PETS', 'PZZA', 'SHOP', 'TSLA', 'WIFI' ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from "styled-components"; | |
const Checkbox = styled.input.attrs(() => ({ | |
type: 'checkbox' | |
}))` | |
appearance: none; | |
background-color: #ffffff; | |
border: 1px solid #000000; | |
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05); | |
padding: 8px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scoreboard-reducer.js | |
const INITIAL_STATE = { | |
home: 0, | |
away: 0, | |
} | |
export const scoreboardReducer = (state = INITIAL_STATE, action) { | |
switch (action.type) { | |
case 'INCREMENT_SCORE': | |
const scoringSide = action.payload.team | |
return {...state, [scoringSide]: state[scoringSide] + 1 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scoreboard-reducer.js | |
const INITIAL_STATE = { | |
home: 0, | |
away: 0, | |
} | |
export const scoreboardReducer = (state = INITIAL_STATE, action) { | |
switch (action.type) { | |
case 'INCREMENT_SCORE': | |
const scoringSide = action.payload.team; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scoreboard-reducer.js | |
const INITIAL_STATE = { | |
home: 0, | |
away: 0, | |
} | |
export const scoreboardReducer = (state = INITIAL_STATE, action) { | |
switch (action.type) { | |
case 'GOAL_SCORED': | |
const scoringSide = action.payload.team; | |
return {...state, [scoringSide]: state.[scoringSide] + 1 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scoreboard-reducer.js | |
const INITIAL_STATE = { | |
home: 0, | |
away: 0, | |
} | |
export const scoreboardReducer = (state = INITIAL_STATE, action) { | |
switch (action.type) { | |
case 'INCREMENT_HOME_SCORE': | |
return {...state, home: state.home + 1 }; | |
case 'INCREMENT_AWAY_SCORE': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { someReducer, SOME_REDUCER_INITIAL_STATE } from './someReducer.js' | |
describe('someReducer', () => { | |
it('should return the correct initial state', () => { | |
expect(someReducer(undefined, {}).toEqual(SOME_REDUCER_INITIAL_STATE); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { someReducer } from './someReducer.js' | |
describe('someReducer', () => { | |
it('should return the correct initial state', () => { | |
expect(someReducer(undefined, {}).toEqual({ | |
prop1: 'someValue1', | |
prop2: 'someValue2', | |
..... | |
}); | |
}); |
NewerOlder