Ad
Code
Diff
  • func gradeCalc(_ score: Int) -> String {
        (0...100~=score) ?  ["F","F","F","F","F","F","D","C","B","A","A"][score / 10] : "Not a grade"
    }
    
    
    
    • func gradeCalc(_ score: Int) -> String {
    • (score < 0 || score > 100) ? "Not a grade" : ["F","F","F","F","F","F","D","C","B","A","A"][score / 10];
    • }
    • (0...100~=score) ? ["F","F","F","F","F","F","D","C","B","A","A"][score / 10] : "Not a grade"
    • }
Fundamentals
Arrays
Data Types

The same stuff in one line, using reduce enstead of forEach.

Code
Diff
  • function findOnly(arr) {
      return arr.reduce((acc, cur) => acc ^ cur);
    }
    • function findOnly(arr) {
    • let result;
    • arr.forEach((i) => {
    • result = i ^ result;
    • });
    • return result;
    • return arr.reduce((acc, cur) => acc ^ cur);
    • }