let a; let b; let c; document.getElementById("submitButton").onclick = function(){ a = document.getElementById("aTextBox").value; a = Number(a); b = document.getElementById("bTextBox").value; b = Number(b); c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); document.getElementById("cLabel").innerHTML = "Side C: " + c; }
let a; let b; let c; a = window.prompt("Enter size a"); a = Number(a); b = window.prompt("Enter size b"); b = Number(b); c = Math.pow(a,2) + Math.pow(b,2); c = Math.sqrt(c); ________________________ OR let a; let b; let c; a = window.prompt("Enter side a"); a = Number(a); b = window.prompt("Enter side b"); b = Number(b); c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2)); console.log("Side C:", c); ________________________ Advanced Version of the Programme
Document
Side A: Side B: submit
******************************* let a; let b let c; /* a = window.prompt("Enter side A); a = Number(a); b = window.prompt("Enter side B); b = Number(b); c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2)); console.log("Side C:",c); */ document.getElementById("submitButton").onclick = function(){
a = document.getElementById("aTextBox").value; a = Number(a);
b = document.getElementById("bTextBox").value; b = Number(b); c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2)); document.getElementById("cLabel").innerHTML = "Side C:"+ c; }
Hello Bro! Another day of my JavaScript adventure with your videos... another day of giving the likes after every video. It goes sometimes a little too quick, but I am still learning new stuff and all the code works for me too, so... I am going further to the next video.
let base = Math.pow(window.prompt("Enter length of the base:"),2); let height= Math.pow(window.prompt("Enter the height of the triangle"),2); alert("The Hypotenuse of the Triangle is "+ Math.sqrt(base + height)); Just tried to put very less variables.
Uncaught TypeError: Cannot read properties of null (reading 'value') at document.getElementById.onclick (index.js:7:44) document.getElementById.onclick @ index.js:7 this is the error i get when i try to calculate. i thought i did something wrong but i copied your code and i still have this error can someone help?
let a;
let b;
let c;
document.getElementById("submitButton").onclick = function(){
a = document.getElementById("aTextBox").value;
a = Number(a);
b = document.getElementById("bTextBox").value;
b = Number(b);
c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
document.getElementById("cLabel").innerHTML = "Side C: " + c;
}
Document
Side A:
Side B:
submit
I think you should add something like:
If atextbox or btextbox is none then the clabel will print "you should fill all textbox"
let a;
let b;
let c;
a = window.prompt("Enter size a");
a = Number(a);
b = window.prompt("Enter size b");
b = Number(b);
c = Math.pow(a,2) + Math.pow(b,2);
c = Math.sqrt(c);
________________________
OR
let a;
let b;
let c;
a = window.prompt("Enter side a");
a = Number(a);
b = window.prompt("Enter side b");
b = Number(b);
c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
console.log("Side C:", c);
________________________
Advanced Version of the Programme
Document
Side A:
Side B:
submit
*******************************
let a;
let b
let c;
/*
a = window.prompt("Enter side A);
a = Number(a);
b = window.prompt("Enter side B);
b = Number(b);
c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
console.log("Side C:",c);
*/
document.getElementById("submitButton").onclick = function(){
a = document.getElementById("aTextBox").value;
a = Number(a);
b = document.getElementById("bTextBox").value;
b = Number(b);
c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
document.getElementById("cLabel").innerHTML = "Side C:"+ c;
}
You explain things with such clarity, essentially "documenting" by narrating, as you go.
This is super, thank you so much
I absolutely love you. You're amazing!
Hello Bro! Another day of my JavaScript adventure with your videos... another day of giving the likes after every video. It goes sometimes a little too quick, but I am still learning new stuff and all the code works for me too, so... I am going further to the next video.
Thanks BroCode it helps me a lot as first year college
I must to like this . This is very interesting.
// For the RUclips algorithm!
Perfect video 🎉!
let base = Math.pow(window.prompt("Enter length of the base:"),2);
let height= Math.pow(window.prompt("Enter the height of the triangle"),2);
alert("The Hypotenuse of the Triangle is "+ Math.sqrt(base + height));
Just tried to put very less variables.
Bro got me learning
perfect! thank you very much!
Great Job!
Thanks, Bro!
There is also a Math.hypot() function available in javascript
yes but that would defeat the purpose of the exercise
Thank you, Bro
Thanks!
Hy Bro Thank's
Nice
// comment down below
could you show how to do this but using a html textbox pls. thnx
Algo ritn
very random comment
based mega chad
Algorithm
Thank you Bro Code Happy to join Bro Code fam
Uncaught TypeError: Cannot read properties of null (reading 'value')
at document.getElementById.onclick (index.js:7:44)
document.getElementById.onclick @ index.js:7
this is the error i get when i try to calculate.
i thought i did something wrong but i copied your code and i still have this error can someone help?
in my case it was because in "Send" I missed "" at the end, your error may be due to an oversight.
Getting same issue anybody who has solved it?
Same issue please help
Remove type="button" from HTML file.
Just
may be see whether u given id or type for the button tag