Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { useState } from 'react'
- import {v4 as uuid} from 'uuid'
- function App(){
- const [valor, setValor] = useState(1)
- const multiplicar = () => {
- if(isNaN(valor))
- return []
- let produtos = []
- for(let m = 1; m <= 10; m++)
- produtos.push(valor * m)
- return produtos
- }
- return (
- <>
- <h1>React - Tabuada</h1>
- <hr />
- <input type="number" onChange={e => setValor(parseInt(e.target.value))} value={valor} />
- { multiplicar().map((item, index) => <p key={uuid()}>{valor}x{index+1} = {item}</p>) }
- </>
- )
- }
- export default App
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement