// Good uses of the array methods, but your implementation of them aren't completely correct. // For example, the total is calculated using the passed in prices array, but as the spec says, // it should use calculate based off the positive prices only in the case that invalid prices are negative. // The spec says first cheap should get the first price under 20, not under 12. // The spec says invalid prices are < or = to 0, but you include 0s when filtering. // Also I'm sadly going to have to dock points since didn't include any comments explaining // why the array methods were used like the spec says. // Correct Use of Array Methods: 4/4 // Code Accuracy & Output: 1/3 // Cleanliness & Readability: 2/2 // Understanding & Comments: 0/1 // Grade: 7/10 const convertPrices = (prices: number[]) => { const positives = prices.filter((num: number) => num >= 0); const formatted = positives.map((num: number) => `$${num}`); const hasExpensive = prices.some((num: number) => num > 100); const total = prices.reduce( (runningTotal: number, num: number) => runningTotal + num, ); const firstCheap = positives.find((num: number) => num < 12); return { "formatted:": formatted, "hasExpensive:": hasExpensive, "total:": total, "firstCheap:": firstCheap, }; }; // Converting to letter grades works perfect! // All the other methods are implemented correctly except for the hasPerfectScore method, // It does technically work but the right syntax would be to use == or === instead of = which is an assignment operator. // I won't dock points for that since it still works, // but just be careful with that in the future since it can lead to bugs in your code if you accidentally use = instead of == or === in a condition. // Correct Use of Array Methods: 4/4 // Code Accuracy & Output: 3/3 // Cleanliness & Readability: 2/2 // Understanding & Comments: 0/1 // Grade: 9/10 const convertToGrades = (grades: number[]) => { const letterGrades = grades.map((num) => { if (num >= 90) return "A"; else if (num >= 80) return "B"; else if (num >= 70) return "C"; else if (num >= 60) return "D"; else return "F"; }); const highPerformers = grades.filter((num: number) => num >= 90); const firstFailing = grades.find((num) => num < 70); const average = grades.reduce((total: number, num: number) => total + num) / grades.length; const hasPerfectScore = grades.some((num) => (num = 100)); return { "letterGrades:": letterGrades, "highPerformers:": highPerformers, "firstFailing:": firstFailing, "average:": average, "hasPerfectScore:": hasPerfectScore, }; }; // Although it didn't effect the output, totalLikes should be calculated based off the published array instead of the original likes array // since the spec says to only calculate total likes based on the published posts which are the positive numbers in the array. // Other than that good job on this one! // Correct Use of Array Methods: 4/4 // Code Accuracy & Output: 2/3 // Cleanliness & Readability: 2/2 // Understanding & Comments: 0/1 // Grade: 8/10 const analyzeSocials = (likes: number[]) => { const published = likes.filter((num: number) => num > 0); const publishedStrings = published.map((num: number) => `${num} likes`); const totalLikes = likes.reduce((total: number, num: number) => total + num); const hasViral = likes.some((num) => num > 50); const firstPopular = likes.find((num) => num > 20); return { "publishedStrings:": publishedStrings, "totalLikes:": totalLikes, "hasViral:": hasViral, "firstPopular:": firstPopular, }; }; /////////////////////////////////////////////////////// Overall Grade: 24/30 --> 80% ///////////////////////////////////////////////////////