Skip to content

Instantly share code, notes, and snippets.

@elnygren
Created September 14, 2017 07:40
Show Gist options
  • Select an option

  • Save elnygren/8b58ba5c6ae6c747fed5485839bc2b12 to your computer and use it in GitHub Desktop.

Select an option

Save elnygren/8b58ba5c6ae6c747fed5485839bc2b12 to your computer and use it in GitHub Desktop.
React junior interview
// tehtävä
// make the following code "better"
// with map, filter, reduce, ES6
var arr = [1,2,3,4,5,6]
var sum = 0
var newArr = []
for (var i = 0; i < arr.length; i++) {
if (arr[i] % 2 == 0) {
newArr.push(arr[i] * 2)
}
sum += arr[i]
}
console.log(newArr, sum)
// Tehtävä:
// Kun C komponentissa olevaa buttonia klikataan, B:ssä olevan numeron pitää kasvaa yhdellä
import React from 'react'
export default class A extends React.Component {
render() {
return (
<div>
<B/>
<C/>
</div>
)
}
}
export default class B extends React.Component {
render() {
return <span>0</span>
}
}
export default class C extends React.Component {
render() {
return <button/>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment