Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Goal Design a simple, visually pleasant, JavaScript-based \"app\" that performs

ID: 3902241 • Letter: G

Question

Goal Design a simple, visually pleasant, JavaScript-based "app" that performs a useful function, namely, unit conversion. Recommended Procedure: 1. Start from a working example, such as the 'temperature conversion code from https://github.com/dondi/javascript-book/tree/master/chapter02/temperature (also available on Bb, and reproduced below for your convenience). temperature.html: cmeta charset.UTF-8" ctitle JavaScript Temperature Convertere/title 6 chi Temperature Conversionc/h1 ep> 18 cinput types"text id"tesperature" /> cinput type "button id" to.c" value"F to C" cinput type- "button id"ctof value-"C to F > 12 13 14 15 ep id- result>X/> script srce temsperature.js"x/script 16

Explanation / Answer

temprature.html

<!DOCTYPE html>

<html>

<head>

<title>JavaScript Temprature Converter</title>

</head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>

<body class="container">

<h1>Temprature Converter</h1>

<form class="card">

<div class="form-group">

<input type="text" name="" id="temprature" class="form-control" placeholder="Enter temprature" pattern="[0-9]" required>

</div>

<div class="form-group">

<button type="button" name="" id="f_to_c" class="form-control btn btn-primary">F to C</button>

</div>

<div class="form-group">

<button type="button" name="" id="c_to_f" class="form-control btn btn-warning">C to F</button>

</div>

<div class="card-footer" id="result"></div>

</form>

<script type="text/javascript" src="temprature.js"></script>

</body>

</html>

temprature.js

var report=function(celsius,fahrenheit){

document.getElementById('result').innerHTML=(celsius>=-273)?celsius+" &degC <br>"+fahrenheit+" &degF":"Enter valid temprature";

};

function fToc(){

document.getElementById("f_to_c").onclick=function(){

var f=document.getElementById("temprature").value;

report((f-32)/1.8,f);

}

}

function cTof(){

var c=document.getElementById("temprature").value;

report(c,(1.8*c+32));

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote