From 620667e229335c20dc833a7f15dd37308de021e1 Mon Sep 17 00:00:00 2001 From: Yana Date: Tue, 14 Jan 2025 13:49:17 +0200 Subject: [PATCH] Implement addOne and add100 functions --- src/App.jsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index c526b634..5216428e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2,14 +2,26 @@ import { useState } from 'react'; import './App.scss'; export const App = () => { - const [count] = useState(0); + const [count, setCount] = useState(0); const addOne = () => { - // write code here + setCount(currentCount => { + let copyCount = currentCount; + + copyCount += 1; + + return copyCount; + }); }; const add100 = () => { - // write code here + setCount(currentCount => { + let copyCount = currentCount; + + copyCount += 100; + + return copyCount; + }); }; // DON'T change the code below