Ad
Code
Diff
  • function getGrade (s1, s2, s3) {
      let avg = (s1 + s2 + s3) / 3;
      if (avg >= 90) {
        return "A"
      }
      
      if (avg >= 80) {
        return "B"
      }
      
      if (avg >= 70) {
        return "C"
      }
      
      if (avg >= 60) {
        return "D"
      }
      
      return "F";
    }
    • function getGrade (s1, s2, s3) {
    • let avg = (s1 + s2 + s3) / 3;
    • if (avg >= 90) {
    • return "A"
    • }
    • else if (avg >= 80) {
    • if (avg >= 80) {
    • return "B"
    • }
    • else if (avg >= 70) {
    • if (avg >= 70) {
    • return "C"
    • }
    • else if (avg >= 60) {
    • if (avg >= 60) {
    • return "D"
    • }
    • else {return "F"}
    • return "F";
    • }
Code
Diff
  • function removeSymbols(str) {
      let newStr = "";
      // list of possible symbols
      const symbols = "@#$%&=^*()-_=+<>/[]|?!,.£`".split("");
      // iterate through each characters in the input str, ignore character if it is a symbol
      for (const char of str){
        if (!symbols.includes(char)){
          newStr += char;
        }
      }
      // return new string with no symbols
      return (newStr);
    }
    • function removeSymbols(str) {
    • const regEx = /[&%!@=\*£]/g;
    • const newStr = str.replaceAll(regEx, "");
    • let newStr = "";
    • // list of possible symbols
    • const symbols = "@#$%&=^*()-_=+<>/[]|?!,.£`".split("");
    • // iterate through each characters in the input str, ignore character if it is a symbol
    • for (const char of str){
    • if (!symbols.includes(char)){
    • newStr += char;
    • }
    • }
    • // return new string with no symbols
    • return (newStr);
    • }