These are chat archives for FreeCodeCamp/Help

11th
Sep 2018
any help would be appreciated, i tried doing with substring but it didn't get it.
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
  if (str.substring(0,str.length -1) === target){
    return true
  }
  //
  return false;
}

confirmEnding("Bastian", "n");
tried with if statement but looks like i might have to go with different approach
Kyle Holm
@thekholm80
Sep 11 2018 00:45
@coderkarma it's just math. you need to figure out how to get your substring to start looking in the right place
Syntax
str.substring(indexStart[, indexEnd])
right now you're starting at the beginning of the string and checking to see if everything between the beginning and the end is equal to target
Karma Drukpa
@coderkarma
Sep 11 2018 00:46
@thekholm80 was looking that infact . thank you though
Kyle Holm
@thekholm80
Sep 11 2018 00:46
okay well best of luck
Karma Drukpa
@coderkarma
Sep 11 2018 00:49
How would you go for this one ?
I was thinking to do loop and see substring thing from i to end of the str
Kyle Holm
@thekholm80
Sep 11 2018 00:50
i did it by return str.substring(/* correct start location */, /* end of string */) === target
Karma Drukpa
@coderkarma
Sep 11 2018 00:51
I was trying to find correct start location. thank you @thekholm80
Claudio Restifo
@Marmiz
Sep 11 2018 03:07
@AbrisM what's the matter?

you have the weirdest syntax I've ever seen.
like

var createElement("Button");

That's not how you assign variables

also you don't need <script> tag in JSfiddle
get rid of them, they are causing errors
AbrisM
@AbrisM
Sep 11 2018 03:35
Hi button was just a quick pseudo place holder
It's been update with button id assignment
Claudio Restifo
@Marmiz
Sep 11 2018 03:38
@AbrisM yeah but in general that's not how you assign variables
i mean, you can assign var to function result, but the syntax is the same as every other var assigment
function sum(x,y) {
  return x + y;
}

var a = 4;
var b = sum(2,2);

a // 4;
b // 4;
AbrisM
@AbrisM
Sep 11 2018 03:59
https://jsfiddle.net/bvLdjrha/2/ code's been updated but function not accepting the id of the table
Karma Drukpa
@coderkarma
Sep 11 2018 05:28
@Marmiz @aditya2000
you guys there
Claudio Restifo
@Marmiz
Sep 11 2018 05:41
@coderkarma 'sup
Karma Drukpa
@coderkarma
Sep 11 2018 05:46
was struggling with this
using logic
but got it now.
damn, i was doing loop nested loop instead of separate
Claudio Restifo
@Marmiz
Sep 11 2018 05:51
@coderkarma the nicest approach I've seen was made by one of my coworker. He used a Set for it :)
really clever
I should look but should be something like
const diffArr = (a,b) => {
  let s = new Set(b) // only unique b
  return a.filter(x => !s.has(x)) // a val that are not in s
}
Claudio Restifo
@Marmiz
Sep 11 2018 05:56
the specs are different so it should be adapted
function diffArray(arr1, arr2) {
  let s1 = new Set(arr1);
  let s2 = new Set(arr2)
  return arr1.filter(x => !s2.has(x)).concat(arr2.filter(x => !s1.has(x)))
}
does the trick
Manish Giri
@Manish-Giri
Sep 11 2018 06:00
function diffArray(a, b) {
  let s = [...a, ...b];
  return s.filter(x => !(a.includes(x) && b.includes(x))); 
}
@Marmiz :wave:
thekindlyelk
@thekindlyelk
Sep 11 2018 06:49
I'm stuck on something so stupid
Aditya
@ezioda004
Sep 11 2018 07:04
@thekindlyelk Declaration of studlyCapVaR doesnt meet its assignment name studlyCapVar
Claudio Restifo
@Marmiz
Sep 11 2018 07:31
@Manish-Giri :wave: nice one
Aditya Dehal
@aditya2000
Sep 11 2018 08:03
@coderkarma yup?
Smootimus
@Smootimus
Sep 11 2018 09:18
Ah man
I have an interesting final Extra Credit assignment lol

For this final Extra Credit assignment, YOU will be writing your own problem, as well as solving it!

The solution to your lab problem must include [but is not limited to] the following:

2 outside functions must be used
one must return a value to main()
one must receive data from main()
1 if statement
1 array [one dimensional or greater]
1 text file that is used to populate an array
1 for loop
rand() function
starting range that does not begin with 0
You must write out the Problem in the top block comment of the program code and document your code through commenting throughout the program (at minimum where the above bullet points exist and what they are being used for).

Get creative with your problem! I can't wait to see what you all come up with :]

This extra credit assignment deadline is extended to Week 10 Day 1 end of class [September 18th 2018]

:eyes:
I have questions I'm going to get answered today
Ene Catalin
@EneCatalin
Sep 11 2018 09:33
hmmm, extra credit problem
can definitely see myself not doing that
Smootimus
@Smootimus
Sep 11 2018 09:43
I'm gonna do it just cause I've aced the rest of them and if I do this one I don't have to do the final lol
I have so many questions tho
Like what kind of aproblem does it HAVE to be, I mean can I just do... something? LOL!
Cause I have so many things I could do and show her! But is this something that I'm gonna have to come up with a brain teaser....
Cause I suck at coming up with puzzles and stuff...
May Kittens Devour Your Soul
@diomed
Sep 11 2018 10:13

For this final Extra Credit assignment, YOU will be writing your own problem

yes, you can do ... something

Smootimus
@Smootimus
Sep 11 2018 10:13
Right, anything
May Kittens Devour Your Soul
@diomed
Sep 11 2018 10:14
so what's the problem then?
Smootimus
@Smootimus
Sep 11 2018 10:14
It's gonna be ridiculous specific
It's gonna be a case where I have to come up with some kind of puzzle for some user to solve
Some riddle
Or some math problem
May Kittens Devour Your Soul
@diomed
Sep 11 2018 10:15
why?
Smootimus
@Smootimus
Sep 11 2018 10:15
Because I have that feeling, when she says "problem"
That word right there is what says it's gonna be some kind of puzzle
Or solution I have to make the user come up with
Amit Patel
@AmitP88
Sep 11 2018 10:16
hey guys, has anyone here done the heat map project for D3? I need help on my scales and axes
May Kittens Devour Your Soul
@diomed
Sep 11 2018 10:19
problem is not a riddle, lol
psyperl
@psyperl
Sep 11 2018 11:00
but is riddle a problem?
Smootimus
@Smootimus
Sep 11 2018 11:26
LoL
Right
^
Ene Catalin
@EneCatalin
Sep 11 2018 11:28
you could create something really smart here, an app where you're given a random list of ingredients from a text file then, trough AI, the app suggest a dinner course and tells you how to prepare it
(based on the ingredients received)
A+ app
May Kittens Devour Your Soul
@diomed
Sep 11 2018 11:34

Le couisine a morte

Ene Catalin
@EneCatalin
Sep 11 2018 11:36
i know someone who made an app kinda similar to that using pretty much full recursion
psyperl
@psyperl
Sep 11 2018 11:41
full recursion app.. now that's interesting
May Kittens Devour Your Soul
@diomed
Sep 11 2018 11:47
Ene Catalin
@EneCatalin
Sep 11 2018 11:53
@psyperl maybe not full but try to using lisp and not go recursive
@diomed everyone will drop your app if it takes 5 seconds to do anything. Otherwise great idea
psyperl
@psyperl
Sep 11 2018 12:12
is it common for ppl to get confused designing schema in noSQL when one is used to relational?
Smootimus
@Smootimus
Sep 11 2018 12:14
I would say so
Niraj Nandish
@Nirajn2311
Sep 11 2018 12:56
@Smootimus are you supposed to do it in c++
Smootimus
@Smootimus
Sep 11 2018 12:57
YEah
C++ assignment
May Kittens Devour Your Soul
@diomed
Sep 11 2018 13:26
IC++U
Smootimus
@Smootimus
Sep 11 2018 13:26
Heh
Do you tho
:P
May Kittens Devour Your Soul
@diomed
Sep 11 2018 13:28
that's just short for Intensive C++are Unit
Smootimus
@Smootimus
Sep 11 2018 13:28
Bahaha
May Kittens Devour Your Soul
@diomed
Sep 11 2018 13:36
Karma Drukpa
@coderkarma
Sep 11 2018 13:57
@Marmiz @Manish-Giri thos were clever answer, i would love to do that way thank you guys
Kyle Holm
@thekholm80
Sep 11 2018 15:00
good morning, /help
Niraj Nandish
@Nirajn2311
Sep 11 2018 15:00
Mornin' @thekholm80 :wave:
@Smootimus requires a problem
Kyle Holm
@thekholm80
Sep 11 2018 15:02
maybe he can solve P vs NP
that's a pretty good problem
alpox
@alpox
Sep 11 2018 15:03
@thekholm80 id like to see that
Kyle Holm
@thekholm80
Sep 11 2018 15:03
smoot can do it, he's the man
psyperl
@psyperl
Sep 11 2018 15:05
can he do with his eyes closed though?
Niraj Nandish
@Nirajn2311
Sep 11 2018 15:06
P vs NP scratching head???
Kyle Holm
@thekholm80
Sep 11 2018 15:06
@Nirajn2311 p vs np
May Kittens Devour Your Soul
@diomed
Sep 11 2018 15:06
@thekholm80 you didn't even think u need this in your life, but now you do
Kyle Holm
@thekholm80
Sep 11 2018 15:07
@diomed i feel like maybe i've been wasting my life. today begins my new life in 3d modeling, animation and physics engines
May Kittens Devour Your Soul
@diomed
Sep 11 2018 15:09
possibilities are endless
Kyle Holm
@thekholm80
Sep 11 2018 15:11
@diomed never mind, i'm going to devote my life to this instead
Niraj Nandish
@Nirajn2311
Sep 11 2018 15:13
@thekholm80 you didn't even think u need this in your life, but now you do
@diomed when America hears that Trump got impeached
May Kittens Devour Your Soul
@diomed
Sep 11 2018 15:27
@Nirajn2311 when shall you build a template with me?
damn, if only there was some kind of place where we could host a template code, then work on it together
psyperl
@psyperl
Sep 11 2018 15:30
codepen?
glitch..?
Niraj Nandish
@Nirajn2311
Sep 11 2018 15:31
@diomed when my ielts is over(this thursday)
May Kittens Devour Your Soul
@diomed
Sep 11 2018 15:32
oh. ok.
Niraj Nandish
@Nirajn2311
Sep 11 2018 15:32
And it is also better if you host the code somewhere
Kyle Holm
@thekholm80
Sep 11 2018 15:36
single male coder looking for template partner php and sql free, will host
we should start a 'personals' page
Aditya Dehal
@aditya2000
Sep 11 2018 15:54
Hey everyone! 🙂
Kyle Holm
@thekholm80
Sep 11 2018 15:55
@aditya2000 :wave:
Karma Drukpa
@coderkarma
Sep 11 2018 15:55
hi
Aditya Dehal
@aditya2000
Sep 11 2018 15:56
What's up @coderkarma @thekholm80
Karma Drukpa
@coderkarma
Sep 11 2018 15:57
Just got in morning class
Aditya Dehal
@aditya2000
Sep 11 2018 15:58
Are you in college?
Karma Drukpa
@coderkarma
Sep 11 2018 16:48
yes
@thekholm80 just little hint needed
function firstDuplicate(a) {
  // sort the arr 
  let result = [];

  a.sort((a,b) => { return a - b});
    console.log(a);
    for (let i = 0; i <a.length -1; i ++){
       if(a[i] === a[i + 1]){
        result.push(a[i])
        console.log(result);
         if (a.indexOf(a[i]) >= 1){
           return a[i];
         }
       } 
    }
    return -1;
 }

 firstDuplicate([2, 1, 3, 5, 3, 2]) // 3
tried doing this
Niraj Nandish
@Nirajn2311
Sep 11 2018 16:50
whats the question
Eric Weiss
@eweiss17
Sep 11 2018 16:52
I had something like that during an interview
Kyle Holm
@thekholm80
Sep 11 2018 16:52
@coderkarma if you want to return the first duplicate, are you sure you want to change the order by using sort()?
i can't see the instructions without creating an account, so i'm just guessing at what they want
then again firstDuplicate([2, 1, 3, 5, 3, 2]) // 3 if my assumption was correct the result here should be 2 so i guess i don't know what they want
Karma Drukpa
@coderkarma
Sep 11 2018 16:53
Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrence of the other number does. If there are no such elements, return -1.

Example

For a = [2, 1, 3, 5, 3, 2], the output should be
firstDuplicate(a) = 3.

There are 2 duplicates: numbers 2 and 3. The second occurrence of 3 has a smaller index than the second occurrence of 2 does, so the answer is 3.

For a = [2, 4, 3, 5, 1], the output should be
firstDuplicate(a) = -1.

Input/Output

[execution time limit] 4 seconds (js)

[input] array.integer a

Guaranteed constraints:
1a.length105,
1a[i] ≤ a.length.

[output] integer

The element in a that occurs in the array more than once and has the minimal index for its second occurrence. If there are no such elements, return -1.
Kyle Holm
@thekholm80
Sep 11 2018 16:53
oh, i see
my point stands. if the order of the array is important i would suggest not sorting it
Karma Drukpa
@coderkarma
Sep 11 2018 16:54
ok
Manish Giri
@Manish-Giri
Sep 11 2018 16:59
There’s an easy way of doing this, if you check the element’s index
Karma Drukpa
@coderkarma
Sep 11 2018 17:02
ok
thanks man
Manish Giri
@Manish-Giri
Sep 11 2018 17:03
:thumbsup:
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:09
hi @Manish-Giri :cat:
Manish Giri
@Manish-Giri
Sep 11 2018 17:11
@diomed good meowning :cat:
My friends are posting their pictures by the beaches in Split
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:13
lucky them.
Manish Giri
@Manish-Giri
Sep 11 2018 17:13
:smirk_cat:
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:14
and when are you coming to Croatia?
in winter, when windy? when bura's gonna get you
xD
Manish Giri
@Manish-Giri
Sep 11 2018 17:14
Haha
Looks that way
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:14
I hate this summer
we need a summerkiller
Manish Giri
@Manish-Giri
Sep 11 2018 17:15
Here we’re in a 15-17 deg phase (during the day) over the last few days
At nights it’s around 9
I love it
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:16
here was chill for few days, then heat came back. tomorrow 30°C again :unamused:
Manish Giri
@Manish-Giri
Sep 11 2018 17:16
Aw lol
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:16
we all thought it's over but nooo
Manish Giri
@Manish-Giri
Sep 11 2018 17:17
Go to Split, enjoy the view
:wine_glass:
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:20
Croatian people go to coast only to work, and make a few bucks.
coz we poor, and live off rich tourists
Manish Giri
@Manish-Giri
Sep 11 2018 17:22
Lol
@diomed x
Try this with the baby
More like toddler, he’s all grown up now
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:24
I was just about to say , I should do that
He's never seen Smeagol, maybe I get lucky :smiling_imp:
Manish Giri
@Manish-Giri
Sep 11 2018 17:25
Lol
U will :smiling_imp:
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:29
@Manish-Giri u know react now, right?
Manish Giri
@Manish-Giri
Sep 11 2018 17:30
Um
Lazar Madžić
@LazarMadzic
Sep 11 2018 17:30
can someone help me with a problem with C language?
Manish Giri
@Manish-Giri
Sep 11 2018 17:30
I knew react before
Hopefully I still remember it
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:32
Dingbin
@tobeforgetten
Sep 11 2018 17:36

@tobeforgetten
gray-background{
background-color:gray;

<div class="gray-background">

Manish Giri
@Manish-Giri
Sep 11 2018 17:37
Is it somewhat like Medium?
Dingbin
@tobeforgetten
Sep 11 2018 17:37
what's wrong with my code?
Niraj Nandish
@Nirajn2311
Sep 11 2018 17:37
@tobeforgetten when referencing classes in css they have begin with a .
for example you have a class poster
Dingbin
@tobeforgetten
Sep 11 2018 17:38
ok let me try
Niraj Nandish
@Nirajn2311
Sep 11 2018 17:38
then in css you will refernece it like .poster { /your code here/}
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:41
@Manish-Giri smth like that. but your own.
Dingbin
@tobeforgetten
Sep 11 2018 17:41
thanks a lot
May Kittens Devour Your Soul
@diomed
Sep 11 2018 17:43
thanks a little
psyperl
@psyperl
Sep 11 2018 18:51
Hello World!, my name is Boni, i am here to learn more about JS and related Web Technology. I like algorithm and programming and networking, but i often get lonely when i code so i hang out in the chat often to connect with other people. I have been looking around for a community that shares the feeling of being in a dark room solving algorithm and seeing the world pass by. hopefully this is the right place for me to be.
Clayton Balzer
@Techn0mancer-X
Sep 11 2018 18:54
Welcome @psyperl, and yes i do believe you are on the right room. I too. enjoy conversing with other like minded individuals when it comes to coding.
psyperl
@psyperl
Sep 11 2018 18:59
Thank you @Techn0mancer-X :smile:
Clayton Balzer
@Techn0mancer-X
Sep 11 2018 19:05
anytime
Alexander R Bott
@Abott1222
Sep 11 2018 19:06
@psyperl :wave:
psyperl
@psyperl
Sep 11 2018 19:06
@Abott1222 :wave:
Kyle Holm
@thekholm80
Sep 11 2018 19:10
lol
Simey de Klerk
@simeydk
Sep 11 2018 20:29
Hi everyone. I have a noob git+github question. If I want to contribute to a project that I don't control, do I add both my fork and the original repo as remotes for my local repo?
Niraj Nandish
@Nirajn2311
Sep 11 2018 20:49
@simeydk yeah you have to
Your fork becomes the origin
And the original repo becomes the upstream
You don’t have to add your fork to your local repo as when you fork and clone it is automatically done
So you only need to add upstream
like
git remote add upstream(you can change the name if you want) <repo-link>
psyperl
@psyperl
Sep 11 2018 20:55
I would have an original repo and my fork as remote too, remote for original repo to keep track of what's new from the original repo, and a remote to my fork where i will push my revision branch. at least that's one flow that i recognized