Day 8: Create a Button | 10 Days of JavaScript – Hacker Rank Solution

Day 8: Create a Button III | 10 Days of JavaScript – Hacker Rank Solution: Hey Guy’s In this post we are solving Day 8: Create a Button which is a part of 10 Days of JavaScript Series.

Day 8: Create a Button | 10 Days of JavaScript – Hacker Rank Solution

Objective

In this challenge, we practice creating buttons in JavaScript. Check out the attached tutorial for learning materials.

Task

Complete the code in the editor so that it creates a clickable button satisfying the following properties:

  • The button’s id is btn.
  • The button’s initial text label is . After each click, the button must increment by . Recall that the button’s text label is the JS object’s innerHTML property.
  • The button has the following style properties:
    • width of 96px.
    • height of 48px.
    • The font-size attribute is 24px.

Day 8: Create a Button | 10 Days of JavaScript – Hacker Rank Solution

var btn = document.getElementById("btn");
    btn.addEventListener("click", function(){
        var current_value = this.innerHTML;
        this.innerHTML  = parseInt(current_value)+1;
    });

Disclaimer: The above Problem (Day 8: Create a Button) is generated by Hackerrank but the Solution is Provided by Chase2Learn. This tutorial is only for Educational and Learning purposes. Authority if any of the queries regarding this post or website fill the following contact form thank you.

Leave a Comment