Answers for "convert my if else method online to switch case"

2

js convert if/else statement to switch case

var gradeOut = 70;
var totalGrade = 80;

if (gradeOut >= 90)
    gradeOut+= "My letter grade is: A";
  else if (totalGrade < 90 && totalGrade >= 80)
    gradeOut+= "My letter grade is: B";
  else if (totalGrade < 80 && totalGrade >= 70)
    gradeOut+= "My letter grade is: C";
  else if (totalGrade < 70 && totalGrade >= 60)
    gradeOut+= "My letter grade is: D";
  else if (totalGrade < 60)
    gradeOut+= "My letter grade is: F";

//here's the same thing using switch(true). Requires var gradeOut (is currently at top of page
switch(true) {
case gradeOut<60:
    gradeOut= "My letter grade is: F";
    break;
case gradeOut<70:
    gradeOut= "My letter grade is: D";
    break;
case gradeOut<80:
    gradeOut="My letter grade is: C";
    break;
}
Posted by: Guest on November-27-2020
0

convert my if else method online to switch case

if (!password.equals(confirmPassword))
                {
                    binding.editConfirmPasswordSignUpUser.setError(getString(R.string.please_enter_your_confirm_password));
                    binding.editConfirmPasswordSignUpUser.requestFocus();
                    return;
                }
Posted by: Guest on August-26-2021
0

convert my if else method online to switch case

if (!password.equals(confirmPassword))
                {
                    binding.editConfirmPasswordSignUpUser.setError(getString(R.string.please_enter_your_confirm_password));
                    binding.editConfirmPasswordSignUpUser.requestFocus();
                    return;
                }
Posted by: Guest on August-26-2021

Code answers related to "convert my if else method online to switch case"

Code answers related to "Javascript"

Browse Popular Code Answers by Language