These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Nov 2017
Christopher Brown
@ChrisBrownie55
Nov 09 2017 01:04
@RoniqueRicketts where did you get the offers from??
Ronique Ricketts
@RoniqueRicketts
Nov 09 2017 01:05
@ChrisBrownie55 people at my work. one of the manager and a regular guy at work
AbrisM
@AbrisM
Nov 09 2017 01:12
Does anyone know how to use an ArrayList in Java?
I know this is Javascript but the BackEnd channel is dead right now
Bryan Reese
@breese8009
Nov 09 2017 01:13
im guessing you could google "array list in java" and you would get a whole bunch of examples an explanations @AbrisM
isnt it the same w both java and javascript
?
AbrisM
@AbrisM
Nov 09 2017 01:15
Its similiar
There's a specific part i'm looking for though
The program should remain in sorted order of the key
HandsOmeac
@HandsOmeac
Nov 09 2017 02:09
anybody online?
korzo
@korzo
Nov 09 2017 02:09
@HandsOmeac sure
HandsOmeac
@HandsOmeac
Nov 09 2017 02:10
need your help
How to use fuction to build a sentence?
korzo
@korzo
Nov 09 2017 02:12
@HandsOmeac is this FCC challenge ?
what's the name?
HandsOmeac
@HandsOmeac
Nov 09 2017 02:12
yes
word blanks
korzo
@korzo
Nov 09 2017 02:14
@HandsOmeac
use + to join words and " " to insert space.
then return result
" " + myAdjective + " " ...
HandsOmeac
@HandsOmeac
Nov 09 2017 02:15
wait a sec. i'll try
i can't work it out
korzo
@korzo
Nov 09 2017 02:20
post your code
HandsOmeac
@HandsOmeac
Nov 09 2017 02:21

function wordBlanks(myAdjective,myNoun , myVerb, myAdverb) {
var result = "myAdjective+myNoun+myVerb+myAdverb";
return result;
}

wordBlanks("dog", "The big brown", "just ran", "quickly");

korzo
@korzo
Nov 09 2017 02:21
function wordBlanks(myAdjective,myNoun , myVerb, myAdverb) {
var result = "myAdjective+myNoun+myVerb+myAdverb";
return result;
}
wordBlanks("dog", "The big brown", "just ran", "quickly");
HandsOmeac
@HandsOmeac
Nov 09 2017 02:22
am i wrong?
korzo
@korzo
Nov 09 2017 02:22
@HandsOmeac you wrapped all inside "", so it will return myAdjective+myNoun+myVerb+myAdverb
@HandsOmeac var result = myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;
HandsOmeac
@HandsOmeac
Nov 09 2017 02:23
I SEE
thx
very much
korzo
@korzo
Nov 09 2017 02:27
@HandsOmeac glad to help
Joe Westcott
@joe-westcott
Nov 09 2017 04:06
Hi, anyone pass the FCC Javascript "Stand in Line" challenge?
..and have some advice to dispense? :)
heroiczero
@heroiczero
Nov 09 2017 04:09
@joe-westcott so what are you trying to do?
Joe Westcott
@joe-westcott
Nov 09 2017 04:11
Hi @heroiczero , I can't figure out why I keep getting an error that "arr.shift is not a function"

This is the function I wrote, to add a new number to the back of the array, then remove and return the first number of the array:

function nextInLine(arr, item) {
// Your code here
arr = arr.push(item);
var firstElement = arr.shift();
return firstElement; // Change this line
}

heroiczero
@heroiczero
Nov 09 2017 04:12
@joe-westcott you do not need to set arr to arr.push(item).
Joe Westcott
@joe-westcott
Nov 09 2017 04:12
ohhh....
heroiczero
@heroiczero
Nov 09 2017 04:12
@joe-westcott when you arr.push(item); it adds it to the array.
Joe Westcott
@joe-westcott
Nov 09 2017 04:14

Thank you. ... Hmm, maybe I'm doing more than one thing wrong. Still getting an error, but slightly different now.

Here's the new function:

function nextInLine(arr, item) {
arr.push(item);
var firstElement = arr.shift();
return firstElement;
}

And here's the new error:

"logOutput.push is not a function"

heroiczero
@heroiczero
Nov 09 2017 04:19
@joe-westcott hmm did you try refreshing. It is passing for me
Joe Westcott
@joe-westcott
Nov 09 2017 04:20
Refreshing worked. (facepalm)
Thanks so much, @heroiczero ! I was so stumped without your help.
CamperBot
@camperbot
Nov 09 2017 04:21
joe-westcott sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2043 | @heroiczero |http://www.freecodecamp.com/heroiczero
heroiczero
@heroiczero
Nov 09 2017 04:21
glad it worked for you :) :+1:
Joe Westcott
@joe-westcott
Nov 09 2017 04:22
Oh my goodness you rock. This one was maddening. :)
heroiczero
@heroiczero
Nov 09 2017 04:22
yeah but you almost got it. It was just a simple mistake :)
Nehemiah Kivelevitz
@NehemiahK
Nov 09 2017 08:19
hey. anyone up?
Markus Kiili
@Masd925
Nov 09 2017 08:20
@NehemiahK Sure. Just post if you have question(s).
Nehemiah Kivelevitz
@NehemiahK
Nov 09 2017 08:20
thanks
var caps = /\[A-Z]/g ;
if (str.charAt(i)== caps)
can i do that?
Markus Kiili
@Masd925
Nov 09 2017 08:21
@NehemiahK That compares a string to an regexp object, so no.
Nehemiah Kivelevitz
@NehemiahK
Nov 09 2017 08:21
yeah. figured.
=(
I'm working on the spinal tap algo.
I can't seem to figure out how to separate words that are meshed together with a capital letter in between
@Masd925 any advice?
korzo
@korzo
Nov 09 2017 08:29
@NehemiahK str.charAt(i) === str.charAt(i).toUpperCase()
Nehemiah Kivelevitz
@NehemiahK
Nov 09 2017 08:30
oh right. duh
thanks
i was thinking though can i use regex w/ replace to replace a match with the matched expression?
like this
 var caps = /\[A-Z]/g ;
  str =str.replace(caps, '-' + matched expression);
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 08:39
gm everyone
Nehemiah Kivelevitz
@NehemiahK
Nov 09 2017 09:45
hey
Dan Couper
@DanCouper
Nov 09 2017 10:25
Ankur sharma
@ankur1163
Nov 09 2017 11:13
can someone help me out
i get this error
./src/index.js
Module not found: Can't resolve './reducers' in '/Users/ankursharma/Documents/projects/meetupz/client_src/src'
Stephen James
@sjames1958gm
Nov 09 2017 11:15
@ankur1163 Do you have a reducers .js file in the same directory as index.js?
no
Stephen James
@sjames1958gm
Nov 09 2017 11:16
@ankur1163 Ah you are importing the directory, which appears to be '../reducers'
Ankur sharma
@ankur1163
Nov 09 2017 11:16
yeah
let me check
@sjames1958gm i added ../
now it tells me
./src/index.js
Module not found: You attempted to import ../reducers which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/.
import reducers from '../reducers';
import ReduxPromise from 'redux-promise';
Ankur sharma
@ankur1163
Nov 09 2017 11:27
i think i solved it
error was i was doing
export default reducer
but while importing
i was using
import reducers....
looks like it worked
thanks @sjames1958gm for trying
CamperBot
@camperbot
Nov 09 2017 11:27
ankur1163 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8685 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 09 2017 11:28
It looks like it is also telling you to move reducers directory into the src/ directory
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 12:11
anyone here got the trading book app working?the example one is broken
Diego Mayer
@Chrono79
Nov 09 2017 14:01
@NehemiahK the backslash before the bracket is escaping it in your regex
Nehemiah Kivelevitz
@NehemiahK
Nov 09 2017 14:09
lol. i just looked at how other people solved the binary challenge and now i feel silly
function binaryAgent(str) {

  var binary = str.split(' '); // split the code into an array to make it easier to loop

  var newStr = ""; // empty string to store final result



  for (var i=0; i<binary.length; i++){ // loop through the inputs

    var count = 0; // this will store the charcode 

    /*
    The binary is 128 bits/bytes? meaning. if there is a 0. it has no value. if it is a 1 it has that value. 00000001 would be eqaul to 1. 00000010 would have the value of two. 
    if the value is a 1 and you multiply by its number it will return that number, which is good because thats the value we want. if there is a 0 there, that means we don't want to add that value. which is good because multiplying it will give us 0 as well. 

    */

  count += binary[i][0]*128; 
  count += binary[i][1]*64;
  count += binary[i][2]*32;
  count += binary[i][3]*16;
  count += binary[i][4]*8;
  count += binary[i][5]*4;
  count += binary[i][6]*2;
  count += binary[i][7]*1;

    newStr += String.fromCharCode(count); // add the char value for the number 

  }

  return newStr;

}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
Diego Mayer
@Chrono79
Nov 09 2017 14:12
This message was deleted
It works, your code could almost always be improved in some way or another
mrjerem
@mrjerem
Nov 09 2017 14:22
Okay now Im here got this 'Error: listen EADDRINUSE :::3000
'
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 14:24
can I see how you tell your express to listen for the port?
mrjerem
@mrjerem
Nov 09 2017 14:26
@tiagocorreiaalmeida
//connects to MongoDB
mongoose.connect('mongodb://localhost/nodekb',{
  useMongoClient: true,
});
let db = mongoose.connection;
@tiagocorreiaalmeida
pp.set('port', 3000);

var server = app.listen(app.get('port'), function() {
  var port = server.address().port;
  console.log('Magic happens on port ' + port);
});
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 14:28
before telling anything may I know what you are doing?
creating in this case
mrjerem
@mrjerem
Nov 09 2017 14:30
@tiagocorreiaalmeida Im just doing a practice site that will post articles to mongoDB and fetch them back I have a POST function operationg correctly
now I have this again that only gets the first one from collection and also does not seem to return as the page just keep loading
app.get('/articles/add', function(req, res){
  res.render('add_article',{
    title:'Add article'
  });
});
wrong code sry
app.get('/article/:id', function(req, res){
  Article.findOne(req.param.id, function(err, article){
    console.log(article);
    return;
  });
});
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 14:36
the configuration you have above to listen to the port looks confusing to me and dont think will ever work anyway
try this
app.listen('3000',function(){
 console.log("Running on port 3000");
});
mrjerem
@mrjerem
Nov 09 2017 14:38
I got it to work ... seems I missed a 's' from req.params.id
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 14:38
req.param
y6eah :D
nice to hear that it worked
didnt saw the typo neither
alpox
@alpox
Nov 09 2017 14:38
:thumbsup: :eyes:
mrjerem
@mrjerem
Nov 09 2017 14:38
Always so simple things...
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 14:39
the biggest eyes on the business(alpox) is here now @mrjerem so if you run into similiar problems they will be solved now :D
alpox
@alpox
Nov 09 2017 14:39
@tiagocorreiaalmeida I guess i would have overseen that one :D
Typos are nasty
mrjerem
@mrjerem
Nov 09 2017 14:40
Yes nasty typos
And also in most cases you read them right as you know what there should be so you won't notice it.
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 15:14
so how's everything @alpox ?
alpox
@alpox
Nov 09 2017 15:14
@tiagocorreiaalmeida Hmm a bit stressed from a task i have to do but i should manage :D
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 15:15
may I know what is it?programming related right?
Albert Cardona II
@daddycardona
Nov 09 2017 15:17
@mrjerem it's always the little things lol
alpox
@alpox
Nov 09 2017 15:58
@tiagocorreiaalmeida Not really :D i have to write a 4-page essay about a topic in the field "Social Capital and Innovation" and it has to be fully scientific - a paper so to say. This means i have to do literature research, fully right citation, formally right structure etc. etc.
Kaz Baig
@kbaig
Nov 09 2017 16:00
God bless dude
So glad I didn't have to do things like that in my studies
alpox
@alpox
Nov 09 2017 16:01
@kbaig You can be :D its a pain. And i have time only until sunday evening
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 16:01
@alpox starts walking slowly backwards
alpox
@alpox
Nov 09 2017 16:02
@tiagocorreiaalmeida :laughing:
Nazar
@IsaakNazar
Nov 09 2017 16:07
hey guys, whats wrong with the code ?
function truthCheck(collection, pre) {
  // Is everyone being true?
  for(var i = 0; i<collection.length; i++){
    if (collection[i][pre]) {
      return true;
    }
    return false;
  }

}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 16:11
returns will stop the function
can't remember the exercise but im pretty sure its about checking if all them contain the sex proprety no?
Nazar
@IsaakNazar
Nov 09 2017 16:12
Check if the predicate (second argument) is truthy on all elements of a collection (first argument).

Remember, you can access object properties through either dot notation or [] notation.
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 16:12
the returbn statement above will stop the the function and this case ofcourse the loop after the first return
based on yoru code there's a simpel solution
check only for a not truthy statement and there return false this way you will be sure the whole loop run if everything is ttrue
plus outside the loop just return true for the cases taht everything is true
Nazar
@IsaakNazar
Nov 09 2017 16:15
@tiagocorreiaalmeida You are amazing thx
CamperBot
@camperbot
Nov 09 2017 16:15
isaaknazar sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 435 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 16:25
finally some brownies for lunch break
anytime :D
Ronique Ricketts
@RoniqueRicketts
Nov 09 2017 16:27
weirdo :)
Emmanuel Akodia
@akodiaemma
Nov 09 2017 16:49
http://mapenzi.ug/project/absolut-electrik-nights/index.html . the divs are not responding to my css and yet in another directory http://mapenzi.ug/project/heineken-house/index.html they are
please let someone help me
wherre have all the kind hearts gone to
Christopher McCormack
@cmccormack
Nov 09 2017 16:53
@akodiaemma Can you be more descriptive in your question? 'the divs' doesn't help us understand what YOU are trying to do
Emmanuel Akodia
@akodiaemma
Nov 09 2017 16:54
its okay figured it out. Thank you @cmccormack
CamperBot
@camperbot
Nov 09 2017 16:54
akodiaemma sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1267 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Nov 09 2017 16:55
@akodiaemma :thumbsup:
Jason Luboff
@JLuboff
Nov 09 2017 16:55
@cmccormack Good work!
Christopher McCormack
@cmccormack
Nov 09 2017 16:55
I do what I can
Jason Luboff
@JLuboff
Nov 09 2017 17:04
@cmccormack I'm going to do it. I'm actually going to work on my pinterest clone today. (I'm psyching myself up)
Christopher McCormack
@cmccormack
Nov 09 2017 17:05
Nice! can you clone another project and just rework it into a pinterest clone?
Jason Luboff
@JLuboff
Nov 09 2017 17:05
....can't tell if joking or actually serious...
Christopher McCormack
@cmccormack
Nov 09 2017 17:05
I'm dead serious can't you tell?
Jason Luboff
@JLuboff
Nov 09 2017 17:05
:(
but uh... ya... there's bits and pieces I can use from previous projects..but not a full clone
Christopher McCormack
@cmccormack
Nov 09 2017 17:06
yeah good start at least
I still haven't started my voting app, not sure where I want to start
But I bet having one down should help with the next immensely
Jason Luboff
@JLuboff
Nov 09 2017 17:07
I'd start with authentication!
Christopher McCormack
@cmccormack
Nov 09 2017 17:08
Been reading up on passport, seems pretty great
Jason Luboff
@JLuboff
Nov 09 2017 17:09
Ya works great
Christopher McCormack
@cmccormack
Nov 09 2017 17:12
Maybe I'll start today - your motivation will become mine!
Jason Luboff
@JLuboff
Nov 09 2017 17:14
:+1:
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 17:26
so im going to design and write the entire html/css of the booking trade app, if you wanan send some motivation :DDDDD
Christopher McCormack
@cmccormack
Nov 09 2017 17:29
@tiagocorreiaalmeida :moneybag: :moneybag: :moneybag:
Stephen James
@sjames1958gm
Nov 09 2017 17:31
@tiagocorreiaalmeida :cake:
alpox
@alpox
Nov 09 2017 17:32
@tiagocorreiaalmeida :+1: :+1: :+1: :+1:
Bryan Reese
@breese8009
Nov 09 2017 17:32
hello js'ers
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 17:33
I could take the cake tough
hey @breese8009
Jason Luboff
@JLuboff
Nov 09 2017 17:34
I've used bootstrap or bulma for all my backend projects. I'm too lazy to code my css lol
Christopher McCormack
@cmccormack
Nov 09 2017 17:36
I've been using materialize css a lot lately, just for fun
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 17:37
@JLuboff my issues its atually the about design and getting ideas for it when only wanted to do the css and not the design part, but since soon I will aim try to aim for a job might be better show something else other than just bootstrap
well its a good oportunity to write so scss since I have nothing on it to show yet
Jason Luboff
@JLuboff
Nov 09 2017 17:37
@tiagocorreiaalmeida Oh absolutely. I just don't have the want/need to learn that at the current moment
@cmccormack Taking a look..maybe I'll try it out if I like it
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 17:38
anyway have you watched the 4 week of mongodb @cmccormack ? the exercices were a bit confusing but I think it was a great explanation on how to behave with mongodb data in certain situations
Christopher McCormack
@cmccormack
Nov 09 2017 17:39
@tiagocorreiaalmeida yeah just finished it
first problem was weird but got it on the third try
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 17:40
yeah, was the kind of videos that might save your life one day when you build something bigger than we do now on fcc projects
Christopher McCormack
@cmccormack
Nov 09 2017 17:42
I think the videos were too short and didn't really provide enough information nor good enough examples
too much glossing over concepts
Tiago Correia
@tiagocorreiaalmeida
Nov 09 2017 18:21
Yeah but explained how to behave in some situations and how you shoulf store it in a good way
Helenbella
@Helenbella
Nov 09 2017 18:26
unction golfScore(par, strokes) {
// Only change code below this line
if(1) {
return"Hole-in-one!";
}if (<=1 , -2){
return"Eagle";
}if (1,-1){
return"Birdie";
}if (par){
return"Par";
}if (1, +1){
return"Bogey";
}if(1, +2){
return"Double Bogey";
}if(1,+3){
return"Go Home!";
}
Jason Luboff
@JLuboff
Nov 09 2017 18:27
@Helenbella Your if conditions make no sense. If what is 1? If what is <= 1?
I'd advise revisiting the if and if/else exercises
Bryan Reese
@breese8009
Nov 09 2017 18:36
@JLuboff sup G!?!?!
Jason Luboff
@JLuboff
Nov 09 2017 18:37
@breese8009 Just living the dream...aka working. You?
Bryan Reese
@breese8009
Nov 09 2017 18:37
@JLuboff same lol
living da dreamzzz
Jason Luboff
@JLuboff
Nov 09 2017 18:38
:+1:
What do you do for work?
Bryan Reese
@breese8009
Nov 09 2017 18:39
@JLuboff im an intern front end starting monday, just finished up bc
Jason Luboff
@JLuboff
Nov 09 2017 18:40
Nice!
Bryan Reese
@breese8009
Nov 09 2017 18:40
pay not so great
25 hr
Jason Luboff
@JLuboff
Nov 09 2017 18:40
At a company I would know? I know you're up in near silicon valley
$25/hr is not bad though...but not great for the area
Bryan Reese
@breese8009
Nov 09 2017 18:41
no its omt.tech
Jason Luboff
@JLuboff
Nov 09 2017 18:41
Ya, never heard of them heh
Bryan Reese
@breese8009
Nov 09 2017 18:41
only 19 employees
small small company
@JLuboff have u started react yet?
Jason Luboff
@JLuboff
Nov 09 2017 18:46
No not yet
Christopher McCormack
@cmccormack
Nov 09 2017 18:58
@JLuboff slacker
Jason Luboff
@JLuboff
Nov 09 2017 18:59
@cmccormack Says the one who was just on facebook updating their profile image instead of working ;)
@cmccormack But I'll say that cover photo is dope
Christopher McCormack
@cmccormack
Nov 09 2017 19:02
Haha It's lunch time homie, I'll browse FB if I please!
Jason Luboff
@JLuboff
Nov 09 2017 19:02
< 11 AM lunch time? hmmm
Christopher McCormack
@cmccormack
Nov 09 2017 19:02
@JLuboff and thanks - I love those super high HDR photos
CamperBot
@camperbot
Nov 09 2017 19:02
cmccormack sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2257 | @jluboff |http://www.freecodecamp.com/jluboff
Christopher McCormack
@cmccormack
Nov 09 2017 19:03
Noon now, you guys fell back or whatever with your weird time changing clocks
Jason Luboff
@JLuboff
Nov 09 2017 19:03
Oh I forgot that you guys don't change time. You're lucky
DST is bullshit
Christopher McCormack
@cmccormack
Nov 09 2017 19:04
Sucks for us too because we're about the only people that have to actually keep track of what season it is when scheduling national and international meetings
For you, NY is always the same number of hours away. I have to repeat that stupid 'spring forward fall back' line and also how it works for us haha
Jason Luboff
@JLuboff
Nov 09 2017 19:05
Oh ya...that sucks
Christopher McCormack
@cmccormack
Nov 09 2017 19:05
they should just get rid of DST as a whole, everyone would be happier
Jason Luboff
@JLuboff
Nov 09 2017 19:06
I agree
Bryan Reese
@breese8009
Nov 09 2017 19:11
@JLuboff when u learn some react, try to implement it with passport... it bothers me that i had to switch to okta because i couldnt figure out passport with react but i got the password hashed, sessions working, and auth working on postman..... but i donno how to deal with what i got and make it work with react. I thought it would be as easy as just making the request to the routes but its not.
Jason Luboff
@JLuboff
Nov 09 2017 19:13
@breese8009 Will do. I'll be starting that stuff after I finish my last backend project
Bryan Reese
@breese8009
Nov 09 2017 19:13
@JLuboff when u did ur passport project did u have a separate model for ur login?
Christopher McCormack
@cmccormack
Nov 09 2017 19:14
@breese8009 hey man not sure if you saw my response to that yesterday - React is frontend- passport is not, as far as I'm aware - in your React app you can just call your own api to use the passport features
Jason Luboff
@JLuboff
Nov 09 2017 19:14
@breese8009 No, I used vanilla mongo so no models with that. Mongoose uses models, and you would have it seperate
Bryan Reese
@breese8009
Nov 09 2017 19:15
@cmccormack i didnt see this.... ohhh so it should be as easy as making the request?
but what about redirecting?
Christopher McCormack
@cmccormack
Nov 09 2017 19:15
use the response from your api request to determine your component response
like if login fails display login component, else home component, or whatever
This is fairly long but shows an example - https://vladimirponomarev.com/blog/authentication-in-react-apps-jwt
Bryan Reese
@breese8009
Nov 09 2017 19:16
I would write this logic in my front end?
Christopher McCormack
@cmccormack
Nov 09 2017 19:18
You'd write the passport stuff on the backend, and use xmlhttprequest in whatever form you want from React
So you'd have your post route for authentication that you call with a post request from React
just like using any other api with react, just in this case you created the api as well
Bryan Reese
@breese8009
Nov 09 2017 19:20
It seems in that link they did alot of other stuff in react to make it work
Christopher McCormack
@cmccormack
Nov 09 2017 19:21
Just to note - I've not done any of this myself, but I've been thinking a lot about it and researching prior to starting my web app projects as I wanted to use React as well
Bryan Reese
@breese8009
Nov 09 2017 19:21
more then just an api call
@cmccormack u should do it and make a tutorial lol
Jason Luboff
@JLuboff
Nov 09 2017 19:21
I'll most likely convert my web apps to react after the fact
Christopher McCormack
@cmccormack
Nov 09 2017 19:22
I'm not sure what you mean - there is some backend setup but that will be required if you want your own login system
It's using local login so there are additional steps added
@JLuboff that should be a fun exercise
@JLuboff react router can handle all the routing stuff and you can just use node for setting up the backend calls you need
Jason Luboff
@JLuboff
Nov 09 2017 19:23
Ya sure I'll act like I know what you're saying :P
Christopher McCormack
@cmccormack
Nov 09 2017 19:24
React router is pretty similar to setting up your paths in node, you setup the path string and respond to it somehow
but it's all frontend
Jason Luboff
@JLuboff
Nov 09 2017 19:24
Ah, ya that should be fairly straightforward
Christopher McCormack
@cmccormack
Nov 09 2017 19:24
and possibly magic
Jason Luboff
@JLuboff
Nov 09 2017 19:27
I hate creating navbars..
Isaiah Trembley
@IsaiahCT
Nov 09 2017 19:27
lmao
I got a navbar
Christopher McCormack
@cmccormack
Nov 09 2017 19:27
What boggles my mind is how you can enter a path like https://somesite.com/reactapp/path1/path2 and as long as you have your reactapp in the reactapp path it can load path1/path2
@JLuboff use bootstrap?
Jason Luboff
@JLuboff
Nov 09 2017 19:28
Ya I'm using bootstrap
Isaiah Trembley
@IsaiahCT
Nov 09 2017 19:28
you don't need bootstrap
Jason Luboff
@JLuboff
Nov 09 2017 19:28
I'm just being lazy about it
I know I don't need bootstrap
if you want use it
Christopher McCormack
@cmccormack
Nov 09 2017 19:28
Noone NEEDS bootstrap, but why would you want to deal with viewport changes and all that if you don't have to
Isaiah Trembley
@IsaiahCT
Nov 09 2017 19:28
I don't care, I am just here
I don't really care if I am hoenst, my code doesn't really get seen
so I am just going to learn js and vg
svg
Jason Luboff
@JLuboff
Nov 09 2017 19:29
Actually... I think I'm going to go with the side nav like I did for my game trader, liked that better
Isaiah Trembley
@IsaiahCT
Nov 09 2017 19:29
what evs
Christopher McCormack
@cmccormack
Nov 09 2017 19:31
@JLuboff the sidenav in materialize css is really easy to implement and setup the toggle - https://codepen.io/cmccormack/pen/dVGZBx?editors=1100
Jason Luboff
@JLuboff
Nov 09 2017 19:31
@cmccormack Looks nice. Think I'm just going to stick with this: https://gametrader.glitch.me/
Christopher McCormack
@cmccormack
Nov 09 2017 19:32
not going to make it responsive?
Looks nice though
Jason Luboff
@JLuboff
Nov 09 2017 19:34
Eh...Maybe pinterest I will. Not sure. Really just want to get it done you know?
But it wouldn't take much time to go back and make that one responsive. Just need to add the proper classes
Christopher McCormack
@cmccormack
Nov 09 2017 19:40
@JLuboff I didn't realize it but your sidenav is responsive, just didn't notice it because the text looked the same in the small view.
Jason Luboff
@JLuboff
Nov 09 2017 19:41
@cmccormack Well the "cards" aren't responsive. Or atleast they stack instead of staying next to each other and doesn't look good
Christopher McCormack
@cmccormack
Nov 09 2017 19:42
I think you just need to add some intermediate viewport column sizes, maybe have them be bigger sooner when reducing window width
like col-lg-4 col-md-6
Jason Luboff
@JLuboff
Nov 09 2017 19:44
Exactly
I need to add for small and xsmall
Christopher McCormack
@cmccormack
Nov 09 2017 19:44
height can be a pain if there is too much text though
like this for example - without fixed height some cards are shifted under other cards and it doesn't wrap nicely http://imagus.glitch.me/puppies
Jason Luboff
@JLuboff
Nov 09 2017 19:48
Ya, thats what happened when you added some game that had a really long title. So I deleted it from your game collection :P
Christopher McCormack
@cmccormack
Nov 09 2017 19:49
HAHA
what about text-overflow: none or ellipses
Jason Luboff
@JLuboff
Nov 09 2017 19:49
I dunno...guess I could try that in the future
FCC recomends this library for the pinterest clone...so I think it handles some of that issue for us.. https://masonry.desandro.com/
Christopher McCormack
@cmccormack
Nov 09 2017 19:50
oh cool! I wondered how people did that timeline
Jason Luboff
@JLuboff
Nov 09 2017 19:51
Ya I actually haven't looked into it much yet
Jason Luboff
@JLuboff
Nov 09 2017 20:03
I like how this coming along.. using a dark theme for bootstrap
Christopher McCormack
@cmccormack
Nov 09 2017 20:03
you using the themes?
bootswatch?
Jason Luboff
@JLuboff
Nov 09 2017 20:09
Ya bootswatch
Christopher McCormack
@cmccormack
Nov 09 2017 20:12
oh nice and clean and I like the smaller navs
Jason Luboff
@JLuboff
Nov 09 2017 20:13
Ya, looks good so far
Christopher McCormack
@cmccormack
Nov 09 2017 20:13
Gonna run for a bit see ya - good luck on your app
Jason Luboff
@JLuboff
Nov 09 2017 20:13
@cmccormack Thanks, see ya
CamperBot
@camperbot
Nov 09 2017 20:13
jluboff sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1268 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher
@bradley1492
Nov 09 2017 21:07
Good evening guys,
I am just working on the Sum All Odd Numbers Challenge. It greenlights all the tests except for the last one. Could it be somesort of rounding off issue? It certainly is not a bug is it? :smile:
Do you guys actually prefer codepen code or copy pasted from the fcc editor?
https://www.freecodecamp.org/challenges/sum-all-odd-fibonacci-numbers

function sumFibs(num) {

  let place = [1];
  // place is the array in which i save the fibonacci sequence
  let placeOdd = [];
  let result = [];
  // placeOdd is the array where the odd numbers from filter get saved
  let previousFirst = 0;
  let previousSecond = 1;
  let next = 1;
    // here I am declaring the start of the sequence
  for (let i = 0; i < num; i++) {
    next = previousFirst + previousSecond;
    previousFirst = previousSecond;
    previousSecond = next;
    // here the fibonacci sequence is being created
    place.push(next);
  }

 place.filter(function(num){
   if (num % 2)
  placeOdd.push(num);  
 });
  // here the array gets filtered for odd numbers
  for (let i = 0; i < placeOdd.length; i++) {
    if (placeOdd[i] < num) {
      result.push(placeOdd[i]);
    }//end if
  }// end for
let endResult = result.reduce(function(a, b){
return a + b;
}, 0);
// here I sum all the numbers form the result array
return endResult;
}

sumFibs(4);
Stephen James
@sjames1958gm
Nov 09 2017 21:08
@bradley1492 Can't be rounding - all integers. Are you making sure you including num ?
let i = 0; i < num; i++
@bradley1492 For your filter function - just return
num % 2 == 1
for odd
let arrayOdds = arr.filter(function(num) { return num % 2 === 1; }) this will filter, keeping only odd numbers
Christopher
@bradley1492
Nov 09 2017 21:13
@sjames1958gm Hey, ok thanks for the filter tip. This is a shortcut isn't it? Is it because the syntax is shorter and therefore easier to read for me and others?
I tried to include num in the for-loop like let i = 0; i <= num; i++but it's still not working..?
CamperBot
@camperbot
Nov 09 2017 21:13
bradley1492 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8686 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 09 2017 21:14
@bradley1492 this is the proper way to use filter. You don't need to push onto another array the internals of filter build you a new array.
Christopher
@bradley1492
Nov 09 2017 21:14
@sjames1958gm ohhhhh niccce
Stephen James
@sjames1958gm
Nov 09 2017 21:14
@bradley1492 Looks like you have placeOdd[i] < num (that might break it as well)
Christopher
@bradley1492
Nov 09 2017 21:16
@sjames1958gm hmm I also exchanged it with let i = 0; i <= placeOdd.length; i++ but it's still not working...
@sjames1958gm I`ll change filter once I am done with basic completion
Stephen James
@sjames1958gm
Nov 09 2017 21:17
@bradley1492 With the proper filter you don't need that for loop at all
@bradley1492 You certainly don't want i <= placeOdd.length this as it will run off your placeOdd array
@bradley1492 Can't you use your placeOdd array with reduce directly?
Christopher
@bradley1492
Nov 09 2017 21:20
@sjames1958gm ok I'll need bit of time to implement your tips. I'll and come back when I figured that out. Meanwhile thanks for helping :)
CamperBot
@camperbot
Nov 09 2017 21:20
bradley1492 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
Stephen James
@sjames1958gm
Nov 09 2017 21:21
good luck
Christopher
@bradley1492
Nov 09 2017 21:44
@sjames1958gm Hey, I implemented the filter function correctly as you said and found the error it was a missing = in the execution part of the second for-loop. Thanks :)
CamperBot
@camperbot
Nov 09 2017 21:44
bradley1492 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
iso
@iso1048
Nov 09 2017 23:42
function permAlone(str){

  var arr = str.split(''),
      n = arr.length;

  function swap(ind1, ind2){
    var x = arr[ind1];
    arr[ind1] = arr[ind2];
    arr[ind2] = x;
    return arr;
  }

  var permArr= [];
  var j = 0;//n is odd (so switch first element and last)
            //j=i means n is even, so switch last and ith element

  function maker(arrLength, array){
    for (var i = 0; i<n; i++){
      if (n == 1){
        return 1;
      }
      else {
        maker(n-1, array);
      }
      if (n%2==0){
        j=i;
      }
      swap(j,n-1);
      permArr.push(array.join(''));
    }//for loop

  }//maker function

  maker(n, arr);


  return permArr;
}

permAlone('aabb');
Hi. I'm working on the no repeats challenge. With the code above, i get RangeError: Maximum call stack size exceeded, so obviously I cannot see if the code is working as intended. How can I fix this?
Diego Mayer
@Chrono79
Nov 09 2017 23:55
@gothamknight are you using arrLength in some place?
your maker function doesn't make much sense
every time you call maker, n value is arr.length