Day 1: If Else Statements
-
[deleted] 9 years ago I started a GIT branch for those who need a little help let me know if you need explanations added as well https://github.com/giannioudis/7-Days-of-JavaScript
-
PRASHANTB1984 9 years ago This is really great! Thank you for sharing this repository.
-
[deleted] 9 years ago best way to learn I find, helping each other !
-
-
trendsetter37 9 years ago May I add to this as well in the form of a PR?
-
[deleted] 9 years ago Yes you can, day two will be up in the next hour or two! let me know if you need anything else
-
-
-
wingardc 9 years ago If you want to stick to the if-else if construction, it's very easy as long as you order your conditionals a certain way (the way they're presented in the problem statement).
if (marks > 90) console.log("AA"); else if (marks > 80) console.log("AB"); else if (marks > 70) console.log("BB"); else if (marks > 60) console.log("BC"); else if (marks > 50) console.log("CC"); else if (marks > 40) console.log("CD"); else if (marks > 30) console.log("DD"); else console.log("FF");
-
smartsammy787 9 years ago I was thinking of using switch case for this problem.
-
wingardc 9 years ago No problem with that if you know what it is and how to use it, but I suspect the "target audience" doesn't, or at least isn't expected to.
-
CSE180320280 3 years ago ur code is right
-
-
-
Soutrik 9 years ago g = ["AA","AB","BB","BC","CC","CD","DD","FF"];for(i = 0;i<8;i++){
if(i!=7){ if(marks>90-10*i){ console.log(g[i]); break; } }
else{ if(marks<=30){ console.log(g[7]); break; } }
}
-
momoaa792 4 months ago if(marks > 90){ console.log("AA") } else if(marks >80 <=90){ console.log("AB") } else if(marks >70 <=80){ console.log("BB") } else if(marks >60 <=70){ console.log("BC") } else if(marks >50 <=60){ console.log("CC") } else if(marks >40 <=50){ console.log("CD") } else if(marks >30 <=40){ console.log("DD") } if(marks <=30){ console.log("FF") }
-
ck5279533 4 months ago if (marks > 90) { console.log("AA"); } else if (marks > 80 && marks <= 90) { console.log("AB"); } else if (marks > 70 && marks <= 80) { console.log("BB"); } else if (marks > 60 && marks <= 70) { console.log("BC"); } else if (marks > 50 && marks <= 60) { console.log("CC"); } else if (marks > 40 && marks <= 50) { console.log("CD"); } else if (marks > 30 && marks <= 40) { console.log("DD"); } else { console.log("FF"); }
Sort 44 Discussions, By:
Please Log In in order to post a comment