Created
November 28, 2017 07:42
-
-
Save incon/e3caa3576db7caaefd167ae54a8df31b to your computer and use it in GitHub Desktop.
React FizzBuzz
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"; | |
const Number = props => <span>{props.value}</span>; | |
const Fizz = () => <span>Fizz</span>; | |
const Buzz = () => <span>Buzz</span>; | |
export const FizzBuzz = () => { | |
return [...Array(100).keys()].map(v => { | |
v++; | |
return ( | |
<div key={v}> | |
{v % 5 !== 0 && v % 3 !== 0 && <Number value={v} />} | |
{v % 3 === 0 && <Fizz />} | |
{v % 5 === 0 && <Buzz />} | |
</div> | |
); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment