Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
thecodingaviator on master
remove A (#31157) (compare)
:cookie: 863 | @dancouper |http://www.freecodecamp.org/dancouper
arr.filter(value => value)
function rot13(str) { // LBH QVQ VG!
var numStr = str.split("").map(function (char) {
return String.fromCharCode(64 < char < 72 ? char.charCodeAt() % 26 + 65 : char);
});
return numStr;
}
(64 < char) < 72
which is testing true/false < 72
hello there, I have a web pack/ babel problem
my loaders:
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
},
Here is the error I am getting:
^CMacBook-Pro:redux-learn Owner$ npm run-script watch
> redux-learn@1.0.0 watch /Users/Owner/Dev/Test Dump/redux-learn
> webpack --watch
Webpack is watching the files…
(node:2086) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: e1004b9f03431443d6e6
Version: webpack 3.10.0
Time: 1232ms
Asset Size Chunks Chunk Names
main.bundle.js 3.4 kB 0 [emitted] main
main.bundle.js.map 2.46 kB 0 [emitted] main
[0] ./main.js 890 bytes {0} [built] [failed] [1 error]
ERROR in ./main.js
Module build failed: SyntaxError: Unexpected token (20:21)
18 | switch (action.type) {
19 | case "CHANGE_NAME": {
> 20 | state = {...state, name: action.payload};
| ^
21 | break;
22 | }
23 | case "CHANGE_AGE": {
hey everyone, I am trying to use filter, however, i want it to some times not filter anything. this is currently what i have
cards.filter(card=> card.type == "awards")
i have a variety of cards and sometimes i want filter to include all of the cards. how can I do that?
@ahmadabdolsaheb - without knowing all that you're doing, how about not calling the .filter
when you don't want to actually filter, or if you make a "control" variable like this:
let doAll = true;
cards = cards.filter(card=> card.type == "awards" || doAll );
So that you can set doAll
to the value you want (based on some condition) and then it would always pass the test? That's at least one take at it... You have to catch the return from the .filter
, so I just threw that in there...