Hi, this is my first post so be gentle, please! I noticed some weird typo’s on the topic “How to Use JavaScript Array.prototype.reduce() - Reduce Conceptual Boilerplate for Problems on Arrays” while working through the Javascript Algos certification. I think freeCodeCamp is an awesome platform, and I just want to make sure these typo’s won’t take away from the awesome work that contributor has done.
So the first typo is found in the createSlug()
function.
function createSlug(str){
return str.split(" ").reduce(function(prev, next){
return prev.concat(<a href='https://signalvnoise.com/posts/3124-give-it-five-minutes' target='_blank' rel='nofollow'>next.toLowerCase()]);
}, [])
.join("-");
}
This is clearly an error as vanilla JS doesn’t have JSX support, and it’s even the wrong syntax for React. This is the main structure of the typo’s found. For whatever reason I think the formatting is messing up. Another example:
var arr = <a href='http://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/' target='_blank' rel='nofollow'>10, 20, 30, 60];
arr.reduce(function(acc, item){
console.log(acc, item);
}, 0);
I’m thinking whatever code editor the contributor is using maybe transferring html <a>
tags, but I honestly have no clue. It seems to happen when they make an array variable and then use the []
syntax. It may be an issue with markdown but again I’m just completely guessing. There are several more examples farther down:
var arr = <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode' target='_blank' rel='nofollow'>10, 20, 30, 60];
arr.reduce(function(acc, item){
console.log(acc, item, this);
return acc;
}, 0);
var arr = <a href='https://en.wikipedia.org/wiki/Loop_invariant' target='_blank' rel='nofollow'>10, 20, 30, 60];
arr.reduce(function(acc, item){
console.log(acc, item, this);
return acc;
}.bind(arr), 0);
There may be more than this but I’m thinking you get the point. Thanks for reading!
-trufflepig