JavaScript Counter Project for beginners is made using HTML, CSS JavaScript.

Create a folder for your project and inside this folder create 3 files index.html, style.css and script.js and copy the code properly in each file.


					<!DOCTYPE html>
<html lang="en">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="style.css">
	<script type="text/javascript" src="script.js" defer=""></script>
	<div id="container">
		<div id="display" class="item">
		<button class="item" onclick="minus()">-</button>
		<button class="item" onclick="reset()">Reset</button>
		<button class="item" onclick="plus()">+</button>


	background-image: linear-gradient(65deg, #85FFBD 0%, #FFFB7D 100%);
	display: grid;
	grid-template-columns: auto auto auto;
	width: 400px;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;	position: absolute;	
	padding: 20px;
	grid-column: 1/ span 3;
	background-color: rgba(0,0,0,0.7);
	color: white;
	font-family: montserrat, lato, san-serif;
	height: 200px;
	line-height: 150px;
	padding: 20px;
	box-sizing: border-box;
	font-size: 28px;
	border: 1px solid rgba(0,0,0, 0.2);
	margin: 2px;
	font-family: montserrat, lato, san-serif;
	padding:0 5px;
	grid-column: 1 / 3;
	grid-column: 1/span 3;
	height: 150px
	margin: 0;
	box-sizing: border-box;
	border: 1px solid white;
	text-align: center;
	font-size: 32px;
	vertical-align: middle;
	height: 100%;
	width: 100%;


					let p = document.querySelector('p');
let n = 0;

function updateNumber() {
	return p.innerText = n;

function plus(){
	return updateNumber();

function minus(){
	if(n > 0)n--;
	return updateNumber();

function reset(){
	return updateNumber();

Leave a Reply

Your email address will not be published.