Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,018 members, 7,818,016 topics. Date: Sunday, 05 May 2024 at 04:35 AM

Can Someone Help Me Explain This Code Line? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Can Someone Help Me Explain This Code Line? (1276 Views)

I Am Bored, I Just Tried This Code / Please,Help Explain This Code In C / Java Programmers ,I Need Help Fixing This Code. (2) (3) (4)

(1) (Reply) (Go Down)

Can Someone Help Me Explain This Code Line? by BabyApple(m): 6:41pm On May 18, 2018
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Functions</h2>

<p>This example calls a function to convert from Fahrenheit to Celsius:</p>
<p id="demo"></p>

<script>
function toCelsius(f) {
return (5/9) * (f-32);
}
document.getElementById("demo"wink.innerHTML = toCelsius(77);
</script>

</body>
</html>
Re: Can Someone Help Me Explain This Code Line? by Wryhder: 11:33pm On May 18, 2018
Which part of it, the JavaScript?
Re: Can Someone Help Me Explain This Code Line? by D34lw4p(m): 1:29am On May 19, 2018
This is a JavaScript and HTML code. The JavaScript code has a function that converts temperature from Fahrenheit to Celsius then the result of the operation is inserted into the HTML page.

1 Like

Re: Can Someone Help Me Explain This Code Line? by BabyApple(m): 5:51am On May 19, 2018
i want detail explation on the javascript code. how do i do about it
Re: Can Someone Help Me Explain This Code Line? by mexzony: 10:14am On May 19, 2018
BabyApple:
i want detail explation on the javascript code. how do i do about it
Pick up a JavaScript book then.
Try JavaScript novice to ninja by Darren . Google it sha
The JavaScript part is just a simple function to convert temperatures.
The function is declared and then called and the result is put into a paragraph which we grab hold of with its given Id in this case called "demo".
The innerHTML is an inbuilt property used to insert text to html tags like the paragraph in this case .It can also be used to insert html elements by their tag.
Now go and study JavaScript.

1 Like

Re: Can Someone Help Me Explain This Code Line? by Yanumo(m): 6:32am On May 20, 2018
you have called your as an event into the function.

so you have to create an input field that carries that event (f). Then create a button that calls the function itself. so as to convert from Fahrenheit to Celsius.

But what your does basically is to convert from one degree to another. And displays the result in the p element.

(1) (Reply)

I Want To Build A Fintech Software - Who Do I Need Programmers Or Developers / Anonymous Functions/ Lambda Functions / Want To Learn How To Build Mobile Apps

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.