Quiz: Super Like

Super like should add 3 likes, but each click adds only 1. Click the line with the mistake.

import { useState } from "react";

export default function App() {
    const [likes, setLikes] = useState(0);

    function handleSuperLike() {
        setLikes((likes) => likes + 1);
        setLikes((likes) => likes + 1);
        setLikes(likes + 1);
    }

    return (
        <main>
            <h1>Lunar Cats</h1>
            <p className="likes">♥ {likes}</p>
            <button onClick={handleSuperLike}>Super like</button>
        </main>
    );
}

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

Back

7/13

Next