Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerRank Day 8: Create a Button 10 Days of javascript solution

YASH PAL, 31 July 2024

In this HackerRank Day 8: Create a Button 10 Days of javascript problem you need to Complete the code in the editor so that it creates a clickable button satisfying the following properties:

  1. The button’s id is btn.
  2. The button’s initial text label is 0. After each click, the button must increment by 1. Recall that the button’s text label is the JS object’s innerHTML property.
  3. The button has the following style properties:
  4. A width of 96px.
  5. A height of 48px.
  6. The font-size attribute is 24px.
HackerRank Day 8: Create a Button 10 Days of javascript solution

HackerRank Day 8: Create a Button 10 Days of javascript problem solution.

CSS file.

.btnClass {

    width: 96px;

    height: 48px;

    font-size: 24px;

}

JavaScript file

var btn = document.createElement(“Button”);

btn.innerHTML = “0”;

btn.id = “btn”;

btn.className = “btnClass”;

document.body.appendChild(btn);

btn.onclick = function() {

    btn.innerHTML+=2;

}

HTML file

<!– Enter your HTML code here –>

<!DOCTYPE html>

<html>

    <head>

        <meta charset=”utf-8″>

        <title>Button</title>

    </head>

    <body>

    </body>

</html>

10 day of javascript coding problems

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes