Javascript-Age in days challange-1 (Source code)

 

                                                                 JAVASCRIPT

         



function ageInDays(){
    var birthYear =  prompt("What year you born......... good friend");
    var ageInDays = (2020 - birthYear)* 365;
    var h1 = document.createElement("h1");
    var textAnswer = document.createTextNode('You are' + ageInDays + 'Days');
    h1.setAttribute('id''ageInDays');
    h1.appendChild(textAnswer);
    document.getElementById('result').appendChild(h1);

};
function reset(){
    document.getElementById('ageInDays').remove();
};

                                                  CSS


.btn-container{
    border2px solid black;
    displayflex;
    flex-directionrow;
    justify-contentspace-around;
}
.container-box-heading1{
    border2px solid black;
    justify-contentcenter;
    align-itemscenter;
    displayflex;
}
.result{
    border2px solid black;
    widthauto;
    height45px;}

.btn-container{
    padding20px;
}
.container_1{
    width75%;
    displayflex;
    flex-directioncolumn;
    align-contentcenter;
    margin-left12.5%;
}
.btn_primary button{
    background-colorrgb(2381616);
    colorrgb(245240240);
    width75px;
    height30px;
    border-radius3px;
    cursorpointer;
    font-size15px;
    bordernone;
}
.btn_danger button{
    background-colorrgb(6554223);
    colorrgb(245240240);
    width75px;
    height30px;
    border-radius3px;
    cursorpointer;
    font-size15px;
    bordernone;
}
.flexbox-result{
    
    widthauto;
    heightauto;
    border2px solid black;
    width75%;
    
}

                                                                   

                                                HTML


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/project1.css">
    <title>Document</title>
</head>
<body>
    <div class="container_1">
        <div class="container-box-heading1">
            <h1>Challange1:Your age in days</h1>
        </div>
        <div class="btn-container">
            <div class="btn_primary" onclick="ageInDays()"><button>Click me</button></div>
            <div class="btn_danger" onclick="reset()"><button>Reset</button></div>
            </div>
            <div id="result">
                 </div>
        </div>
    <script src="/js/project1.js"></script>
    <script>
    </script>
</body>

</html>

Comments

Popular posts from this blog

My Journey to first 50K on Freelancer.com as a Student Web Developer.