codedamn

Building an increment decrement counter

Created by Codedamn about a year ago

0

No description provided

8 Comments

    0

    why decrement does not work?

    import React,{useState} from 'react'

    function App() { const [counter,setCounter]=useState(0)

    const incrementCount=()=>{
        setCounter(counter+1);
    };
    
    const decrementCount=()=>{
        setCounter(counter-1);
    };
    
    return (
    	<div className="App">
    		<h1>Counter: <span>{counter}</span></h1>
    		<button onClick={incrementCount}>Increment</button>
    		<button onclick={decrementCount}>Decrement</button>
    	</div>
    );
    

    }

    export default App

    @erwinpritanto

    Erwin Pritanto

    @erwinpritanto

    1

    No Test Case are Passes but i checked everything looks Fine And Also a update Template to react 18 too fix reactDom Reander isssue import React , {useState} from 'react'

    function App() { const [counter,setCounter] = useState(0); function Increase (){ setCounter(oldValue => oldValue + 1); } function Deacrease (){ setCounter(oldValue => oldValue - 1); } return ( <div className="App"> <h1>Counter: <span>{counter}</span></h1> <button onClick={Increase}>Increment</button> <button onClick={Deacrease}>Decrement</button> </div> ) }

    export default App

    @kodedara

    Kodedara

    @kodedara

    0

    It keep showing no test passed what did i do wrong

    import React,{useState} from 'react'

    function App() {

    const [counter,setCounter] = useState(0) function increment1 () { setCounter(counter + 1) }

    function decrement1 (){
    setCounter(counter - 1)
    }
    

    return ( <div className="App"> <h1>Counter: <span>{counter}</span></h1> <button onClick={increment1}>Increment</button> <button onClick={decrement1}>Decrement</button> </div> ) }

    export default App

    @duduumoon21

    Adugna Tefera

    @duduumoon21

    0

    this is my code and it working absolutely perfect but it still saying test not passed

    import React from 'react' import react, {useState} from 'react'

    function App() { const [counter, setCounter] = useState(0)

     function increase (){
      setCounter(counter + 1)
      }
      
      function decrease (){
    	setCounter(counter - 1)
      }
    
    
     return (
    	<div className="App">
    		<h1>Counter: <span>{counter}</span></h1>
    		<button onClick = {increase} >Increment</button>
    		<button onClick = {decrease} >Decrement</button>
    	</div>
    

    ) }

    export default App

    @gtheapex

    Gbenga yasir Atunnise

    @gtheapex

    0

    test Case for this exercise is not written properly . Please check

    @parmjeetmishra

    Parmjeet Mishra

    @parmjeetmishra

    0

    this is my code and it working absolutely perfect but it still saying test not passed

    @vivek0808

    Vivek Sharma

    @vivek0808

    0

    import React,{useState} from 'react'

    function App() { const [counter,setCounter] = useState(1) function Increase(){ setCounter(counter+1) } function Decrease(){ setCounter(counter-1) } return ( <div className="App"> <h1>Counter: <span>{counter}</span></h1> <button onClick={Increase}>Increment</button> <button onClick={Decrease}>Decrement</button> </div> ) }

    export default App

    code is not passing all test cases

    @hafeez500

    Shaik Hafeez Basha

    @hafeez500

    0

    after everything i tried my test cases are not passing.

    import React,{useState} from 'react';

    function App() { const [counter,setCounter] = useState(1) function Increase(){ setCounter(counter+1) } function Decrease(){ setCounter(counter-1) } return ( <div className="App"> <h1>Counter: <span>{counter}</span></h1> <button onClick={Increase}>Increment</button> <button onClick={Decrease}>Decrement</button> </div> ); } export default App;

    @imasamuraitoo

    Agon Keet

    @imasamuraitoo

Your comment