Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • May 10 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 25 17:12
    @mstellaluna banned @cmal
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:09
    thecodingaviator commented #31179
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:07
    thecodingaviator commented #31182
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator commented #31190
  • Apr 01 18:05
    thecodingaviator commented #31157
  • Apr 01 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

  • Apr 01 18:04
    thecodingaviator closed #31157
  • Apr 01 18:04
    thecodingaviator closed #33788
  • Apr 01 18:04
    thecodingaviator commented #33788
  • Apr 01 18:02
    thecodingaviator closed #31059
  • Apr 01 18:02
    thecodingaviator commented #31059
Dan Couper
@DanCouper
i.e. a function that just returns the value you give it
Because
Filter already takes that value and converts it to true or false
mitchell369
@mitchell369
are you saying arr.fipt == arr.filter (value => value) ?
Markus Kiili
@Masd925
@mitchell369 arr.filter (value => value) filters in truthy array elements, the same as arr.filter (Boolean).
Dan Couper
@DanCouper
arr.fipt is me mistyping @mitchell369
mitchell369
@mitchell369
Good afternoon goyim. Can any of you good goys help me work of why my if statement is n't evaluating non-alpha characters in my code?

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;
}

I have passed through values like ' and it wants to assign them the samevalue as "A"
Stephen James
@sjames1958gm
@mitchell369 64 < char < 72 this is not valid syntax
@mitchell369 Well it is not testing what you want.
What you end up with is essentially (64 < char) < 72 which is testing true/false < 72
mitchell369
@mitchell369
@sjames1958gm ok, I can understand that as someone who wasn't completely hopelessin math
Unwana Essien
@afixoftrix

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": {
Stephen James
@sjames1958gm
@mitchell369 You need 64 < char && char < 72 to have two numeric comparisons
mitchell369
@mitchell369
@sjames1958gm so can I use a colon after the first evalution then see if it is <|> ?
ok, I don't havemuch experience with && but I will give that a go
Stephen James
@sjames1958gm
@mitchell369 Just read && as AND
Unwana Essien
@afixoftrix
I don't understand why it doesn’t understand spread operator.
mitchell369
@mitchell369
@sjames1958gm That completely destroy the output lol
Stephen James
@sjames1958gm
@mitchell369 char.charCodeAt() % 26 + 65 what is this trying to do?
Markus Kiili
@Masd925
@sjames1958gm Spread operator is ES6 (ES2015).
mitchell369
@mitchell369
@sjames1958gm Its evaluating the remainder when I pass it through 26 character alphabet, I found that is the most effective method to produce the A => N conversion and Z => M or w/e it is. Adding the 65 get's you back to the Ascii recognized coding for A-Z
Unwana Essien
@afixoftrix
@mitchell369 Ok I just added babel ‘stage-3’ presets and it worked.
Stephen James
@sjames1958gm
@Masd925 Odd, it appears that for some reason babel doesn't work for objects like above with just es2015 preset
Markus Kiili
@Masd925
@sjames1958gm Compatibility of spread also differs depending on where/how it is used.
Stephen James
@sjames1958gm
@mitchell369 Why is the second number 72? and not 91 (one more than Z
mitchell369
@mitchell369
@sjames1958gm right on, good start... should be 92
Stephen James
@sjames1958gm
@mitchell369 BTW, your 64 < char && char < 72 is comparing the string value char not the char code of char
mitchell369
@mitchell369
@sjames1958gm That's a good lead, basically what I see it doing is changing all values that fall below that range into 65 and providing me with the output
Stephen James
@sjames1958gm
@mitchell369 You need to make sure that the types in your variables match the types you are comparing
mitchell369
@mitchell369
@sjames1958gm specifying the the limits within the charCodeAt(), seems to return hex values...
Stephen James
@sjames1958gm
@mitchell369 Your algorithm is close. just that the comparison should be with charCode not char
var c = char.charCodeAt();
return String.fromCharCode(64 < c && c < 91 ? c % 26 + 65 : c);
Ahmad Abdolsaheb
@ahmadabdolsaheb

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?

Ken Haduch
@khaduch

@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...

Ahmad Abdolsaheb
@ahmadabdolsaheb
@khaduch so cards.filter(card=> card.type == true ); does not seem to return all items.
i tried it in js fiddle
array = [1,2,3,5]; console.log(array.filter(num => num == true)); only returns one
Markus Kiili
@Masd925
@ahmadabdolsaheb What are you trying to do? Why use abstract equality == (which nobody remember how it works really).
Ahmad Abdolsaheb
@ahmadabdolsaheb
@Masd925 i have cards with different types. i wanna show a specific card type when a relevant button is pressed. but, sometime, i wanna show all cards.
i am trying to use filter not to filter :)
cards.filter(card=> card.type == "awards")
what should I use instead of "awards and includes everything
or
cards.filter(card=> card.type === "awards")
Markus Kiili
@Masd925
@ahmadabdolsaheb There is no value that would be equal to all strings. cards.filter(card => true) would keep all elements.
cards.filter(card => card.type) would also keep all cards provided that types are non-empty strings.
@ahmadabdolsaheb I think that changing the logic as @khaduch said is best.
Ahmad Abdolsaheb
@ahmadabdolsaheb
@Masd925 @khaduch i think i will change logic since making a control variable didn't work. thanks
CamperBot
@camperbot
ahmadabdolsaheb sends brownie points to @masd925 and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3677 | @khaduch |http://www.freecodecamp.org/khaduch
:star2: 4653 | @masd925 |http://www.freecodecamp.org/masd925