These are chat archives for FreeCodeCamp/Help

1st
Nov 2018
kinopotato
@kinopotato
Nov 01 2018 00:00
Good day, was just wondering why this returns false
 let a = [{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }];

let b = [{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }];

console.log(a[0]);
console.log(b[0]);
 a[0] === b[0]; //returns false
kinopotato
@kinopotato
Nov 01 2018 00:19
@Manish-Giri wow this looks immensely complex. why is this difficult and is this just difficult in js or is it really hard to compare with other languages as well?
Manish Giri
@Manish-Giri
Nov 01 2018 00:20
@kinopotato haha
I know for a fact it's the same way in Java too, not sure about other languages
i think it's somewhat easier in python
kinopotato
@kinopotato
Nov 01 2018 00:21
this seems just strange xD I mean it's comparing two things, how does the machine even get false when it should be the exact information? or is this the stack thing where since objects are stored in different stacks (or so I've heard) then the address is different and so it returns false?
Manish Giri
@Manish-Giri
Nov 01 2018 00:28
it depends on the two things you're comparing
for simple types, like numbers, the variables contain the exact value, so using === gives the right answer because you're comparing the content directly
like 3 === 3,10 === 10 etc
for reference types like objects, arrays, etc, the variables contain a reference to the object, not the object itself (which is stored elsewhere in memory)
so using === on these types checks the memory locations these variables contain and not the content that's stored in these memory locations
kinopotato
@kinopotato
Nov 01 2018 00:32
hmm, what you say made sense, but what doesn't make sense is why after 20 years of JS they didn't make an innate function or something that can check if a[0] is equal to b[0]?
Manish Giri
@Manish-Giri
Nov 01 2018 00:35
lol
JS has many many things which still doesn't make sense to me after all this time
kinopotato
@kinopotato
Nov 01 2018 00:36
ohh, that kinda comforts me a bit xD I thought I was just really really noob (which I am) but I guess JS also does have its own quirks
Manish Giri
@Manish-Giri
Nov 01 2018 00:36
In JavaScript, typeof null is 'object', which incorrectly suggests that null is an object (it isn’t, it’s a primitive value, consult my blog post on categorizing values for details). This is a bug and one that unfortunately can’t be fixed, because it would break existing code. Let’s explore the history of this bug.
kinopotato
@kinopotato
Nov 01 2018 00:37
the makers of JS must look at this and do a face palm as they remember how they coded an unfixable bug. haha
Manish Giri
@Manish-Giri
Nov 01 2018 00:38
lol
kinopotato
@kinopotato
Nov 01 2018 00:39
hmm, even .hasOwnProperty isn't working

function whatIsInAName(collection, source) {
  // What's in a name?
  console.log(arguments[0].hasOwnProperty(arguments[1])); // returns false
  console.log(arguments[0]); // returns 
//[ { first: 'Romeo', last: 'Montague' },
  //{ first: 'Mercutio', last: null },
  //{ first: 'Tybalt', last: 'Capulet' } ]

  console.log(arguments[1]); // returns { last: 'Capulet' }
  // Only change code below this line


  // Only change code above this line

}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
it is returning false even though last: "Capulet" can be found in arguments[0]
Manish Giri
@Manish-Giri
Nov 01 2018 00:42
arguments[0] would be an array
.hasOwnProperty() is a function for objects
you should try to loop through collection and then check .hasOwnProperty() on each element
kinopotato
@kinopotato
Nov 01 2018 00:43
mother fucker xD but if you use typeof with arguments[0] it returns object.
Manish Giri
@Manish-Giri
Nov 01 2018 00:43
that's coz array is an object
another quirk
:wink:
Karma Drukpa
@coderkarma
Nov 01 2018 00:44
Everything is an object in Js ?
kinopotato
@kinopotato
Nov 01 2018 00:44
probably not everything, but I think most
I mean, boolean can't be an object right? or just random numbers
Manish Giri
@Manish-Giri
Nov 01 2018 00:45
correct
kinopotato
@kinopotato
Nov 01 2018 00:45
I swear to god I will lose all my hair soon
and this is just some basic js
when I get to dom manipulation and making this work with both html and css
then probably I'll also age four times quicker
Manish Giri
@Manish-Giri
Nov 01 2018 00:47
good news is the basics are sometimes the hardest
kinopotato
@kinopotato
Nov 01 2018 00:47
I hope so. I'm so hung up on this that I found something in my coffee, I don't know what it was, and I just continued drinking.
I'll probably die later from food poisoning
Manish Giri
@Manish-Giri
Nov 01 2018 00:48
lmao
kinopotato
@kinopotato
Nov 01 2018 00:48
death by food poisoning or death by basic JS
Manish Giri
@Manish-Giri
Nov 01 2018 00:51
death by JS poisoning
kinopotato
@kinopotato
Nov 01 2018 00:53
well that's at least a good middle ground between pathetic and absurd xD learn how to code, die from both java script and java coffee
Manish Giri
@Manish-Giri
Nov 01 2018 00:54
lol
kinopotato
@kinopotato
Nov 01 2018 03:39
Hello, can someone please help me understand what this FCC challenge wants?
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin
it says at the last part "Should handle words without vowels." my code passed everything but this so I don't know what that even means

this is the description of the challenge
Intermediate Algorithm Scripting: Pig Latin
Translate the provided string to pig latin.

Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an "ay".

If a word begins with a vowel you just add "way" to the end.

Input strings are guaranteed to be English words in all lowercase.

and this is my code
function translatePigLatin(str) {
let regex = /(^[^aeiou]+)/;
let strCon = "";
if (regex.test(str)){
strCon = str.replace(/(^[^aeiou]+)(\w+)/, "$2$1"+"ay");
return strCon;
} else {
  strCon = str.concat("way");
  return strCon;
}

}

translatePigLatin("cccccccccccc"); //returns ccccccccccccay
this requirement is really bad, it's asking me to move a single group and attach it at the end of nothing. if you attach a single group into nothing then that nothing becomes the single group you attached it to which means it becomes that group which means why tf did you move it in the first place?
wth is wrong with the guy who made this challenge??
Aditya
@ezioda004
Nov 01 2018 03:50

@kinopotato

"Should handle words without vowels."

Example: "bcd" => "bcday"

kinopotato
@kinopotato
Nov 01 2018 03:51
@ezioda004 yeah I just figured it out, I was trying cccccccc so I couldn't see it. Seriously though that requirement could have been handled better. I was becoming philosophical with the whole attaching one group of something into nothing and expecting any difference
Aditya
@ezioda004
Nov 01 2018 03:53
@kinopotato Probably because you're thinking in terms of group? Even if you think in substrings, its asking you to move first consonant cluster so a word with no vowel is a consonant cluster as a whole.
Its like cut-paste operation, you take the whole string and paste to itself ie now an empty string.
kinopotato
@kinopotato
Nov 01 2018 03:55
yes you are right, I was thinking of .replace using regex (....) that, whatever that parenthesis in regex is called.
using substr seemed strange and convoluted to me, so I avoided it. but I probably just don't know how to use it
Aditya
@ezioda004
Nov 01 2018 03:58
By substring, I meant a for loop. You start from the beginning and select the string until a vowel is found. Using regex is fine as well.
kinopotato
@kinopotato
Nov 01 2018 04:28
Are loops inefficient? I mean it must cost a lot of processing power to loop through an object right?
then again for all I know regex can be operating under the same principle
Aditya
@ezioda004
Nov 01 2018 04:44
Loop are fundamental but yes they have a cost. You're right, regex is a loop itself.
Darren
@DarrenfJ
Nov 01 2018 05:35
evening fCC helpRoom...
Aditya
@ezioda004
Nov 01 2018 05:38
@DarrenfJ :wave:
Darren
@DarrenfJ
Nov 01 2018 05:53
@ezioda004 :smile:
phao5814
@phao5814
Nov 01 2018 06:29
kinopotato
@kinopotato
Nov 01 2018 11:08
Hello, quick question. why is this /T[^[]]/g matching both T and C in this [A, T]TCG[A, T]??
btw there are slashes in the regex brackets but it was automatically removed by chat
T[^\[\]] // matches both T and C in [A, T]TCG[A, T]
oh basically it's T and whatever isn't a bracket
nevermind
hmm, so how do I ignore the T inside the brackets and only get the T outside?
Aditya
@ezioda004
Nov 01 2018 11:15
@kinopotato Its ignoring the T inside the brackets, isnt it?
kinopotato
@kinopotato
Nov 01 2018 11:21
Yes, but the only way I can do that is by getting anything that isn't a bracket that is attached to T
and if the case is [T, A] it doesn't ignore that T
I've decided to change my approach for this challenge, but now I don't get why my switch isn't working



function pairElement(str) {

  let a = str.split("");
  let result = [];
  console.log(a.length);
for (let i = 0; i <= a.length; i++){
  switch(a[i]){
    case "G":
    result.push(["G", "C"]);
    case "C":
    result.push(["C", "G"]);
  break;
  }
  return result;
}
}

pairElement("GCG"); //return [ [ 'G', 'C' ], [ 'C', 'G' ] ] it doesn't cycle through

 //AT and CG
even when I remove the break; it still doesn't cycle through more than 2, I thought being inside a for loop will make it cycle through everything
Niraj Nandish
@Nirajn2311
Nov 01 2018 11:31
@kinopotato which challenge
DNA pairing from intermediate, I was trying to use 8 .replace() xD but I can't get the regex working
would have been fun, I really want to solve it that way
Aditya
@ezioda004
Nov 01 2018 11:34
@kinopotato You have return statement inside the loop. So it only iterates once.
Also, you'd want to add another break; after case "G"
kinopotato
@kinopotato
Nov 01 2018 11:35
mother fucker, it was that simple
sorry for cursing
it felt apt
Aditya
@ezioda004
Nov 01 2018 11:36
One of the reasons you should be properly indenting your code.
kinopotato
@kinopotato
Nov 01 2018 11:38
okay I'll try to develop that habit, thanks again dude!
Niraj Nandish
@Nirajn2311
Nov 01 2018 12:57
@ezioda004 hey, you there?
Momozor
@momozor
Nov 01 2018 13:14
:fishing_pole_and_fish:
Niraj Nandish
@Nirajn2311
Nov 01 2018 13:22
:hourglass_flowing_sand: :hourglass: :hourglass_flowing_sand:
AND YOU GET A - :fish:
Momozor
@momozor
Nov 01 2018 14:03
:fist: :fist:
Binyamin Aron Green
@b3u
Nov 01 2018 14:13
Hey guys. How do you create a new page for each item in a database? Like a user page on a forum.
Eric Weiss
@eweiss17
Nov 01 2018 14:15
what?
Binyamin Aron Green
@b3u
Nov 01 2018 14:15
whats wrong?
@eweiss17
Binyamin Aron Green
@b3u
Nov 01 2018 14:21
help?
Eric Weiss
@eweiss17
Nov 01 2018 14:22
can you rephrase your question
Binyamin Aron Green
@b3u
Nov 01 2018 14:22
like, fcc.org/users/eweiss17
I log in, and the system automatically creates a page with my info.
btw, i like your website.
interesting that you used bootstrap colors for materialize
I'll show you an example: here. If you click on a campsite, you get a page where the url is the key.
Eric Weiss
@eweiss17
Nov 01 2018 14:28
are you talking about server side or client side?
Binyamin Aron Green
@b3u
Nov 01 2018 14:29
What do you mean?
:}
Eric Weiss
@eweiss17
Nov 01 2018 14:29
you just talking about the extension of /.....?
yes that is a brand new page
Binyamin Aron Green
@b3u
Nov 01 2018 14:31
So, if I would click add a new campsite and input credentials, how would I write the code so that the next step is to create the page I would see when I click on that campsite.
Eric Weiss
@eweiss17
Nov 01 2018 14:35
i'm confused man what do you need? I don't have a log in for that site.
Binyamin Aron Green
@b3u
Nov 01 2018 14:36
nobody does. whatever.
I'll figure it out.
Aditya
@ezioda004
Nov 01 2018 16:40
@Nirajn2311 Whats up?
Niraj Nandish
@Nirajn2311
Nov 01 2018 16:41
@ezioda004 nothing, started reviewing PRs
also started mongo challenges
Aditya
@ezioda004
Nov 01 2018 16:43
Nice :thumbsup:
Niraj Nandish
@Nirajn2311
Nov 01 2018 16:45
@ezioda004 what are we supposed to do in this challenge - https://learn.freecodecamp.org/apis-and-microservices/mongodb-and-mongoose/create-a-model
Aditya
@ezioda004
Nov 01 2018 16:49
@Nirajn2311 You need to create a Schema of Person Prototype.
Check example in the docs.
Binyamin Aron Green
@b3u
Nov 01 2018 17:40
Can someone help me on stack overflow?
Xarri Jorge
@xarrijorge
Nov 01 2018 18:00
Hibernation is over! Whats up folks?
Cristian
@GummyGod
Nov 01 2018 18:13
Anyone in here that knows about react can give me some ideeas, i'm trying to do something
Binyamin Aron Green
@b3u
Nov 01 2018 18:14
project ideas?
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:25
@GummyGod it wanna gummy maci
any1 here who speaks fluent English and understands said words :question:
Cristian
@GummyGod
Nov 01 2018 18:33
I dmed u on private @diomed
Mohammed Boudad
@matrixersp
Nov 01 2018 18:35
Hey everyone, to avoid typing the password every time I run cross-env echo $PASSWD | sudo -S npm run build && electron . I had to install cross-env package globally to be able to access system environment variables, is there a better way to access system variables without relying on cross-env?
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:37
@cmccormack =!?! is you ther?
Christopher McCormack
@cmccormack
Nov 01 2018 18:37
sometimes
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:37
@GummyGod has a react question for you
Christopher McCormack
@cmccormack
Nov 01 2018 18:39
@GummyGod what's up?
Niraj Nandish
@Nirajn2311
Nov 01 2018 18:39

any1 here who speaks fluent English and understands said words :question:

Is a 7.5 IELTS enough for you

@diomed hows your day going
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:40
what is this guy saying at 6:45 https://youtu.be/GHpme0ZeHdU?t=405
that's it folks. starts real slow and :question: :question: :question: to nothing
@Nirajn2311 been places, done things. visited family. it's holiday.
Niraj Nandish
@Nirajn2311
Nov 01 2018 18:41
What reason
National :cat: day
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:41
no. it's All Saints day
Niraj Nandish
@Nirajn2311
Nov 01 2018 18:42
Whats that
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:42
Christian holiday.
Niraj Nandish
@Nirajn2311
Nov 01 2018 18:42
Is it similar to St. Patricks day
Christopher McCormack
@cmccormack
Nov 01 2018 18:43
@diomed tapers off to nothing
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:43
no. it's for visiting graves of dead people
Niraj Nandish
@Nirajn2311
Nov 01 2018 18:43
Like the festival of the dead
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:45
@Nirajn2311 yeah. sorta. kinda. has same origin I think
thank you @cmccormack
first time I encounter that word
Christopher McCormack
@cmccormack
Nov 01 2018 18:46
@diomed it was also an actor playing a mush-mouthed singer so I can understand :)
May Kittens Devour Your Soul
@diomed
Nov 01 2018 18:46
heh
Cristian
@GummyGod
Nov 01 2018 18:55
@cmccormack i asked you privately because it's a bit long to describe
May Kittens Devour Your Soul
@diomed
Nov 01 2018 19:22
did anyone in their life come to witness smth like this:
<style class="cp-pen-styles">
Niraj Nandish
@Nirajn2311
Nov 01 2018 19:24
Wait 😲😲 we can do that
Aditya
@ezioda004
Nov 01 2018 19:26
Yes, but it wont matter.
Kelechi Chinaka
@ke1echi
Nov 01 2018 19:27
hows it going? @ezioda004
Aditya
@ezioda004
Nov 01 2018 19:29
@ke1echi Doing some light read before heading to bed. What about you?
Kelechi Chinaka
@ke1echi
Nov 01 2018 19:32
just starting to read spec for recover pset @ezioda004
Aditya
@ezioda004
Nov 01 2018 19:33
@ke1echi Thats the last of pset4?
Kelechi Chinaka
@ke1echi
Nov 01 2018 19:33
yea @ezioda004
Aditya
@ezioda004
Nov 01 2018 19:34
Ah cool :thumbsup:
BuntyBru
@BuntyBru
Nov 01 2018 20:00
Can anyone provide me a trick to make the tbody of a table scrollable
I tried doing it but
is their anyway apart from display:block ?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:00
@ezioda004 My code for the challenge i had asked before
var Schema = mongoose.Schema;

var Person  = new Schema({
  name: { type: String, required: true },
  age: Number,
  favoriteFoods: [String]
});
But it still doesnt pass
Christopher McCormack
@cmccormack
Nov 01 2018 20:03
favourtieFoods?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:04
@cmccormack just saw the typo, fixed it check above
but it still doesnt pass, am it missing something here
Christopher McCormack
@cmccormack
Nov 01 2018 20:05
shouldn't there be a part where you create the model?
Person would be what you assign the actual model to, above you would use something like personSchema = new Schema....
then I think it's something like const Person = new mongoose.Model('Person', personSchema) but you should review the docs
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:06
There is nothing about making a model in the instructions of the challenge
Christopher McCormack
@cmccormack
Nov 01 2018 20:09
did you clone the glitch/github boilerplate?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:09
yeah
Christopher McCormack
@cmccormack
Nov 01 2018 20:11
I think it wants you to follow the guide for that part
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:13
@cmccormack Thats what I have been using but it doesnt work
Updated Code
var Schema = mongoose.Schema;

var personSchema  = new Schema({
  name: { type: String, required: true, default: "Niraj" },
  age: { type: Number, default: 17 },
  favoriteFoods: { type: [String], default: ["Jam", "Butter"] }
});

var Person = mongoose.model('Person', personSchema);
The error I get is - Person Model is not correct
Christopher McCormack
@cmccormack
Nov 01 2018 20:17
try killing those defaults
not sure if required works with default
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:19
Still there is the error
Is the array part right
I mean favoriteFoods should be an array of strings
So have I defined it properly
Christopher McCormack
@cmccormack
Nov 01 2018 20:20
favoriteFoods: [String] should work
what does it look like now?
Aditya
@ezioda004
Nov 01 2018 20:22
Well, your code passes for me.
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:23
var Schema = mongoose.Schema;

var personSchema  = new Schema({
  name: { type: String, required: true },
  age: Number,
  favoriteFoods: [String]
});

var Person = mongoose.model('Person', personSchema);
Christopher McCormack
@cmccormack
Nov 01 2018 20:23
what are you running it in?
glitch?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:23
Yeah glitch
Christopher McCormack
@cmccormack
Nov 01 2018 20:23
are you pasting the edit link or the view link?
it must be the view link
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:24
No, I am pasting the view link
Aditya
@ezioda004
Nov 01 2018 20:25
What error are you getting in the fcc test?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:25
Person Model is not correct
Christopher McCormack
@cmccormack
Nov 01 2018 20:26
did you add your mongo env variables?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:27
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI);
Christopher McCormack
@cmccormack
Nov 01 2018 20:27
not sure if that's the issue
Aditya
@ezioda004
Nov 01 2018 20:27
He probably did or he wont be able to pass the first challenge
@Nirajn2311 Mind sharing your glitch?
Aditya
@ezioda004
Nov 01 2018 20:28
Page Not Found
Jason Luboff
@JLuboff
Nov 01 2018 20:29
I like the undefined in the url hehe
Aditya
@ezioda004
Nov 01 2018 20:32
Seems fine - looks like a glitch in the glitch.
Ditch this one and fork a new boilerplate.
Eric Miller
@ericmiller777
Nov 01 2018 20:33
hey guys
I dont wanna know the answer, but just a hint at what im doing wrong
function updateRecords(id, prop, value) {
console.log(collection[1245]["tracks"] == []);
  if(value == ""){
    delete collection[id][prop];
  }else if(prop === "tracks" && value != ""){
    if(collection[id][prop] != []){
      collection[id][prop] = [value];
    }else{
    collection[id][prop].push(value);
    }
  }else{
    collection[id][prop].push(value);
  }
  return collection[id];
}
for record keeper
Aditya
@ezioda004
Nov 01 2018 20:34
@Nirajn2311 For reference I have this https://glitch.com/edit/#!/fertile-psychiatrist
And it passes the tests.
Christopher McCormack
@cmccormack
Nov 01 2018 20:34

@ezioda004 @Nirajn2311 may be a regex thing or something.
replace

var Schema = mongoose.Schema;

var personSchema  = new Schema({

with

var personSchema = new mongoose.Schema({
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:35
@cmccormack Nope, still error
Aditya
@ezioda004
Nov 01 2018 20:36
Dont think its a regex issue. Something something maxtrix something something glitch.
@ericmiller777 Link to the challenge?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:41
@cmccormack @ezioda004 Thats strange, I did it in a new boilerplate as Aditya told and it passed 🤔🤔🤔
Christopher McCormack
@cmccormack
Nov 01 2018 20:41
i'm wondering if you got a weird character in there or something
Eric Miller
@ericmiller777
Nov 01 2018 20:46
sorry to bother you guys, anyone look at it?
Niraj Nandish
@Nirajn2311
Nov 01 2018 20:47

Seems fine - looks like a glitch in the glitch.

The matrix is real 😲😲

@ericmiller777 Just a min, was busy with another challenge
Eric Miller
@ericmiller777
Nov 01 2018 20:47
no hurry
thank you
Aditya
@ezioda004
Nov 01 2018 21:00

@ericmiller777

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

Nowhere it says the prop is an array, but you are assuming its an array and using .push().

Also, collection[id][prop] != [] is a wrong comparison. Objects/arrays are compared by reference and not value.
Eric Miller
@ericmiller777
Nov 01 2018 21:06
@ezioda004 thank you
Eric Miller
@ericmiller777
Nov 01 2018 21:46
WOW
I worked on that for so long
it just wanted me to return collection not collection[id]
I thought it wanted me to return the modified part only
wtf
Albert Cardona II
@daddycardona
Nov 01 2018 23:41
@ericmiller777 how the heck are you
@DarrenfJ how you doing long time ;)
@longnt80 hey ho wyou been long time wow seems like a life time ago lol
@Manish-Giri wow You live not so far from where I work what up bro long time :)
@diomed you always have a different pic but dont think I forgot about you how you been :)