These are chat archives for FreeCodeCamp/HelpFrontEnd

22nd
Jan 2018
Sorin Ruse
@sorinr
Jan 22 2018 03:14
@Dr-D-M where is this "e" in switch(e.key) coming from ? you only pass to the function "(op, num1, num2)"
Dr-D-M
@Dr-D-M
Jan 22 2018 04:02
@sorinr it was the key suppose to be the key press and then pass that to the function using the event fired
Sorin Ruse
@sorinr
Jan 22 2018 04:03
@Dr-D-M it seems you don't pass that "e" to the function :)
Dr-D-M
@Dr-D-M
Jan 22 2018 04:04
it is being called in the beginnig
but, perhaps that might be one of the many erros I have
I cannot get it work, man
shivam gupta
@shivamg11000
Jan 22 2018 04:51
the panel is not going behind the head and main
z-index not working correctly
https://codepen.io/shivamg11000/pen/MrLzrP?editors=1100
Lallo Vigil
@lalov1
Jan 22 2018 05:27
@shivamg11000 Try giving it a negative z-index
Siddhartha Chatterjee
@sidinsomniac
Jan 22 2018 05:35
Hello! I'm new to Gitter :)
I need help regarding a project of mine. Can you please help me out?
Siddhartha Chatterjee
@sidinsomniac
Jan 22 2018 05:40
how to stop a setTimeout function from executing AFTER it has been triggered?
Aditya
@ezioda004
Jan 22 2018 05:45
@sidinsomniac clearTimeout stops the setTimeout method from executing.
Siddhartha Chatterjee
@sidinsomniac
Jan 22 2018 05:57
Thanks @ezioda004, But I already tried that. It doesn't stop the function "AFTER" it has been triggered.
clearTimeout stops all the future action by setTimeout function.
What I want is to stop the function inbetween
E.g setTimeout for 10 seconds. Timer has already been started. But in between, say at around 5 seconds, the program needs the timer to cancel inbetween. Is it possible?
I hope you understand what I'm trying to covey :)
CamperBot
@camperbot
Jan 22 2018 05:57
sidinsomniac sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Aditya
@ezioda004
Jan 22 2018 06:49
@sidinsomniac The async functions (setTimeout and others) don't start executing until after all sync functions (single threads) are handled, they are just stored in memory in a queue and only start executing after all the single threads are completed. Example:
var someVariable;

setTimeout(function(){
    someVariable = 1;
    console.log(someVariable); //1
}, 1000);
function syncFunc(){
    console.log(someVariable); //undefined

}
syncFunc();
Aditya
@ezioda004
Jan 22 2018 06:54
Same example with synchronous function:
var someVariable;
function someFunc(){
    someVariable = 1;
    console.log(someVariable); //1
};

function syncFunc(){
    console.log(someVariable); //1

}
someFunc();
syncFunc();
So you can stop the setTimeout function if its set to 10sec, after the timer has started at 5sec. But the function is only stored in memory, it won't start executing until it hits 10 second.
Sweet Coding :)
@SweetCodingInc
Jan 22 2018 07:28
now with promise that synchronises shit
var someVariable;
function asyncFunc(){
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      someVariable = 1;
      resolve();
    }, 1000);
  });
}

function syncFunc(){
    someVariable = 2;
}

function logSomeVariable(){
  console.log(someVariable);
}

asyncFunc()
 .then(logSomeVariable)
 .then(syncFunc)
 .then(logSomeVariable);
jjzep
@jjzep
Jan 22 2018 07:58
Having an issue with a click event listener and ES6 classes.
class Test {
constructor() {
    this.userSelection = 'none';
}

    assignValue(selection) {
        this.userSelection = selection;
        console.log(this.userSelection); //does not log anything.
    }

    selectCharacter() {
        let clickName;
        $('.character-select').click(function() {
                clickName = $(this).attr('id');
                }
            );   
        this.assignValue(clickName);
    }
}
I’m trying to get the value from the id to the assignValue method, where it can pass the value to the instance variable
Xapuu
@Xapuu
Jan 22 2018 08:23
@jjzep look at this code snipet
https://pastebin.com/VCVZ8JvT
jjzep
@jjzep
Jan 22 2018 08:40
Is there a way to have the click event method inside the class itself?
Siddhartha Chatterjee
@sidinsomniac
Jan 22 2018 08:54
Thanks @ezioda004 and @SweetCodingInc . I'll try it and let you know. This "promise" thingie seems to be something new
CamperBot
@camperbot
Jan 22 2018 08:54
sidinsomniac sends brownie points to @ezioda004 and @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 202 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
:cookie: 408 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:35
Hi, i have an issue with the basic algorithm scripting, the exercice "Tittle case sentence" i am trying to figured it out since 2-3 weeks, looking at the documentation and sources but i failed since to achieve to make it. I don't cleary understand how to combine several methods as .toUpperCase() and .split. I tried a double for loop for access to each first letter of each arrays ( arr[0][0]) . But it doesn't work. i don't have any snippet to show because i keep trying new thing ( regex but its kind of weird i struggle as well with that) Does anymore can give me just a hint about how to approach the problem ?
Fabien SHAN
@X140hu4
Jan 22 2018 09:36
@PatrickMoumiet Can you give us the link?
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:44
hum i'm trying a something else so there is only crap code but yeah ( if you mean the direct url- first time i ask for help so ^^) >> https://www.freecodecamp.org/challenges/title-case-a-sentence
alpox
@alpox
Jan 22 2018 09:44
@PatrickMoumiet Maby what confuses you is that strings are immutable. This means that a string itself can NOT be altered.
@PatrickMoumiet All string methods only RETURN a NEW string which can be REASSIGNED or used otherwise
Fabien SHAN
@X140hu4
Jan 22 2018 09:45
@PatrickMoumiet What have you tried so far?
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:46
split the array then double for loop for access the first letter of each element of the array then .toUpperCase then return the array.
alpox
@alpox
Jan 22 2018 09:46
@PatrickMoumiet So what toUpperCase() does is nothing else than returning a new string which you give to it in uppercase letters:
var str = "test";
var upperCased = str.toUpperCase();
console.log(upperCased); // Logs "TEST"

var firstLetterUpper = str[0].toUpperCase();
console.log(firstLetterUpper); // Logs "T"

console.log(str); // Logs "test"
@PatrickMoumiet With the method you just proposed, you will have to re-assign the new, changed, words to the array indices - or create a new array with the changed words
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:49
yes. Its the aim of the exercice so. ( and also put some connecting words in uppercase too). So its about reassigning the new string
alpox
@alpox
Jan 22 2018 09:50
@PatrickMoumiet Be aware that you cannot reassign into a string though:
str[0] = "T" does not work in javascript as strings are immutable
Only replacing the whole string works
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:51
yeah i tried to to that with a new array and to push every elements but i'm struggling with the method like i don't understand why i have errors why i tried to combine them.
alpox
@alpox
Jan 22 2018 09:51
Then, can you show us your trial?
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:53
k wait i have to put i back ( i reset most to the time) 3 min^^
alpox
@alpox
Jan 22 2018 09:53
Ok :-)
Zack Adams
@mindforcode
Jan 22 2018 09:55
howdy
alpox
@alpox
Jan 22 2018 09:56
@mindforcode :wave:
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:58
function titleCase(str) {


 var arr = str.split(" ");
 var arr2 = [];

  for (var i = 0 ; i < arr.length ; i++) {

     for (var x = 0 ; x < 1 ; x++)v{

        arr[i][x].toUpperCase();

        arr2.push(arr[i]);
         }
        return arr2;
     }

   }

setTimeout(function(){ alert("Hello"); }, 1000);

titleCase("I'm a little tea pot"); // return ["I'm"]  so the first element of the array
some stuff missing just giving the all idea
alpox
@alpox
Jan 22 2018 09:58
@PatrickMoumiet So i guess thats a typo but you have a v after the for before the {
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 09:59
yep
alpox
@alpox
Jan 22 2018 09:59
@PatrickMoumiet and arr[i][x].toUpperCase(); this is the problem - if you use that statement like this, it does nothing because it cannot change the word in-place, it returns the new uppercase letter. But you don't use it
Also, you return the arr2 inside of the outer for loop which means that you stop the computation after the first iteration already.
Another thing is, that you use 2 for loops - the inner to do what?
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:00
oh yeah.. i just figured out this yesterday ^^
alpox
@alpox
Jan 22 2018 10:00
According to the challenge, you only have to upper-case the first letter of the word, you don't need a loop to find the first letter :D
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:01
i tried to get in the first element to N elements of the array
and then the index 0 of each elements to uppercase
alpox
@alpox
Jan 22 2018 10:02
With the outer loop you find the n elements of the array (which are the words), and you are right, then you use index 0
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:02
lol^^ok but how i select the first so ^^
alpox
@alpox
Jan 22 2018 10:02
arr[i][0]
Is the first letter
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:02
yep
alpox
@alpox
Jan 22 2018 10:02

lol^^ok but how i select the first so ^^

Hmm what is the first so?

Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:03
i tried but i think i have some confusion like you say on the string and how to assigned them correctly
alpox
@alpox
Jan 22 2018 10:03
Well yea you have to create a new string
Markus Kiili
@Masd925
Jan 22 2018 10:03
@PatrickMoumiet Strings were invented so you didn't need to fiddle with character arrays. So here also avoiding character arrays would be a good idea.
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:03
sorry , i just wanted to say " and so" ( patter of my native language)
alpox
@alpox
Jan 22 2018 10:03
Like:
arr2.push(<newstringhere>) as for example arr2.push(<first letter in uppercase> + <rest of the word>)
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:05
@Masd925 okay ^^but so... how i process it ? regex or ?
alpox
@alpox
Jan 22 2018 10:06
About immutability: if you use arr[i][x].toUpperCase(); as you did before, i told you this does nothing because you don't use its return value.
You can get the first letter in uppercase if you just use the return value:
var letter = arr[i][x].toUpperCase();
@PatrickMoumiet No need for regex. toUpperCase and slice are the only things you might need
Markus Kiili
@Masd925
Jan 22 2018 10:06
@PatrickMoumiet Just loop the array of words and make a new titlecased string from the original, and assign it back to the array of words. Use string operations and methods for that.
Read what @alpox said above.
Strings are immutable, so you always make new strings from originals.
Patrick Moumiet
@PatrickMoumiet
Jan 22 2018 10:09
@Masd925 @alpox ok i'm going to try that. thanks for the help^^.
CamperBot
@camperbot
Jan 22 2018 10:09
patrickmoumiet sends brownie points to @masd925 and @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1525 | @alpox |http://www.freecodecamp.org/alpox
:star2: 4663 | @masd925 |http://www.freecodecamp.org/masd925
Rada
@Radascript
Jan 22 2018 10:31
hey guys. Does anyone know how to make it so that that first the little logo with buttons is scrolled away, the clear picture of horses is revealed, and THEN the rest scrolls like normal?
Like right now, the three horses div immediately starts scrolling. And I'd like it to only starts scrolling once the logo is out of view.
https://codepen.io/RadaCodes/pen/rpRLKP
alpox
@alpox
Jan 22 2018 10:58
@Radascript You'd have to make the upper part bigger. Probably about: height: calc(100vh + 150px);
ahmed-issa-mohd
@ahmed-issa-mohd
Jan 22 2018 10:59
hi , how to embed plug-ins like PDF readers) in web pages. ?
Rada
@Radascript
Jan 22 2018 11:07
@alpox hmm which part are you talking about? The overlay or the background or?
alpox
@alpox
Jan 22 2018 11:51
@Radascript On .fademe
Rada
@Radascript
Jan 22 2018 11:51
@alpox mm didn't help
alpox
@alpox
Jan 22 2018 11:52
@Radascript Did you set height: calc(100vh + 150px);?
Rada
@Radascript
Jan 22 2018 11:53
yeah @alpox
Hemakshi Sachdev
@hemakshis
Jan 22 2018 11:55
@moT01 Glad you liked it now :grin:. Thanks for all the tips :blush:.
CamperBot
@camperbot
Jan 22 2018 11:55
hemakshis sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 964 | @mot01 |http://www.freecodecamp.org/mot01
Rada
@Radascript
Jan 22 2018 12:03
fixed it
EdMagal
@EdMagal
Jan 22 2018 12:54
@Radascript that is pretty neat. :+1:
Ali Bulut
@ali27001
Jan 22 2018 13:35
what problem ? http://prntscr.com/i3xbfe
Markus Kiili
@Masd925
Jan 22 2018 13:37
@ali27001 Kitty ipsum starts with a capital K.
Ali Bulut
@ali27001
Jan 22 2018 13:42
it has not changet https://jsfiddle.net/bqpo0ehb/
Markus Kiili
@Masd925
Jan 22 2018 13:43
@ali27001 The content needs to be Kitty ipsum dolor, not Kitty ipsum text
Ali Bulut
@ali27001
Jan 22 2018 13:49
@Masd925 my English is bad. Can you edit on the editor ?. I did not try again
Markus Kiili
@Masd925
Jan 22 2018 13:50
@ali27001 ok
shivam gupta
@shivamg11000
Jan 22 2018 13:53
@shivamg11000
panel is not going behing the head and main
z-index is not working
https://codepen.io/shivamg11000/pen/MrLzrP?editors=1100
EdMagal
@EdMagal
Jan 22 2018 13:57
@ali27001 your second paragraph tag, <p>, needs to have the text provided in the exercise: "Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched."
Ali Bulut
@ali27001
Jan 22 2018 14:16
@EdMagal thanks
Puyan Wei
@puyanwei
Jan 22 2018 14:39

Hi,

I have 3 buttons and I would like to hide one when I click on any of them. In the console, $(".button").hide() hides all of them and $(".button")[0] shows the first button. But when I combine it to have $(".button")[0].hide() I get the error message ".hide() is not a function"

index.html

  <div class="score-inputs">
    <form class="buttons">
      <input class="button" type="button" value="1"></input>
      <input class="button" type="button" value="2"></input>
      <input class="button" type="button" value="3"></input>
    </form>
  </div>

  <script>
$(document).ready(() => {
  $(".button").click(function() {
        $(".button")[0].hide();
  });
});
</script>
Phylicia
@pcampb22
Jan 22 2018 14:47
Hey yall, I have a quick question. It’s not on freecodecamp but I am working on my personal website and my CSS is being dumb lol
basically.
Tom
@moT01
Jan 22 2018 14:48
@puyanwei what is it you're trying to accomplish?
@pcampb22 that's not a question
Phylicia
@pcampb22
Jan 22 2018 14:50
@moT01 i know it’s not. lol I was in the middle of writing it.
Puyan Wei
@puyanwei
Jan 22 2018 14:50
@moT01 I have 3 buttons and I would like to hide the first button when I click on any of them?
Phylicia
@pcampb22
Jan 22 2018 14:53
Basically, trying to make my background image work and for some reason an error comes up where it can’t find the file. For example, i will write background-image: url(‘../img/wallpaper.jpg’); and the file path is correct but the picture won’t load. Also when I inspect it using google chrome the error shows the wrong file path.
it shows file:///Volumes/Mac%20HD/phyliciacampbell/Desktop/Website/css/img/wallpaper.jpg
the css/img is wrong. i am not sure why it keeps going to css folder instead of straight to img. the img folder is not located in css folder
Tom
@moT01
Jan 22 2018 14:54
try targeting it by navigating the dom tree - something like $(this).firstSibling().hide() ---- i dont think that's a method
@puyanwei
$(this).parent().firstChild().hide()
not sure if that is either - but perhaps that would get you on the right track
@pcampb22 two dots goes up a folder - one will stay in the same folder - './img/wallpaper.jpg'
i think that might be what the problem is if i understand what you're asking
Tom
@moT01
Jan 22 2018 15:02
@pcampb22 any luck?
Phylicia
@pcampb22
Jan 22 2018 15:02
nope. @moT01
Tom
@moT01
Jan 22 2018 15:03
what does the folder structure look like
Phylicia
@pcampb22
Jan 22 2018 15:03
@moT01 I am trying something else right now.
@moT01 im going to take a screenshot
Tom
@moT01
Jan 22 2018 15:05
you can't access a photo on your hard drive if you're using something like codepen or some other online editor
Phylicia
@pcampb22
Jan 22 2018 15:05
im using Atom. @moT01
Tom
@moT01
Jan 22 2018 15:10
well, if you more help ill be hangin out - not sure without seeing a little more
so the img and css folders are both in the website folder is what you're saying
Phylicia
@pcampb22
Jan 22 2018 15:13
@moT01 yes. they are both in the website folder but the img folder isn’t inside of the css folder but it keeps linking it as if it was even though it’s not what is inputed in the url
Tom
@moT01
Jan 22 2018 15:15
yea, how you had it should be right then i would think
wondering if you can't go up folders like that in a css file
i would think you should be able to
Kevin Galang
@kgalang
Jan 22 2018 15:18

I'm working on the beta react course right now and wanted to verify that this was a bug before reporting. Can someone who's familiar with react help verify this, please? Or let me know if I'm missing anything lol (happens a lot)

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: 'Initial State'
    };
    this.handleClick = this.handleClick.bind(this);
  }
  handleClick() {
    // change code below this line
      this.setState(
        name: "React Rocks!"
      );
    // change code above this line
  }
  render() {
    return (
      <div>
        <button onClick={this.handleClick}>Click Me</button>
        <h1>{this.state.name}</h1>
      </div>
    );
  }
};

The above code passes all tests even though I don't think it should work without the brackets around the key: value of .setState()

I'm almost certain that it shouldn't work unless I have {name: "React Rocks!"}
Kaz Baig
@kbaig
Jan 22 2018 15:21
@kgalang looks ok to me
Tom
@moT01
Jan 22 2018 15:21
@kgalang not working in codepen without the brackets
Kaz Baig
@kbaig
Jan 22 2018 15:21
but I don't know what the instructions are
Kaz Baig
@kbaig
Jan 22 2018 15:21
oh yeah I was just looking at the syntax, can't make the brackets out from looking lol
@kbaig @moT01 there's the link for the challenge
I didn't want to spam with a bunch of screen shots haha
Tom
@moT01
Jan 22 2018 15:23
yea, i just ran tests without adding any code and it passed
Kaz Baig
@kbaig
Jan 22 2018 15:23
Just passing this.setState({name: 'React Rocks!'}); between the comment lines worked for me
Kevin Galang
@kgalang
Jan 22 2018 15:24
@moT01 @kbaig Thanks guys! I'll definitely create an issue report on github now
CamperBot
@camperbot
Jan 22 2018 15:24
kgalang sends brownie points to @mot01 and @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 542 | @kbaig |http://www.freecodecamp.org/kbaig
:cookie: 965 | @mot01 |http://www.freecodecamp.org/mot01
Kaz Baig
@kbaig
Jan 22 2018 15:25
@kgalang make sure to check that isn't already known (it probably is)
Kevin Galang
@kgalang
Jan 22 2018 15:26
@kbaig will do. thanks again
CamperBot
@camperbot
Jan 22 2018 15:26
kgalang sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
api offline
Marc
@MWBauer
Jan 22 2018 16:05
Morning everyone
For those of you who still have morning.
For the rest of you, good day
Matej Bošnjak
@mbosnjak01
Jan 22 2018 16:06
almost evening
^^
Marc
@MWBauer
Jan 22 2018 16:06
Or good evening.
Lisa Copeland
@lisacopeland
Jan 22 2018 16:06
@MWBauer Good Morning!
Marc
@MWBauer
Jan 22 2018 16:06
Hiya' Lisa
Lisa Copeland
@lisacopeland
Jan 22 2018 16:08
@MWBauer What are ya workin on today
Aryan J
@AryanJ-NYC
Jan 22 2018 16:11
Good morning, @MWBauer and everyone else. I used to frequent the chat. Stopped for a bit but now I'm re-introduced to the chat. Anyway, hi all!
Marc
@MWBauer
Jan 22 2018 16:13
Hi Aryan
@lisacopeland I'm attempting the Diff of 2 arrays
1 array has 2 arrays and you're supposed to filter them to see what doesn't match and then push it into a new arr
Lisa Copeland
@lisacopeland
Jan 22 2018 16:14
One of the FCC Challenges?
Marc
@MWBauer
Jan 22 2018 16:14
Yes, maam
Lisa Copeland
@lisacopeland
Jan 22 2018 16:14
Excellent!
Marc
@MWBauer
Jan 22 2018 16:15
I started by breaking the one array into 2. so I have an aArr and bArr.
Now i'm trying to compare them
Marc
@MWBauer
Jan 22 2018 16:30
can I filter in the comparison?
Stephen James
@sjames1958gm
Jan 22 2018 16:32
@MWBauer You might have to do filter twice.
Marc
@MWBauer
Jan 22 2018 16:32
Ok.
Was thinking about !== then filter
Stephen James
@sjames1958gm
Jan 22 2018 16:33
@MWBauer You can imagine each array as a drawer of single socks and you want to find all the unmatched socks
Marc
@MWBauer
Jan 22 2018 16:33
right
do I need to break each array down, or does filter do that for me?
Stephen James
@sjames1958gm
Jan 22 2018 16:43
@MWBauer filter will iterate over one array and allow you to decide whether or not to keep each value.
@MWBauer So you go through one drawer selecting (filtering) the socks that aren't in the other drawer
And then do the reverse and combine the two piles of socks
Marc
@MWBauer
Jan 22 2018 16:48
newarray = aArr.filter
@sjames1958gm is the comparison run inside the filter?
or does the filter compare the 2 arrs?
Sweet Coding :)
@SweetCodingInc
Jan 22 2018 16:53
@MWBauer : filter takes a function that implements comparison logic
you need to do
newarray = aArr.filter(function(){
  // do your comparison here...
})
Marc
@MWBauer
Jan 22 2018 16:54
right. thanks
Marc
@MWBauer
Jan 22 2018 17:00
aArr !== bArr
I'm out of practice and trying to remember what I'm doing.
Kaz Baig
@kbaig
Jan 22 2018 17:01
@MWBauer you can't directly compare arrays using equality comparisons
you have to iterate through them to compare the values at each index
Marc
@MWBauer
Jan 22 2018 17:02
right. I was thining about that.
thanks
Stephen James
@sjames1958gm
Jan 22 2018 17:18
@MWBauer Sorry, I had to drop off, looks like others answered your questions
Kaz Baig
@kbaig
Jan 22 2018 17:39
Has anyone here used GatsbyJS?
Onome Sotu
@onomesotu
Jan 22 2018 17:50
@kbaig For some reason, i cannot see the solutions to my intermediate algortihms
@kbaig no, I haven't used GatsbyJS
Kaz Baig
@kbaig
Jan 22 2018 17:52
@onomesotu did you try accessing them through your profile page?
Onome Sotu
@onomesotu
Jan 22 2018 17:54
yes...
i think there is a bug
Dennis Onder
@ShadowpathHD
Jan 22 2018 18:05
hello there, can someone help me a bit with JS?
i am doing the stand in line challenge, and i cant get it to work

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

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Kaz Baig
@kbaig
Jan 22 2018 18:06
@ShadowpathHD should just post your question :D
ah you got it
Dennis Onder
@ShadowpathHD
Jan 22 2018 18:06
lol
Kaz Baig
@kbaig
Jan 22 2018 18:07
@ShadowpathHD what seems to be the problem
Dennis Onder
@ShadowpathHD
Jan 22 2018 18:07
so the code is supposed to add an element to the end of the array, which it does
and then remove the first element of the array and return it
it does everything except returning the value
also i did try return arr;
CamperBot
@camperbot
Jan 22 2018 18:08
:bulb: to format code use backticks! ``` more info
Dennis Onder
@ShadowpathHD
Jan 22 2018 18:08
didn't really work
Stephen James
@sjames1958gm
Jan 22 2018 18:08
@ShadowpathHD what does arr.shift() return
Kaz Baig
@kbaig
Jan 22 2018 18:09
^
Dennis Onder
@ShadowpathHD
Jan 22 2018 18:09
return arr.shift(); // Change this line
wait
sorry
lol
cant copy the log
but it just removes another element from the array
Stephen James
@sjames1958gm
Jan 22 2018 18:09
@ShadowpathHD Don't call it twice?
Dennis Onder
@ShadowpathHD
Jan 22 2018 18:09
im not
Stephen James
@sjames1958gm
Jan 22 2018 18:10
@ShadowpathHD You said it removes another element, sounds like you called it twice?
Dennis Onder
@ShadowpathHD
Jan 22 2018 18:11
fixed it lol, i had to declare arr.shift() inside a variable and then return the variable itself
G-4-R-Y
@G-4-R-Y
Jan 22 2018 18:12
hye guys, I can't select/iterate through the properties of "source" in "Wherefore art thou" because it returns undefined, i came to the conclusion that it is not an object because it's passed to the function as { last: "Capulet" } and stuff like that (without []). So, is it and object? How can I iterate through it's properties??
Stephen James
@sjames1958gm
Jan 22 2018 18:12

@ShadowpathHD

arr.push(item);
return arr.shift();

this would have worked as well

@G-4-R-Y Object.keys(source) will give you an array of keys, which you can iterate over.
G-4-R-Y
@G-4-R-Y
Jan 22 2018 18:13
ooooh, I see, thanks @sjames1958gm
CamperBot
@camperbot
Jan 22 2018 18:13
g-4-r-y sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8879 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Jan 22 2018 18:13
@camperbot :+1:
G-4-R-Y
@G-4-R-Y
Jan 22 2018 18:14
and can I get the properties's values?
Javier Pons
@JavierPons
Jan 22 2018 18:14
hi all!
ogwel5
@ogwel5
Jan 22 2018 18:14
hey, kindly can someone help me with JS
Stephen James
@sjames1958gm
Jan 22 2018 18:15
@G-4-R-Y Object.values does the same with values.
@JavierPons :wave:
G-4-R-Y
@G-4-R-Y
Jan 22 2018 18:15
tyyyyyyyy <3
Stephen James
@sjames1958gm
Jan 22 2018 18:15
@ogwel5 What do you need?
ogwel5
@ogwel5
Jan 22 2018 18:17
i am trying to figure out how to locate a string in a string.....so the problem here is how the index of counts ....like how does this ends up to be 7 @sjames1958gm
var str = "Please locate where 'locate' occurs!";
var pos = str.indexOf("locate");
Stephen James
@sjames1958gm
Jan 22 2018 18:18
@ogwel5 The index of the first letter is zero, so starting from zero "locate" is at index 7
Javier Pons
@JavierPons
Jan 22 2018 18:19

What Im doing wrong with this code?

function doVaro() {
   console.log ('Aqui conecta');
   const doDiv = document.createElelment('div');
    doDiv.style.width = "3rem";
    doDiv.style.height= '5rem';
    doDiv.style.color= 'white';


}

 document.getElementById('firstVaro').appendChild(div);

Uncaught TypeError: document.createElelment is not a function
at doVaro (code.js:3)

Stephen James
@sjames1958gm
Jan 22 2018 18:19
@ogwel5 In many, if not most programming languages, when accessing arrays and strings and such, indexing starts at zero
ogwel5
@ogwel5
Jan 22 2018 18:19
@sjames1958gm so 0 is letter p of Please?
Stephen James
@sjames1958gm
Jan 22 2018 18:19
@JavierPons createElelment should be createElement
@ogwel5 Yes 0 is "P" of "Please"
Javier Pons
@JavierPons
Jan 22 2018 18:20
:worried: @sjames1958gm
SAURABH SHEORAIN
@SSheorain
Jan 22 2018 18:20
hey .. can anyone help me with progress bar
in html
Javier Pons
@JavierPons
Jan 22 2018 18:22
@sjames1958gm Cannot read property 'appendChild' of null
at code.js:11?
Stephen James
@sjames1958gm
Jan 22 2018 18:23
@JavierPons that tells me you have no element with id="firstVaro"
Javier Pons
@JavierPons
Jan 22 2018 18:23
I changed by 'doVaro'
I have a empty div
@sjames1958gm I want that when the button is press created a white square
Stephen James
@sjames1958gm
Jan 22 2018 18:25
  1. Do you ever call this function doVaro()
  2. That function doesn't set the id of doDiv
  3. Do you add the element doDiv to the DOM?
Javier Pons
@JavierPons
Jan 22 2018 18:26
mm...
@sjames1958gm How I can add element doDiv to the DOM?
Stephen James
@sjames1958gm
Jan 22 2018 18:28
@JavierPons I am not clear exactly what you are trying to do.
I am guessing maybe this?
function doVaro() {
   console.log ('Aqui conecta');
   const doDiv = document.createElelment('div');
    doDiv.style.width = "3rem";
    doDiv.style.height= '5rem';
    doDiv.style.color= 'white';
  return doDiv;
}
 document.getElementById('firstVaro').appendChild(doVaro());
Javier Pons
@JavierPons
Jan 22 2018 18:32

@sjames1958gm No working yet.... mmm... I have

<div class="float-right" id="firstVaro"></div>

<section id="front">
        <div id="cover-caption">
           <continer >
           <div class="col-sm-12 col-sm-offset-1 text-center">
            <div>Code</div>
            <br>
            <br>
            <div class="col-sm-3 float-left">
            <button type="button" class="btn btn-success">Kuvat</button>
            <br>
            <br>
            <button type="button" class="btn btn-warning" onclick='doVaro();'>Varo</button>

            <div class="float-right" id="firstVaro"></div>
        </div>
            </div>
        </continer>
        </div>
    </section>
Mirko Sorbara
@arabros92
Jan 22 2018 18:33
For general setting (bg color, color, ff ecc) in style.css is better to define html or body?
Javier Pons
@JavierPons
Jan 22 2018 18:34
@sjames1958gm Uncaught TypeError: Cannot read property 'appendChild' of null
at code.js:11
(anonymous) @ code.js:11
Stephen James
@sjames1958gm
Jan 22 2018 18:35
document.getElementById('firstVaro').appendChild(doDiv);
Put this inside your function (in place of the return
You are probably getting that error because the getElementById is running too soon before the page is ready
Javier Pons
@JavierPons
Jan 22 2018 18:37
It has created an limited loop
:worried:
Stephen James
@sjames1958gm
Jan 22 2018 18:38
@JavierPons document.getElementById('firstVaro').appendChild(doDiv); << this is changed to not call the function.
function doVaro() {
   console.log ('Aqui conecta');
   const doDiv = document.createElelment('div');
    doDiv.style.width = "3rem";
    doDiv.style.height= '5rem';
    doDiv.style.color= 'white';
   document.getElementById('firstVaro').appendChild(doDiv); // This adds doDiv to DOM
}
Kaz Baig
@kbaig
Jan 22 2018 18:40
@arabros92 this might help https://css-tricks.com/html-vs-body-in-css/
Mirko Sorbara
@arabros92
Jan 22 2018 18:42
@kbaig thank you!
CamperBot
@camperbot
Jan 22 2018 18:42
arabros92 sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 544 | @kbaig |http://www.freecodecamp.org/kbaig
Javier Pons
@JavierPons
Jan 22 2018 18:43
@sjames1958gm perfect. I changed color per backgroundColor
@sjames1958gm thanks a lot. That help it means a lot to me more that you think!
CamperBot
@camperbot
Jan 22 2018 18:43
javierpons sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8880 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Jan 22 2018 18:43
@JavierPons :+1:
krckyboy
@krckyboy
Jan 22 2018 18:43
Hey, guys. I'm wondering if watchandcode.com teaches only vanilla javascript or it offers any frameworks and other tools that a developer uses nowadays?
Brad
@bradtaniguchi
Jan 22 2018 19:21
@krckyboy I'm unfamilair with this site, but from the looks of it the site has 2 courses only, and the top rated comments are 2 years old
Dennis Onder
@ShadowpathHD
Jan 22 2018 19:26
Can i get some help? Stuck on golf code :c
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == 1) {
    return "Hole-in-one!";
  }
  else if (par + 3) {
  return "Go Home!";
}
  else if (par + 2) {
    return "Double Bogey";
  }
  else if (par + 1) {
    return "Double Bogey";
  }
  else if (par == strokes) {
    return "Par";
  }
  else if (par - 1) {
    return "Birdie";
  }
  else if (par - 2) {
    return "Eagle";
  }
  else {
  return "Change Me";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Olga
@OStefani
Jan 22 2018 19:27
@krckyboy only vanilla JS. I read good reviews on his courses but didn't take it
Tom
@moT01
Jan 22 2018 19:28
@ShadowpathHD your if tests dont look right
if(par + 3)
maybe something like if (stroke - par == 3)
Aryan J
@AryanJ-NYC
Jan 22 2018 19:29
or stroke === par + 3
@krckyboy What are you looking for in a course like that? Are you hoping to watch live coding?
Also, would anyone here be interested in a FCC user guide? Perhaps a guide to the exercises?
Or maybe even a collection of videos?
Olga
@OStefani
Jan 22 2018 19:36
@AryanJ-NYC which videos?
Aryan J
@AryanJ-NYC
Jan 22 2018 19:38
@OStefani Sorry. I was asking if anyone would be interested in a collection of videos on completing FCC.
Olga
@OStefani
Jan 22 2018 19:42
oh ok :) FCC lessons look very detailed.
Dennis Onder
@ShadowpathHD
Jan 22 2018 20:39

var count = 0;

function cc(card) {
  // Only change code below this line
if (card == 2,3,4,5,6) {
  count = 1;
  return = card + " Bet";
}  
  else if (card == 7,8,9) {
    count = 0;
    return = card + " Hold";
  }
  else if (card == 10,"J","Q","K","A") {
    count = -1;
    return = card + " Hold";
  }
  else {
  return "Change Me";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
whats wrong with this one? im doing the counting cards challenge
Kaz Baig
@kbaig
Jan 22 2018 20:39
@ShadowpathHD This is invalid
(card == 2,3,4,5,6)
replace with card == 2 || card == 3 etc
That may not be the only issue but give it a try. One at a time :)
Christopher McCormack
@cmccormack
Jan 22 2018 20:58
@ShadowpathHD count should be changing over time, but you're simply assigning a value to it for each function call. For example, if you called cc(2) then cc(2), count should become 2, not 1 as you currently have it
Stephen James
@sjames1958gm
Jan 22 2018 20:58
@ShadowpathHD Also, will then return a string with the current count and . . . the return contains the count not the card
Dennis Onder
@ShadowpathHD
Jan 22 2018 21:00
well i ended up finding the solution on the hint page lol
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 21:09
Hey, any wiz kids out here?
I have quite an annoying problem.
Tom
@moT01
Jan 22 2018 21:13
whats the problem @ICodedGod
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 21:19
I have a bunch of whitespace under my footer, and I can't seem to get rid of it.
Tom
@moT01
Jan 22 2018 21:21
do you have your project somewhere we can see? make the content bigger
Aryan J
@AryanJ-NYC
Jan 22 2018 21:22
@ICodedGod Difficult to help without a link to code.
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 21:24
Sure
I tried to set a max height, which fixes the problem. But then you get some annoying inner-scrollbar
I've got the seperate files here, I haven't got them online (like in codepen or anything. What would be wise?
Tom
@moT01
Jan 22 2018 21:26
put them online
you know flexbox at all?
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 21:29
not yet, but im about to find out
Juan Gonzalez Jr.
@1moosey1
Jan 22 2018 21:30
Tom
@moT01
Jan 22 2018 21:30
you set a max height and it fixed it - cept for the scroll bar? you mean min-height? - pretty sure you can hide the scroll bars
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 21:30
no, mean max-height, that fixed it
Dan Lafferty
@DanLaff
Jan 22 2018 21:36
@ICodedGod Put it in a codepen and it will be easier to help. There are several reasons why you might have white space below your footer - impossible to help without seeing the code.
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 21:36
allright
wait perhaps this helps
Kaz Baig
@kbaig
Jan 22 2018 21:37
Found an interesting article on r/webdev discussing high level design philosophies in relation to UI
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 21:37
https://uparoo.co.uk/ this is the original site. There have been some changes, but it has the same whitespace problem
Kaz Baig
@kbaig
Jan 22 2018 21:39
@ICodedGod it's happening because of
.section {
    padding: 80px 0;
}
found using inspect element
So you can either do
#pricing {
    padding-bottom: 0;
}
or you could make the last .section padding-bottom 0 as well
Dan Lafferty
@DanLaff
Jan 22 2018 21:41
Looks to me that they're missing a closing /div for their .section
Kaz Baig
@kbaig
Jan 22 2018 21:41
Yeah that could be it too, I'm just assuming it's a styling problem
Not using my brain :D
Dan Lafferty
@DanLaff
Jan 22 2018 21:43
Wonder if uparoo is hiring Front End developers :p they should be lol
Kaz Baig
@kbaig
Jan 22 2018 21:48
It seems that *roo is the equivalent of *ly for British startups
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 23:09
@DanLaff I need you to know that I love you
Dan Lafferty
@DanLaff
Jan 22 2018 23:10
:fire: :fire:
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 23:35
@DanLaff can I just ask, how did you spot that? I wrote an entire JS script to overkill it, but failed to notice that little bit
Dan Lafferty
@DanLaff
Jan 22 2018 23:38
@ICodedGod I right-clicked the white space below the footer and selected "inspect" - it brings up a developer tool and shows the HTML. In the HTML, that <div id="pricing" class="section"...> div was highlighted for me already, and when I expanded it, I noticed that the footer was inside it - (no </div> tag before the footer).
I think it's just a matter of getting comfortable with the Chrome developer tools - eventually issues like that get easier to notice
supercalifragilisticthisbesuchacodekid
@ICodedGod
Jan 22 2018 23:52
yes, I figured that out after you mentioned it. Damn it, you fixed a lot of pain in my face