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, { useEffect, useState, useCallback } from 'react'; | |
const USERS_URL = 'https://example.com/api/users'; | |
const PAGE_SIZE = 10; | |
const calcPageCount = (count) => { | |
return Math.floor(count/PAGE_SIZE) + (count%PAGE_SIZE ? 1 : 0); | |
} |
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
/* | |
* Given an array of objects in JavaScript. | |
* Each one contains a name (a string) and ranking (a number). | |
* Write two functions, one to return the objects ordered by ranking and another to return the average ranking. | |
*/ | |
// Calculate the average ranking | |
const calcAverageRanking = arr => arr.reduce((total, { ranking }) => (total + ranking), 0)/ arr.length; | |
// Function to return objects ordered by ranking |
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, { PropTypes, Component } from 'react'; | |
import { isEmpty } from 'underscore'; | |
import { reduxForm } from 'redux-form'; | |
import { bindActions, validateRegFields } from 'path to base'; | |
import { regFields } from 'path to constants'; | |
import TextInput from 'path to TextInput component'; | |
import ProgressBar from 'path to ProgressBar component'; | |
class RegisterForm extends Component { | |
constructor(props) { |
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
Set up a simple folder strucure thus: | |
``` | |
SumNumbers | |
|-src/ | |
| |-index.js | |
|-test/ | |
| |-test.js | |
|-package.json | |
``` |
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
Set up a simple folder strucure thus: | |
``` | |
FlattenList | |
|-src | |
| |-index.js | |
|-test | |
| |-test.js | |
|-package.json | |
``` |