Day 2 "Calculator"

Hector·2023년 3월 24일
0

Vanilla JavaScript

목록 보기
2/14
<script>
function sum(a,b){
        return a+b;
    }
    function sub(a,b){
        return a-b;
    }
    function gob(a,b){
        return a*b;
    }
    function devide(a,b){
        return a/b;
    }
    function nam(a,b){
        return a%b;
    }
    function getType(data){
        return Object.prototype.toString.call(data).slice(8,-1)
    }
    function parseInt(str){
        return Number.parseInt(str)
    }
    let a = prompt('Please enter a Number.')
        if(isNaN(parseInt(a))){
            alert('no!')
        }
    let b = prompt('Please enter a Number.')
        if(isNaN(parseInt(a))||isNaN(parseInt(b))){
            alert('no!')
        }else{
            console.log(sum(a,b));
            console.log(sub(a,b));
            console.log(gob(a,b));
            console.log(devide(a,b));
            console.log(nam(a,b));
        }
</script>
profile
I`m Studying Bankend

0개의 댓글