These are chat archives for FreeCodeCamp/Help

20th
May 2018
HoopsFTWGG
@HoopsFTWGG
May 20 2018 00:42
can anyone help me with a redux challenge ('send action data to the store')?
Kyle Holm
@thekholm80
May 20 2018 00:46
@HoopsFTWGG what have you tried?
HoopsFTWGG
@HoopsFTWGG
May 20 2018 00:49

`const ADD_NOTE = 'ADD_NOTE';

const notesReducer = (state = 'Initial State', action) => {
switch(action.type) {
// change code below this line
case ADD_NOTE:
return {text:action.text}
// change code above this line
default:
return state;
}
};

const addNoteText = (note) => {
// change code below this line
return {type: ADD_NOTE,
text: note}
// change code above this line
};

const store = Redux.createStore(notesReducer);

console.log(store.getState());
store.dispatch(addNoteText('Hello!'));
console.log(store.getState());`

well, the ` in gitter didn't form it properly for this window, so just ignore those flanking the entire code body
Kyle Holm
@thekholm80
May 20 2018 00:50
@HoopsFTWGG in your reducer's switch statement you should just return action.text
you don't need to return an object
HoopsFTWGG
@HoopsFTWGG
May 20 2018 00:50
ty
that works
Kyle Holm
@thekholm80
May 20 2018 00:50
:+1:
HoopsFTWGG
@HoopsFTWGG
May 20 2018 00:50
just wondering - why do we need to return objects in some cases and not in others
Kyle Holm
@thekholm80
May 20 2018 00:51
i suppose it depends on the specific use case
for example, your reducer needed 2 pieces of information from the action, type and text it's easier to stick these into an object than to pass 2 different values
the reducer only needed to return a single value, so it didn't really need to use an object
HoopsFTWGG
@HoopsFTWGG
May 20 2018 00:53
gotcha
Ken Haduch
@khaduch
May 20 2018 02:06
@HoopsFTWGG - isn't an object or array the only way to return multiple values in JavaScript? @thekholm80
Kyle Holm
@thekholm80
May 20 2018 02:07
@khaduch until the JS gods bestow tuples upon us
Ene Catalin
@EneCatalin
May 20 2018 03:43
@simpleguy747 no idea what that is. I am doing mobile myself though
PavanAkurathi
@PavanAkurathi
May 20 2018 03:59
Hello Everyone!. function intersection(arrays){
var arr = arrays.reduce(function(acc, nxt){
console.log(acc.length)
});
return arr;
}
console.log(intersection([[5, 10, 15, 20], [15, 88, 1, 5, 7], [1, 10, 15, 5, 20]]))
why cannot i find the index of values inside acc which is[5, 10, 15, 20]
even acc.length is undefined
Manish Giri
@Manish-Giri
May 20 2018 04:07
you need to return something from the reduce()
PavanAkurathi
@PavanAkurathi
May 20 2018 04:10
if i return acc output will be [5, 10, 15, 20], How can i access elements inside
Manish Giri
@Manish-Giri
May 20 2018 04:11
what are you trying to do?
PavanAkurathi
@PavanAkurathi
May 20 2018 04:12
i am trying to find the common elements of first array
output should be [5, 15]
Manish Giri
@Manish-Giri
May 20 2018 04:15
so find elements from first array which are also present in all the remaining arrays?
PavanAkurathi
@PavanAkurathi
May 20 2018 04:16
its nested array
yes
https://goo.gl/ABhHkW you can see here
Manish Giri
@Manish-Giri
May 20 2018 04:18
function intersection(arrays){
 return arrays[0].filter(e => arrays[1].includes(e) && arrays[2].includes(e));
}
PavanAkurathi
@PavanAkurathi
May 20 2018 04:19
i did using filter and traditional way. trying to figure out just using reduce
is it even possible ?
Manish Giri
@Manish-Giri
May 20 2018 04:19
as for why acc.length was undefined
run this
 function intersection(arrays){
    var arr = arrays.reduce(function(acc, nxt){
        console.log(acc, nxt);
        console.log("---");
    });
return arr;
}
the first time reduce() runs, acc and nxt are - [ 5, 10, 15, 20 ] [ 15, 88, 1, 5, 7 ]
respectively
but you don't return anything when this iteration finishes
so next time acc is undefined
and nxt is [ 1, 10, 15, 5, 20 ]
PavanAkurathi
@PavanAkurathi
May 20 2018 04:25
Thank you
Manish Giri
@Manish-Giri
May 20 2018 04:25
np
Ene Catalin
@EneCatalin
May 20 2018 09:37
fk that, ostrich knows the bestest tutorial
one that actually helped ostrich finally do a simple app
and remember java is not js. In simple terms, while JS does actually suck java is just great
the things above (there's also an advanced part you don't really need atm) have a lot of templates you can modify to do whatever
simpleguy747
@simpleguy747
May 20 2018 11:58
@EneCatalin @ndburrus Thanks for the cool links
CamperBot
@camperbot
May 20 2018 11:58
simpleguy747 sends brownie points to @enecatalin and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 457 | @enecatalin |http://www.freecodecamp.org/enecatalin
:star2: 2229 | @ndburrus |http://www.freecodecamp.org/ndburrus
Norvin Burrus
@ndburrus
May 20 2018 12:01
@simpleguy747 you're welcome! enjoy :palm_tree:
simpleguy747
@simpleguy747
May 20 2018 12:03
@EneCatalin JS does not suck, lot cool things to do with JS, now there is ES6 and things like type script in picture as well.
simpleguy747
@simpleguy747
May 20 2018 14:49
Has anyone used lightning design system? https://www.lightningdesignsystem.com/
HoopsFTWGG
@HoopsFTWGG
May 20 2018 20:32
has anyone tried the beta react/redux challenges today after the front-end redesign of the beta site? i think it's broken
mstellaluna
@mstellaluna
May 20 2018 20:40
@HoopsFTWGG are you referring to a challenge in particular ?
HoopsFTWGG
@HoopsFTWGG
May 20 2018 20:43
multiple challenges are giving me similar errors when they weren't yesterday
i
i'll give you an example
React and Redux - Manage State Locally First
received the following error:
Cannot read property 'rendered' of undefined

So I tried:
import ReactDOM from 'react-dom';

and received the another error:
require is not defined

so I went back to a few previous challenges that I had solved and plugged in my old solutions, only to have more errors or the tests to run indefinitely.
mstellaluna
@mstellaluna
May 20 2018 20:49
@HoopsFTWGG give me a few minutes to try it. if you load the console is any error showing up?
HoopsFTWGG
@HoopsFTWGG
May 20 2018 20:51
i can't run any tests now
in any of the challenges
i was able to about 10 minutes ago
mstellaluna
@mstellaluna
May 20 2018 20:52
you don't need to run any test, in the dev console on the challenge are any errors coming up?
HoopsFTWGG
@HoopsFTWGG
May 20 2018 20:53
they were previously, but now there's literally nothing
its as if the console and the preview pane are unresponsive to whatever i type in the code editor
ok restarted my browser, here are the errors
Uncaught (in promise) TypeError: Request scheme 'chrome-extension' is unsupported
at sw.js:279
Uncaught TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at Object.r [as subscribeToResult] (/commons-9e38eccf8ebde527da51.js:1)
at t.error (/commons-9e38eccf8ebde527da51.js:25)
at t.notifyError (/commons-9e38eccf8ebde527da51.js:1)
at t._error (/commons-9e38eccf8ebde527da51.js:74)
at t.error (/commons-9e38eccf8ebde527da51.js:1)
at t._error (/commons-9e38eccf8ebde527da51.js:1)
at t.error (/commons-9e38eccf8ebde527da51.js:1)
at t._error (/commons-9e38eccf8ebde527da51.js:8)
at t.error (/commons-9e38eccf8ebde527da51.js:1)
at t.notifyError (/commons-9e38eccf8ebde527da51.js:1)
mstellaluna
@mstellaluna
May 20 2018 20:57
@HoopsFTWGG im inquiring in the contributors room to see if anyone how is working on the update might know what's going on. normally i don't test the React/Redux sections
HoopsFTWGG
@HoopsFTWGG
May 20 2018 20:59
most of the challenges just give me the second error and not the first
mstellaluna
@mstellaluna
May 20 2018 21:15
@HoopsFTWGG the core-team requested to please open an issue on this repo https://github.com/freecodecamp/learn and provide as much detail as you can, they will investigate into it