This file contains 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
function sum(...theArgs) { | |
return theArgs.reduce((previous, current) => { | |
return previous + current; | |
}); | |
} | |
console.log(sum(1, 2, 3)) // 6 | |
// expected output: 6 | |
console.log(sum(1, 2, 3, 4)) // 10 |
This file contains 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
// let's separate Hansel from the rest, he will be put in the cage | |
const people = { Hansel: { age: 14 }, Gretel: { age: 10 }, Witch: { age: 99 } } | |
const { Hansel, ...rest } = people | |
console.log(Hansel) // { age: 14 } | |
console.log(rest) // { Gretel: { age: 10 }, Witch: { age: 99 } } | |
// let's draw cards from a deck | |
const deckOfCards = ['sevenOfClubs', 'aceOfSpades', 'queenOfHearts'] |
This file contains 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
// let's add out dice in a game | |
const dicePool = [5, 2, 4] | |
const firstDiceThrow = [1, 4, 6] | |
const secondDiceThrow = [3, 6, 1] | |
console.log(dicePool) // [5, 2, 4] | |
dicePool.push(...firstDiceThrow, ...secondDiceThrow) | |
console.log(dicePool) // [5, 2, 4, 1, 4, 6, 3, 6, 1] |
This file contains 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
// create a cube from a square | |
const square = { x: 5, y: 10 } | |
const cube = { ...square, z: 12 } | |
console.log(square) // { x: 5, y: 10 } | |
console.log(cube) // { x: 5, y: 10, z: 12 } | |
cube.x = 10 | |
console.log(square) // { x: 5, y: 10 } |
This file contains 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
// our base for making copies | |
const baseUnit = { | |
movement: 10, | |
hp: 100, | |
attributes: { | |
str: 12, | |
dex: 8, | |
con: 18, | |
}, | |
} |
This file contains 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
// our NewWorldComponent.jsx | |
const NewWorldComponent = (props) => { | |
const { targetWorld } = props | |
return ( | |
<div> | |
Hello {targetWorld}! | |
</div> | |
) | |
} |
This file contains 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
// our SpecialLink.jsx | |
const SpecialLink = (props) => { | |
const { url, label, ...additionalProps } = props | |
return ( | |
<a href={url} ...additionalProps> | |
{label} | |
</a> | |
) | |
} |
This file contains 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 React from 'react'; | |
import { Provider } from 'react-redux' | |
import { enableScreens } from 'react-native-screens'; | |
import configureStore from './src/redux/store' | |
import { initialiseApplication } from './src/redux/actions/application.actions' | |
import Navigation from './src/navigation' | |
enableScreens(); | |
const store = configureStore() |
This file contains 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
// src/components/other/VersionTag.jsx | |
import React from 'react' | |
import { Text } from 'react-native' | |
import { connect } from 'react-redux' | |
const VersionTag = ({ applicationState: { version, name } }) => ( | |
<Text>{`${name} (v${version})`}</Text> | |
) | |
const mapStateToProps = (state) => ({ |
OlderNewer