Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript triangle project

Name: Conserned Citizen 2012-10-27 22:00

So I'm trying to write a JS that takes the sides of triangles and determines if they're real or not. It keeps fucking up though and I have NO idea why.
Code:
//Gather input
var side1 = prompt("Input the length of side A(Not the longest).");
var side2 = prompt("Input the length of side B(Not the longest).");
var side3 = prompt("Input the length of side C(Longest side).");
//Create triangle object
var triangle = new Object();
//Find out if the triangle is real
real = function() {
if (side1 + side2 <= side3 || side2 + side1 <= side3) {
triangle.real = "not real";
}
else{
triangle.real = "real";
}
};
//Call functions and display answer
real();
alert("The triangle is " + triangle.real + ".");

Name: Anonymous 2012-10-27 22:08

>>1
side1 + side2 <= side3 || side2 + side1 <= side3
This is my favorite. Maybe computers aren't for you.

Name: Conserned Citizen 2012-10-27 22:10

No, I knew that it doesn't make a difference but I thought I'd try to see if that fixed it for some reason. Obviously doesn't do shit.

Name: Anonymous 2012-10-27 22:28

prompt("Input the length of side A(Not the longest).")
prompt("Input the length of side B(Not the longest).")
prompt("Input the length of side C(Longest side).")
Why would you make the user deal with bullshit like this? This is bad behavior. What if multiple sides are the longest?

side1 + side2 <= side3 || side2 + side1 <= side3
...

triangle.real = "not real"
Bools?

Name: c 2012-10-27 22:34

>>4

Because I'm just developing this as a way to test my skills, I'm . I'm just trying to get better at this.

Yeah I know. In some weird logic from me staring at it too long I thought that would do something for whatever odd reason.

And I'm not using Bools because I'm printing that (see last line)

Name: Anonymous 2012-10-27 22:38

I don't see any code, but:
if (side1 + side2 <= side3 || side2 + side1 <= side3)
may be one of the funniest statements I have ever seen.
Do you know how addition works?

Name: Anonymous 2012-10-27 22:44

And I'm not using Bools because I'm printing that (see last line)
10: triangle.real = false;
13: triangle.real = true;
18: alert("The triangle is " + (triangle.real?"real":"not real") + ".");

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List