M2R5 practical | O level practical exam 2025 | Web designing and publishing | Codology World

Опубликовано: 23 Апрель 2026
на канале: Codology World
942
25

Solution to create a calculator using html and javascript :

// Javascript Coding
function add(){
var first=parseInt(document.getElementById("first").value);
var second=parseInt(document.getElementById("second").value);
var result=first+second; document.getElementById("r").innerHTML=result;
}
function sub(){
var first=Number(document.getElementById("first").value);
var second=Number(document.getElementById("second").value);
var result=first-second; document.getElementById("r").innerHTML=result;
}
function mult(){
var first=Number(document.getElementById("first").value);
var second=Number(document.getElementById("second").value);
var result=first*second; document.getElementById("r").innerHTML=result;
}
function div(){
var first=parseInt(document.getElementById("n1").value);
var second=parseInt(document.getElementById("n2").value);
var result=first/second; document.getElementById("r").innerHTML=result;
}

#javascript #calculator #codologyworld #htmltutorial #olevelexam #nielitolevel