These are chat archives for FreeCodeCamp/HelpJavaScript

1st
Mar 2017
Chris Jantzen
@XXiphias
Mar 01 2017 00:00
@haseebuchiha look into the array methods push and shift
Moisés Man
@moigithub
Mar 01 2017 00:00
@haseebuchiha HOW do u add elements to the end of the array
and HOW u remove first element from the array??
.. review this
Manipulate Arrays With push() Complete
Manipulate Arrays With pop() Complete
Manipulate Arrays With shift() Complete
Manipulate Arrays With unshift()
Chris Jantzen
@XXiphias
Mar 01 2017 00:00
that is all you need to complete that
Haseeb Arshad
@haseebuchiha
Mar 01 2017 00:01
@XXiphias @moigithub Thanks Guys I'll look into it
CamperBot
@camperbot
Mar 01 2017 00:01
haseebuchiha sends brownie points to @xxiphias and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2757 | @moigithub |http://www.freecodecamp.com/moigithub
:cookie: 358 | @xxiphias |http://www.freecodecamp.com/xxiphias
Pieter Stokkink
@forkerino
Mar 01 2017 00:01
@charlesdarkwind you don't have to go over the props in collection[i], just the ones of source. Then inside you can use .hasOwnProperty to check if the prop is in the collection[i] object and also to check if their values are the same.
Rene Villa
@renevilla
Mar 01 2017 00:02

hi everyone - i have a question regarding better coding technique(which solution is better)[testing objects for properties] which is better? first solution or second?
FIRST

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
function checkObj(checkProp) {
  // Your Code Here
  var object = myObj.hasOwnProperty(checkProp);
  if(object){
    return myObj[checkProp];
  } else {
    return "Not Found";
  }

}

// Test your code by modifying these values
checkObj("gift");

SECOND

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
function checkObj(checkProp) {
  // Your Code Here

  if(myObj.hasOwnProperty(checkProp)){
    return myObj[checkProp];
  } else {
    return "Not Found";
  }

}

// Test your code by modifying these values
checkObj("gift");
grahamhsu
@grahamhsu
Mar 01 2017 00:02
can someone help me with truncate a string? I'm not quite sure how to subtract the length of the dots.
Pieter Stokkink
@forkerino
Mar 01 2017 00:03
@grahamhsu -3
grahamhsu
@grahamhsu
Mar 01 2017 00:03
but than absolutely longer, 2 doesn't work right pieter?

here's my code also
function truncateString(str, num) {
var dotStr = "...";
if (str.length <=3 ) {
return str.slice(0,num) + dotStr;
}
else if (str.length > num)
{
return str.slice(0,num-dotStr.length) + dotStr;
} else {
return str;
}
}

truncateString("Absolutely Longer", 2);

Rene Villa
@renevilla
Mar 01 2017 00:05
just asking in terms of code maintainability i suppose or better code practices
Pieter Stokkink
@forkerino
Mar 01 2017 00:05

@renevilla definitely second, but I prefer using the ternary operator:

return myObj.hasOwnProperty(checkProp) ? myObj[checkProp] : "Not Found";

this may be a little overwhelming at first, but with time they become very readable (unless you nest them too deep).

Jason Luboff
@JLuboff
Mar 01 2017 00:05
Can anybody comment on my color selection? You may have to open in the browser for functionality to work properly
http://codepen.io/jluboff/full/KaLOJd/
Pieter Stokkink
@forkerino
Mar 01 2017 00:05
@grahamhsu well if num is smaller than or equal to three, you don't have to subtract them.
Jasmin Parent
@charlesdarkwind
Mar 01 2017 00:06
@forkerino thanks haha, thats so simple now that I think about it this way... at least Im now an expert in every form of itterations...
CamperBot
@camperbot
Mar 01 2017 00:06
charlesdarkwind sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1285 | @forkerino |http://www.freecodecamp.com/forkerino
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:06

function uniteUnique(arr) {


  var flattened = [arguments[0], arguments[1], arguments[2]].reduce(function(a, b) {
  return a.concat(b);
}, []);

  return flattened;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Rene Villa
@renevilla
Mar 01 2017 00:06
@forkerino thanks for the insight, keep forgetting that the ternary operator exist :worried: i'll start using it in my examples. thanks!
CamperBot
@camperbot
Mar 01 2017 00:06
renevilla sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1286 | @forkerino |http://www.freecodecamp.com/forkerino
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:07
so far I got the concaneted array of all elements. I want to know if I could just sort it out
Haseeb Arshad
@haseebuchiha
Mar 01 2017 00:07
I keep getting this error
TypeError: nextInLine.push is not a function
Jason Luboff
@JLuboff
Mar 01 2017 00:07
@haseebuchiha You should be using arr not nextInLine
nextInLine is your function name
Pieter Stokkink
@forkerino
Mar 01 2017 00:07
@charlesdarkwind :) Another hint: when I had a solution similar to yours, I had to use a flag inside the for ... in loop to keep track of whether or not the object matched. And push it onto an array only after.
Chris Jantzen
@XXiphias
Mar 01 2017 00:08
oh wow. i just learned about ES6's rest operator. That is so much nicer than using arguments...
Pieter Stokkink
@forkerino
Mar 01 2017 00:09
@XXiphias you can even do both!
Chris Jantzen
@XXiphias
Mar 01 2017 00:09
in one function? what would be the use?
Pieter Stokkink
@forkerino
Mar 01 2017 00:09
exactly!
Chris Jantzen
@XXiphias
Mar 01 2017 00:09
haha well I guess it's always handy to have options :D
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:10
guys if I wana get all arguments passed to my function, do i use arguments[i] would that work inside array?
Pieter Stokkink
@forkerino
Mar 01 2017 00:10
@XXiphias arguments is still useful in some cases where you need to for example extract the last argument of a function with an unspecified amount of arguments.
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:10
inside loop sorry
Jason Luboff
@JLuboff
Mar 01 2017 00:10
@pshiwakoti1 You can use arguments[i] but you would need to be incrementing i
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:10
true
Chris Jantzen
@XXiphias
Mar 01 2017 00:11
@forkerino Wouldnt it be the same process to get the last with both? Only way I can think of quickly doing it is with args.pop(). And with arguments you would need to convert it to an array first. Or is there some better way im not thinking of?
grahamhsu
@grahamhsu
Mar 01 2017 00:12
is it possible to force a number to becoming positive in javascript
Jason Luboff
@JLuboff
Mar 01 2017 00:12
@grahamhsu Yes Math.abs()
Chris Jantzen
@XXiphias
Mar 01 2017 00:12
@grahamhsu Math.abs(x);
grahamhsu
@grahamhsu
Mar 01 2017 00:12
ty
Chris Jantzen
@XXiphias
Mar 01 2017 00:12
abs for absolute
Jason Luboff
@JLuboff
Mar 01 2017 00:13
It can also be used to convert numbers to negative like so: -Math.abs()
Pieter Stokkink
@forkerino
Mar 01 2017 00:13
@XXiphias you are right. I remember there was a case where arguments was still useful, but I obviously misremembered.
Chris Jantzen
@XXiphias
Mar 01 2017 00:13
ahh ok. Well thanks regardless @forkerino :) Always useful to learn new things!
CamperBot
@camperbot
Mar 01 2017 00:13
xxiphias sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1287 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Mar 01 2017 00:15
@XXiphias I did use ...arguments on some occasions.
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:15


function uniteUnique(arr) {
  var flattened = [];
  for(var i=0; i<arr.length; i++){

  flattened = [arguments[i]].reduce(function(a, b) {
    if(a< b){
        return a.concat(b);
    }
   }, []);




  }

  return flattened;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
what is wrong with my code?
im getting [2,1] array only
Jason Luboff
@JLuboff
Mar 01 2017 00:17
TicTacToe officially turned in! Now onto Simon.....
Chris Jantzen
@XXiphias
Mar 01 2017 00:17
Nice :) ive been putting off doing those advanced projects and instead trying out some of the beta. they've got a lot of useful new content in it
although I am looking forwards to doing those projects
Jason Luboff
@JLuboff
Mar 01 2017 00:18
@XXiphias Ya...I put off the pomodoro for several months...finished it 2? weeks ago and now just finishing up TTT
Chris Jantzen
@XXiphias
Mar 01 2017 00:18
haha nice :P
grahamhsu
@grahamhsu
Mar 01 2017 00:18
still having trouble with truncate a string...help would be appreciated
Chris Jantzen
@XXiphias
Mar 01 2017 00:18
well almost there then
grahamhsu
@grahamhsu
Mar 01 2017 00:19

function truncateString(str, num) {
var dotStr = "...";
if (str.length <=3 ) {
return str.slice(0,num) + dotStr;
}
else if (str.length > num)
{
return str.slice(0,num-3) + dotStr;
} else {
return str;
}
}

truncateString("Absolutely Longer", 2);

I'm getting a negative value on num-3 causing it to only erase the r

Chris Jantzen
@XXiphias
Mar 01 2017 00:19
@pshiwakoti1 what is this supposed to do? [arguments[i]]
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:19
supposed to give me arguments passsed to it
Pieter Stokkink
@forkerino
Mar 01 2017 00:20
@grahamhsu you have to compare str.length to num and num to 3 in your function. Not str.length to 3.
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:20
oh ok should I start with 1 index then
Chris Jantzen
@XXiphias
Mar 01 2017 00:20
square brackets are used to access a part of an array
grahamhsu
@grahamhsu
Mar 01 2017 00:20
ah ty pieter
Chris Jantzen
@XXiphias
Mar 01 2017 00:20
square brackets around all of arguments1... im not sure if theyd be ignored or cause an error
grahamhsu
@grahamhsu
Mar 01 2017 00:20
that makes a lot of sense now pieterTT
boy i feel dumb
cassv
@cassv24
Mar 01 2017 00:21
@pshiwakoti1 you need to use arguments and convert it to an array and work with it
Chris Jantzen
@XXiphias
Mar 01 2017 00:21
@grahamhsu you can just subtract 3 from num if num is greater than 3. that will deal with the "length of 3" issues.
cassv
@cassv24
Mar 01 2017 00:22
@pshiwakoti1 arr would be only the first array passed
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:24
ok
so arguments[0] would refer to the first array passed right
Pieter Stokkink
@forkerino
Mar 01 2017 00:25
I'm off ! Have a good one!
forkerino @forkerino :sleeping:
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:25
see you thanks for helping @forkerino
CamperBot
@camperbot
Mar 01 2017 00:25
pshiwakoti1 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1288 | @forkerino |http://www.freecodecamp.com/forkerino
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:26
@cassv24 can u give me some more hints
Im kinda stuck
Chris Jantzen
@XXiphias
Mar 01 2017 00:27
nn @forkerino :)
Jason Luboff
@JLuboff
Mar 01 2017 00:27
@forkerino Night
Chris Jantzen
@XXiphias
Mar 01 2017 00:27
@pshiwakoti1 lookup how to change arguments into an array. You probably need to do that before anything else
ABitOfKylie
@ABitOfKylie
Mar 01 2017 00:27

@forkerino re Caesar Cipher -- so, if I understand you correctly then I would add: if(str.charCodeAt(i) == 32){
return(i); ??? -- repeating my revised code here which returns "FREE-CODE-CAMP"

function rot13(str) {
var remainder = [];

for(var i =0; i<str.length; i++){ if(str.charCodeAt(i) +13 >90){
remainder.push(String.fromCharCode(str.charCodeAt(i)-13));
}
else{
remainder.push(String.fromCharCode(str.charCodeAt(i) + 13));
}
}
return remainder.join(" ");
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Chris Jantzen
@XXiphias
Mar 01 2017 00:30
I think he just went to bed @ABitOfKylie what issue are you having?
Hello911
@Hello911
Mar 01 2017 00:30
Do you guys actually study the syntax of JSON? The FCC challenges just asks you to copy and paste the code
Chris Jantzen
@XXiphias
Mar 01 2017 00:31
the syntax of json is exactly the same as the syntax of javascript objects
so if you use those while doing the lessons, you'll learn it fast enough
ABitOfKylie
@ABitOfKylie
Mar 01 2017 00:31
@XXiphias -- current code returns FREE-CODE-CAMP, which is almost there but should return FREE CODE CAMP
cassv
@cassv24
Mar 01 2017 00:31
@pshiwakoti1 you can convert it to an array with var args = Array.from(arguments);
Chris Jantzen
@XXiphias
Mar 01 2017 00:31
you will need to use json in the intermediate projects
Hello911
@Hello911
Mar 01 2017 00:31
No the syntax is very differnet from regular javascript. There is $
everywhere
Chris Jantzen
@XXiphias
Mar 01 2017 00:32
$ symbols in your json..?
Gulsvi
@gulsvi
Mar 01 2017 00:32
j$on ?
Jason Luboff
@JLuboff
Mar 01 2017 00:32
@Hello911 Are you sure you're not confusing jQuery with JSON? I should have said you can get JSON using jQuery
Hello911
@Hello911
Mar 01 2017 00:32
 $("#getMessage").on("click", function() {
      $.getJSON("/json/cats.json", function(json) {

        var html = "";
        // Only change code below this line.



        // Only change code above this line.

        $(".message").html(html);
Chris Jantzen
@XXiphias
Mar 01 2017 00:32
ya... thats jquery
Hello911
@Hello911
Mar 01 2017 00:32
I dont know the difference
Chris Jantzen
@XXiphias
Mar 01 2017 00:32
that is getting a json string from the file cats.json
@ABitOfKylie so you just want to strip out - chars? If so find the char code for it and if that char code, return a space instead
Hello911
@Hello911
Mar 01 2017 00:33
The syntax look from differnt from Javascript
Jason Luboff
@JLuboff
Mar 01 2017 00:33
@Hello911 jQuery is a library of Javascript
Hello911
@Hello911
Mar 01 2017 00:33
Do you guys use W3 school from Jqury and JSON?
Chris Jantzen
@XXiphias
Mar 01 2017 00:33
Yes, that is jquery syntax @Hello911. well technically it's javascript syntax but jquery is a library that adds new functions and methods. Anythign starting with a $ is generally a jquery method
Hello911
@Hello911
Mar 01 2017 00:34
@SkyCoder01 Yeah, that looks like JS object
Gulsvi
@gulsvi
Mar 01 2017 00:34
JSON = JS Object Notation
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:35

function uniteUnique(arr) {
  var flattened = [];

  var arrayArg=[];
  for (var i = 0; i < arguments.length; i++) {
    arrayArg = arguments[i];
  }

    flattened = arrayArg.reduce(function(a, b) {
    if(a< b){
        return a.concat(b);
    }
   }, []);








  return flattened;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
hi @XXiphias can you please suggest now what did i do wrong
Hello911
@Hello911
Mar 01 2017 00:35
What resource do you guys use to learn JQuery and JSON?
Ken Haduch
@khaduch
Mar 01 2017 00:35
@JLuboff - congrats on the 1000 BP!
Jason Luboff
@JLuboff
Mar 01 2017 00:35
@Hello911 Google :D But also the documentation. Documentation is key
@khaduch Thanks!
CamperBot
@camperbot
Mar 01 2017 00:35
jluboff sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2556 | @khaduch |http://www.freecodecamp.com/khaduch
Hello911
@Hello911
Mar 01 2017 00:36
is W3 School. The Document looks scarily complex
Stephen James
@sjames1958gm
Mar 01 2017 00:36
@pshiwakoti1 aren't a and b arrays? how can you do a < b
Chris Jantzen
@XXiphias
Mar 01 2017 00:36
@pshiwakoti1 You didnt take any of the other advice given to you... look back at what @cassv24 suggested
Hello911
@Hello911
Mar 01 2017 00:36
Is W3 School good? (I meant to say)
Jason Luboff
@JLuboff
Mar 01 2017 00:37
@Hello911 I use it from time to time but find the actual documentation to contain more information
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 00:37
sorry @XXiphias
Chris Jantzen
@XXiphias
Mar 01 2017 00:37
@Hello911 W3schools is ok for basic stuff, but not the greatest.
Ken Haduch
@khaduch
Mar 01 2017 00:37

@Hello911 - there are so many You Tube videos out there, if you're a visual learner or just have someone run through some examples and explanations and demos.

There are widely mixed opinions about w3schools. I've used them for a lot of things and like their format, but I've read where they have some things that are out of date, etc. But if you try it and it helps you, great!

Gulsvi
@gulsvi
Mar 01 2017 00:38
@pshiwakoti1 You seem to be going through these exercises very quickly
Hello911
@Hello911
Mar 01 2017 00:38
Is this the documentation for JQuery that you talked about? http://api.jquery.com/addClass/
Chris Jantzen
@XXiphias
Mar 01 2017 00:38
I found codeacademy's jquery course useful. It's pretty easy to learn and it makes writing things in javascript considerably easier. Especially if you want to do a lot of DOM manipulation
yes, that is their documentation @Hello911
Jason Luboff
@JLuboff
Mar 01 2017 00:39
@Hello911 That is for addClass, but yes that is the documentation website
Ken Haduch
@khaduch
Mar 01 2017 00:39
@Hello911 - go to google and search for "youtube beginner jquery and JSON" - a lot of links come up. I haven't tried them, but there are many!
Hello911
@Hello911
Mar 01 2017 00:39
And this for JSON?http://www.json.org/
Chris Jantzen
@XXiphias
Mar 01 2017 00:39
this gives you all of their functions https://api.jquery.com/
i dont know if JSON has an official documentation. but you don't really need it
if you learn javascript objects, you'll know JSON
Jason Luboff
@JLuboff
Mar 01 2017 00:40
@Hello911 JSON is just a format
Chris Jantzen
@XXiphias
Mar 01 2017 00:40
json is just a format
Jason Luboff
@JLuboff
Mar 01 2017 00:40
@XXiphias :joy:
Gulsvi
@gulsvi
Mar 01 2017 00:40
@Hello911 I started here and just went down the list: http://api.jquery.com/category/manipulation/
Chris Jantzen
@XXiphias
Mar 01 2017 00:40
haha what he said... :P
Hello911
@Hello911
Mar 01 2017 00:41
OK
tanyatiem
@tanyatiem
Mar 01 2017 00:41
Hi all...I need help with functions...

function convertToF(celsius) {
var fahrenheit;

return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

what am i missing
Jason Luboff
@JLuboff
Mar 01 2017 00:42
@tanyatiem You're missing the conversion
Ken Haduch
@khaduch
Mar 01 2017 00:42
@tanyatiem - the 1st question - do you see the equation in the instructions for that lesson? You're missing the implementation of that.
Chris Jantzen
@XXiphias
Mar 01 2017 00:42
@tanyatiem What do you mean? you have no code
Stephen James
@sjames1958gm
Mar 01 2017 00:42
@tanyatiem celsius will have the value to convert
use celisus and the formula F = C * 9/5 + 32 to set the local variable
cassv
@cassv24
Mar 01 2017 00:42
@Hello911 you could used the JSON-Handle Chrome extension to visualize the JSON in a colorful manner
tanyatiem
@tanyatiem
Mar 01 2017 00:43
ok, let me try...
cassv
@cassv24
Mar 01 2017 00:43
This mess would turn it into something readable : https://fcctop100.herokuapp.com/api/fccusers/top/alltime
there are many extensions like that for both Chrome and Firefox
tanyatiem
@tanyatiem
Mar 01 2017 00:44
thank you @sjames1958gm
CamperBot
@camperbot
Mar 01 2017 00:44
tanyatiem sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6085 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
tanyatiem
@tanyatiem
Mar 01 2017 00:44
thank you @JLuboff
CamperBot
@camperbot
Mar 01 2017 00:44
tanyatiem sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1004 | @jluboff |http://www.freecodecamp.com/jluboff
Kalin Parushev
@Kalinaki
Mar 01 2017 00:46
What should I add? Obviously when there is a whole separate word to compare my function fails. Any tips?
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  str= str.substring(str.length-1);
  if (str === target)
  return true;

  else
    if (str !==target)
    {return false;}
}

confirmEnding("He has to give me a new name", "name");
Stephen James
@sjames1958gm
Mar 01 2017 00:46
@Kalinaki perhaps use target.length with str.substring?
Kalin Parushev
@Kalinaki
Mar 01 2017 00:48
@sjames1958gm just thought of that but how would i write it?
str= str.substring(str.length-1).target.length ?
Stephen James
@sjames1958gm
Mar 01 2017 00:48
@Kalinaki research the substring parameters - there is a way to take off the end of the string
Kalin Parushev
@Kalinaki
Mar 01 2017 00:50
@sjames1958gm use it for indexEnd?
Chris Jantzen
@XXiphias
Mar 01 2017 00:52
pretty sure he's talking about the 2nd argument to substring
Stephen James
@sjames1958gm
Mar 01 2017 00:54
@Kalinaki I was thinking of substr which has different parameters:
Location at which to begin extracting characters. If a negative number is given, it is treated as strLength + start where strLength is the length of the string (for example, if start is -3 it is treated as strLength - 3.)
cassv
@cassv24
Mar 01 2017 00:54
@Kalinaki try this out str.substring(str.length - name.length);
Stephen James
@sjames1958gm
Mar 01 2017 00:55
@cassv24 that should be target.length not name.length
cassv
@cassv24
Mar 01 2017 00:55
if you console.log(str.substring(str.length - name.length)); will give you "name"
Kalin Parushev
@Kalinaki
Mar 01 2017 00:55
@cassv24 Thank you. Completed
CamperBot
@camperbot
Mar 01 2017 00:55
:cookie: 303 | @cassv24 |http://www.freecodecamp.com/cassv24
kalinaki sends brownie points to @cassv24 :sparkles: :thumbsup: :sparkles:
cassv
@cassv24
Mar 01 2017 00:56
@sjames1958gm yeah.. i just type that on my console :smile:
@Kalinaki you are welcome
Kalin Parushev
@Kalinaki
Mar 01 2017 00:56
@sjames1958gm I figured
Stephen James
@sjames1958gm
Mar 01 2017 00:56
@Kalinaki with substr you have done substr(-target.length)
Kalin Parushev
@Kalinaki
Mar 01 2017 00:57
@sjames1958gm I was looking for ways to enter the substing of the substing but whatever
its completed now
Sooraj
@S4j
Mar 01 2017 00:58
function palindrome(str) {
  // Good luck!
  if(str.split('').reverse().join('') == str)
    return true;
  else
    return false;
}



palindrome("malayalam");
Which command should I use to remove the special mcharcaters?
Can anybody help?
Jason Luboff
@JLuboff
Mar 01 2017 00:59
@S4j You need to use regex
Sooraj
@S4j
Mar 01 2017 00:59
oh
Stephen James
@sjames1958gm
Mar 01 2017 00:59
@S4j with replace
Sooraj
@S4j
Mar 01 2017 00:59
Ok let me try
Jasmin Parent
@charlesdarkwind
Mar 01 2017 01:01
Im still stuck at this problem guys; how can I make it so it wont push the object from "collection" as soon as the loop sees the first key match in "source" (wherefore art thou)

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  //return collection[0][Object.keys(collection[0])[0]]- access a VALUE from collection-
  //return Object.keys(source)[0]; - Key from source -
  // Only change code below this line
  //return Object.keys(collection[0])[0]; //- access a KEY from collection-
  //return Object.keys(collection[0])[0] == Object.keys(source)[0];
  //return Object.keys(collection[0])[0];
  //return Object.keys(collection[0])[1];
  //return source[Object.keys(source)[0]]; // value of source no quotes
  //return collection[0].hasOwnProperty(Object.keys(source)[0]);
  /*
  //for (var i = 0; i < collection.length;i++) {
    arr = collection.filter(function(val) {
      for (var x = 0; x < Object.keys(source).length;x++) { //iterate throught source keys
        //console.log (Object.keys(val));
        console.log(Object.keys(source)[x]);
        if (Object.keys(val) == Object.keys(source)[x]) {

          return val ;
        }        
      }

    });
   */ 
    //for (var j = 0; j < Object.keys(collection[i]).length;j++) { //itterate throught the obj key    

    //}           
  //}

  for (var i = 0; i < collection.length;i++) {
    for (var prop in collection[i]) {
      //console.log(collection[i][prop]);
      for (var propSour in source) {
       if (prop == propSour && collection[i][prop] == source[propSour]){
         arr.push(collection[i]);
       }
      }
    }
  }




  // Only change code above this line
  return arr;
}
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Stephen James
@sjames1958gm
Mar 01 2017 01:02
@charlesdarkwind You can use a boolean value set before the loop and tested after the loop.
.every is an array function that might help here as well
Jasmin Parent
@charlesdarkwind
Mar 01 2017 01:03
@sjames1958gm ok ill try that
ill try to think about something like that i mean
Chris Jantzen
@XXiphias
Mar 01 2017 01:04
Is there a reason the editor says that 'console' from console.log is not defined when using "use strict"; ?
Stephen James
@sjames1958gm
Mar 01 2017 01:05
@XXiphias it shouldnt
Chris Jantzen
@XXiphias
Mar 01 2017 01:05
hmm ok thanks. guess it's a bug
Stephen James
@sjames1958gm
Mar 01 2017 01:06
Show the code where you are seeing this>
ABitOfKylie
@ABitOfKylie
Mar 01 2017 01:06

RE: Caesar Cipher ok -- new round. note first if statement. Trying to accommodate 4 punctuation. (space = 32, exclamation mark = 33, question mark == 63 and period ==46 ). So if (i) == any one of these just return it in original form. ! ? and the period not recognized AND the space returns a red dot on the Free Code site (but just a regular space on the console).

function rot13(str) {
var remainder = [];

for(var i =0; i<str.length; i++){ if(str.charCodeAt(i)==32 || str.charCodeAt(i)==63 || str.charCodeAt(i)==33 || str.charCodeAt(i)==46){ remainder.push(String.fromCharCode(i)); } else if(str.charCodeAt(i) +13 >90){
remainder.push(String.fromCharCode(str.charCodeAt(i)-13));
}
else{
remainder.push(String.fromCharCode(str.charCodeAt(i) + 13));
}
}
return remainder.join(" ");
}
rot13("SERR CVMMN?");

Chris Jantzen
@XXiphias
Mar 01 2017 01:06
Ive been going through the beta lessons @sjames1958gm And it doesnt matter what the code is. Any lesson in the editor, if you use "use strict"; it tells you console is not defined if console.log is used
Stephen James
@sjames1958gm
Mar 01 2017 01:07
@XXiphias ah ok.
Chris Jantzen
@XXiphias
Mar 01 2017 01:07
@ABitOfKylie might I suggest using a regex string to only target alphabetical characters?
Stephen James
@sjames1958gm
Mar 01 2017 01:07
@ABitOfKylie certainly don't join with ' '
Chris Jantzen
@XXiphias
Mar 01 2017 01:07
ya, wanted to make sure it was a bug and not something im not aware of in relation to "use strict"
Stephen James
@sjames1958gm
Mar 01 2017 01:08
I don't recall that behavior of use strict
Chris Jantzen
@XXiphias
Mar 01 2017 01:08
ok. thanks @sjames1958gm
Stephen James
@sjames1958gm
Mar 01 2017 01:08
@ABitOfKylie It seems to me better to check if the charCode is in the range A - Z rather than all those special checks.
Chris Jantzen
@XXiphias
Mar 01 2017 01:09
ah.. that would be a good way to go too
ABitOfKylie
@ABitOfKylie
Mar 01 2017 01:09
@XXiphias -- yes regex would be a better solution. :-) @sjames1958gm - why not use .join(" ")
Chris Jantzen
@XXiphias
Mar 01 2017 01:09
probably even simpler than regex since you already have the char codes
Stephen James
@sjames1958gm
Mar 01 2017 01:09
@ABitOfKylie Use more lines - having all that code on one line is bad practice
Chris Jantzen
@XXiphias
Mar 01 2017 01:09
@ABitOfKylie " " adds a space between each letter ;)
Carey Van
@thisiscarey
Mar 01 2017 01:11
can I get help on Return Largest Numbers in Arrays? I realize that I need to somehow push the largestNumber in my j For loop to the fourLargest array, but I don't know how or where to do this in my code.

'''
function largestOfFour(arr) {
var fourLargest = [];
for (i = 0; i < arr.length; i++) {
for (j = 0; j < arr[i].length; j++) {
var largestNumber = 0;
if (arr[i][j] > largestNumber) {
arr[i][j] = largestNumber;
}
fourLargest = largestNumber;
}
}
return fourLargest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
'''

CamperBot
@camperbot
Mar 01 2017 01:11
:bulb: to format code use backticks! ``` more info
Carey Van
@thisiscarey
Mar 01 2017 01:11
function largestOfFour(arr) {
  var fourLargest = [];
  for (i = 0; i < arr.length; i++) {
    for (j = 0; j < arr[i].length; j++) {
      var largestNumber = 0;
      if (arr[i][j] > largestNumber) {
        arr[i][j] = largestNumber;
      }
      fourLargest = largestNumber;
    }
  }
  return fourLargest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Hello911
@Hello911
Mar 01 2017 01:12
html += "<img src = '" + val.imageLink + "' " + "alt='" + val.altText + "'>";
Is .imageLink a javscript? method? JQuery?
What does html+= mean?
Chris Jantzen
@XXiphias
Mar 01 2017 01:13
@Hello911 imageLink is a property of the object val. That is javascript. html += means concatenate the string on the right to html
Stephen James
@sjames1958gm
Mar 01 2017 01:13
@thisiscarey Isnt the output of the function supposed to be an array?
But you have set fourLargest to a number
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:15
guys how do i sort out the unique values?

function uniteUnique(arr) {


 var concatenatedArray = [];
  var k = 0;
  while (arguments[k]){
    concatenatedArray = concatenatedArray.concat(arguments[k]); 
    k++;
  }
   console.log(concatenatedArray);
  for(var j=0; j<concatenatedArray.length; j++){

    if(arguments[j]< arguments[j+1]){

    }
   }




}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, [1]]);
without removing the order of the first array
acarosell1
@acarosell1
Mar 01 2017 01:16

Hello. I am looking for advice on on the Profile Lookup challenge. The code works with number indexes that I have manually input. When I added the the "i" variable with the For Loop things ceased to work. What is wrong with this code ?:
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i <5; i++) {
if (contacts[i].firstName != firstName){
return "No such contact";
} else if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
} else return "No such property";
// Only change code above this line
}}

// Change these values to test your function
lookUpProfile("Harry","number");

Carey Van
@thisiscarey
Mar 01 2017 01:16
@sjames1958gm yes. I tried this code to try to push it to the array. Is it placed in the right spot?
function largestOfFour(arr) {
  var fourLargest = [];
  for (i = 0; i < arr.length; i++) {
    for (j = 0; j < arr[i].length; j++) {
      var largestNumber = 0;
      if (arr[i][j] > largestNumber) {
        arr[i][j] = largestNumber;
      }
      fourLargest.push(largestNumber);
    }
  }
  return fourLargest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stephen James
@sjames1958gm
Mar 01 2017 01:16
@acarosell1 Use contacts.length not 5 in the for loop
@thisiscarey that looks correct
Hello911
@Hello911
Mar 01 2017 01:17
@XXiphias Thanks
CamperBot
@camperbot
Mar 01 2017 01:17
hello911 sends brownie points to @xxiphias :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @xxiphias |http://www.freecodecamp.com/xxiphias
Dan Couper
@DanCouper
Mar 01 2017 01:17
@XXiphias console isn't defined, that's why you get it undefined: it's technically correct. There isn't an object called console in scope; it's not part of JS, it's just something thelat browsers implement. window.console.log might work
Stephen James
@sjames1958gm
Mar 01 2017 01:17
@acarosell1 you cannot return no such contact until all the contacts have been checked
Chris Jantzen
@XXiphias
Mar 01 2017 01:17
ah... very interesting. Good to know! Thank you @DanCouper :)
CamperBot
@camperbot
Mar 01 2017 01:17
xxiphias sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 527 | @dancouper |http://www.freecodecamp.com/dancouper
Carey Van
@thisiscarey
Mar 01 2017 01:17
I must have it in the wrong spot or something. it's returning all 0s
Stephen James
@sjames1958gm
Mar 01 2017 01:18
@thisiscarey is that not working
acarosell1
@acarosell1
Mar 01 2017 01:18
@sjames1958gm Good point. Thanks.
CamperBot
@camperbot
Mar 01 2017 01:18
acarosell1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6086 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
acarosell1
@acarosell1
Mar 01 2017 01:18
@sjames1958gm Thanks
CamperBot
@camperbot
Mar 01 2017 01:18
acarosell1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: acarosell1 already gave sjames1958gm points
Stephen James
@sjames1958gm
Mar 01 2017 01:19
@thisiscarey are you sure about your placement of largestNumber = 0 ?
Dan Couper
@DanCouper
Mar 01 2017 01:19
@XXiphias this is a stab in the dark, but I assume it's kinda hidden from the rest of the JS in scope for safety reasons, so there
Hello911
@Hello911
Mar 01 2017 01:19
What is Free Code Camp's cat photo JSON API? Is it an array?
Dan Couper
@DanCouper
Mar 01 2017 01:19
Is no way someone could manipulate the is using it
Ugh, fat fingers. JS, not is
Chris Jantzen
@XXiphias
Mar 01 2017 01:20
interesting. that would make sense
@Hello911 it is JSON. It returns a JSON object
Carey Van
@thisiscarey
Mar 01 2017 01:22
Not at all, but I've moved it around so many times. I basically just trying every combination, which feels like cheating. I felt like it was right the first time
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:22
@sjames1958gm will you please look into my code
rsenter1993
@rsenter1993
Mar 01 2017 01:24
Hey all
I'm having a bit of trouble with trying to defined this operator
myVar = i++;
i = 1;
Sooraj
@S4j
Mar 01 2017 01:25
Still stuck with palindrome
Replace is confusing
How do I ignore the special characters and whitespaces using replace
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:26
can someone help ?
Sooraj
@S4j
Mar 01 2017 01:26
str.replace(/\s+/g).toLowerCase()
What regex should I use
ABitOfKylie
@ABitOfKylie
Mar 01 2017 01:26

@XXiphias -- so if using regex....when I do the following -- I get a space for every/any character. I was thinking: if the letter/char is not A-Z then push it to the array 'as is'.
if(str.charCodeAt(i)!== /A-Z/g){
remainder.push(String.fromCharCode(i));
}
now on my 6th hour...

alternatively.... if (str.charCodeAt(i) <65 || >90....

Christopher
@Chris2W
Mar 01 2017 01:27

var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;

Sooraj
@S4j
Mar 01 2017 01:27
@rsenter1993 what is the lesson number?
rsenter1993
@rsenter1993
Mar 01 2017 01:27
hold let me get it
Christopher
@Chris2W
Mar 01 2017 01:28
they ask me to convert variables a, b, and c to use the += operator. How would I do that?
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:28
@XXiphias will you please look into my code
Christopher
@Chris2W
Mar 01 2017 01:28

var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;

rsenter1993
@rsenter1993
Mar 01 2017 01:28
I'm on 128
Sooraj
@S4j
Mar 01 2017 01:29
Increment a number javascript?? Is that the lesson?
rsenter1993
@rsenter1993
Mar 01 2017 01:29
Thats it
Christopher
@Chris2W
Mar 01 2017 01:30
nvm i got it
Sooraj
@S4j
Mar 01 2017 01:31
Great. So here we are just trying to make myVar which is 87 to 88. i.e we are incrementing it's value to + 1
SD
@sourish33
Mar 01 2017 01:31
Hey I'm on the Javascript lesson on camelCase, and I can't figure out the camelCase form of "studlyCapVar"- any ideas?
rsenter1993
@rsenter1993
Mar 01 2017 01:31
What do you have for code?
Sooraj
@S4j
Mar 01 2017 01:31
So we just have to use (variable name)++ and it will work
Christopher
@Chris2W
Mar 01 2017 01:32
@sourish33 that should be correct
Stephen James
@sjames1958gm
Mar 01 2017 01:32
@Chris2W
a += 12 is the same as a = a + 12
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:32
any help coming? im stuck
rsenter1993
@rsenter1993
Mar 01 2017 01:32
Put it in myVar ++?
Sooraj
@S4j
Mar 01 2017 01:32
Yep
rsenter1993
@rsenter1993
Mar 01 2017 01:32
Ahh oaky
Stephen James
@sjames1958gm
Mar 01 2017 01:33
@sourish33 The tests show all the correct variable formats
rsenter1993
@rsenter1993
Mar 01 2017 01:33
SD @sourish33 can you post your code?
Chris Jantzen
@XXiphias
Mar 01 2017 01:33
@ABitOfKylie close. You could do str[i].text(/a-z/g) in your if. Or usee what you put second, testing if charCode is <65 or >90. I think that should work just as well
Stephen James
@sjames1958gm
Mar 01 2017 01:33
@pshiwakoti1 Which challenge?
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:33
let me post my code
Sorted Union
Chris Jantzen
@XXiphias
Mar 01 2017 01:34
@pshiwakoti1 I dont know what your code is...
Sooraj
@S4j
Mar 01 2017 01:34
@sjames1958gm I am stuck with the replace
str.replace(/\s+/g).toLowerCase()
How do I ignore the white spaces?
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:34

function uniteUnique(arr) {


 var concatenatedArray = [];
  var k = 0;
  while (arguments[k]){
    concatenatedArray = concatenatedArray.concat(arguments[k]); 
    k++;
  }
   console.log(concatenatedArray);
  for(var j=0; j<concatenatedArray.length; j++){

    if(arguments[j]< arguments[j+1]){

    }
   }




}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, [1]]);
Carey Van
@thisiscarey
Mar 01 2017 01:34
@sjames1958gm I figured it out with this code. I think I had largestNumber=arr[i][j] flipped around, which I didn't think mattered, but now I realize it does. I move the largestNumber = 0 inside the first For loop. Still not quite sure why that needs to be there instead of the 2nd For loop, but it worked
function largestOfFour(arr) {
  var fourLargest = [];

  for (i = 0; i < arr.length; i++) {
    var largestNumber = 0;
    for (j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > largestNumber) {
        largestNumber = arr[i][j];   
      }
    }
    fourLargest.push(largestNumber);
  }
  return fourLargest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stephen James
@sjames1958gm
Mar 01 2017 01:34
@S4j you need a second value to do the replace
@thisiscarey largestNumber = 0 has to be between the two loops
Chris Jantzen
@XXiphias
Mar 01 2017 01:35
@S4j are you wanting to only target alphanumeric characters with regex?
Stephen James
@sjames1958gm
Mar 01 2017 01:35
@thisiscarey You need to reset the largest value when you start testing the next inner array
Chris Jantzen
@XXiphias
Mar 01 2017 01:35
if so you want /\w/g for your regex
Carey Van
@thisiscarey
Mar 01 2017 01:36
oh, gotcha. Thanks @sjames1958gm
CamperBot
@camperbot
Mar 01 2017 01:36
thisiscarey sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6087 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Andres Arias
@Drecoder
Mar 01 2017 01:37

// Setup
var a;
var b = 2;

// Only change code below this line

how can I suggest that the value of a = b and value of 2=7 obviously Im a newbie

Sooraj
@S4j
Mar 01 2017 01:37
@XXiphias So w will replace only the alpha numeric characters? what about the other special characters? Man I am confused early morning.
Chris Jantzen
@XXiphias
Mar 01 2017 01:37
@pshiwakoti1 you still havent turned arguments into an array. by default it is not one and you need to turn it into one to use it like you are doing
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:38
i concatenated the array and made one isn't it
Stephen James
@sjames1958gm
Mar 01 2017 01:38
@pshiwakoti1 consider using filter to remove the extra values from concatenate array.
Chris Jantzen
@XXiphias
Mar 01 2017 01:38
im not sure exactly what you're trying to do @S4j
Explain and I might be able to give better guidance :P
CamperBot
@camperbot
Mar 01 2017 01:38

freeCodeCamp Wiki:

:point_right: The freeCodeCamp wiki can be found on our forum.
Please follow the link and search there.
Stephen James
@sjames1958gm
Mar 01 2017 01:39
@Drecoder you need to assign 7 to a where assignment goes from right to left
ABitOfKylie
@ABitOfKylie
Mar 01 2017 01:39

@XXiphias -- This was a bust:

if(str.charCodeAt(i)<65 || str.charCodeAt(i) >90){


remainder.push(String.fromCharCode(i));

}

Cant find a string prototype "text" method... not sure whata you mean with : " str[i].text(/a-z/g)"

Chris Jantzen
@XXiphias
Mar 01 2017 01:39
oh sorry, did I say text? Meant test
its for testing it against a regex string
Stephen James
@sjames1958gm
Mar 01 2017 01:40
@ABitOfKylie just push str.charAt(i)
Prakash Shiwakoti
@pshiwakoti1
Mar 01 2017 01:40
thanks @XXiphias
CamperBot
@camperbot
Mar 01 2017 01:40
:cookie: 360 | @xxiphias |http://www.freecodecamp.com/xxiphias
pshiwakoti1 sends brownie points to @xxiphias :sparkles: :thumbsup: :sparkles:
Sooraj
@S4j
Mar 01 2017 01:41
@XXiphias Sure. How do I replace all the special characters and whitespace using replace and regex? Right now I have done str.replace(/\s+/g).toLowerCase() which I know is wrong because /\s is just for counting the white space. So I am literally stuck.
Stephen James
@sjames1958gm
Mar 01 2017 01:42
@S4j you need to replace with something
str.replace(/\s+/g, '')'
Chris Jantzen
@XXiphias
Mar 01 2017 01:42
@S4j do str.replace(/\W+/g).toLowerCase();
that will replace anything that is NOT alphanumeric
and ya, I guess replace it with something :P
Stephen James
@sjames1958gm
Mar 01 2017 01:42
@S4j or /[^A-Za-z0-9]/g
Sooraj
@S4j
Mar 01 2017 01:43
@sjames1958gm what is that ^ stand for? Doe sit stand for include all?
ABitOfKylie
@ABitOfKylie
Mar 01 2017 01:43
@sjames1958gm OMG!!! Thank you! I just didn't think of charAt was so stuck on charCodeAt and .fromCharCode. Thank you thank you!
CamperBot
@camperbot
Mar 01 2017 01:43
abitofkylie sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6088 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 01 2017 01:43
@S4j inside the [] ^ means negate the match
ABitOfKylie
@ABitOfKylie
Mar 01 2017 01:43
thanks to @XXiphias
CamperBot
@camperbot
Mar 01 2017 01:43
abitofkylie sends brownie points to @xxiphias :sparkles: :thumbsup: :sparkles:
:cookie: 361 | @xxiphias |http://www.freecodecamp.com/xxiphias
Kalin Parushev
@Kalinaki
Mar 01 2017 01:44
What is the easiest or the recommended project to start with from the Intermediated Front-End Projects for beginners???
Alex G
@glazey132
Mar 01 2017 01:44
can someone please explain to me what replace(); does and how regular expressions work?
Stephen James
@sjames1958gm
Mar 01 2017 01:44
@Kalinaki The quote project is a good one.
Alex G
@glazey132
Mar 01 2017 01:44
function palindrome(str) {
str = str.toLowerCase();
str = str.replace(/\w _/g, '');
var backwardString = str.reverse();
Stephen James
@sjames1958gm
Mar 01 2017 01:45
@Kalinaki You can provide an array of quotes if you don't want to do an API yet
@glazey132 string doesn't have reverse
/\w_/ will match a word character (letters, numbers and _) followed by _ this is not what you want.
Alex G
@glazey132
Mar 01 2017 01:47
got it got it change the string to an array.
Kalin Parushev
@Kalinaki
Mar 01 2017 01:48
API is needed for the weather I take it
Alex G
@glazey132
Mar 01 2017 01:48
what do you mean match a word? as in if char 1 and char 2 are == it returns true?\
@sjames1958gm
Matt K
@MattKim22
Mar 01 2017 01:49
Hello everyone. Just started my weather app challenge. Having a little trouble understanding what's wrong with my switch statement http://codepen.io/MattKim22/pen/vxONKj?editors=1111
obviously the design is still a work in progress, but trying to get the parts working first
Ngoc Hoan Vu
@Hoanvn1734
Mar 01 2017 01:50
Help me!
function isNumStr(obj) {
  return obj !== undefined && obj !== null && obj !== false && obj !== 0 && obj !== "" && !isNaN(obj);
}

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr.filter(isNumStr);
}

bouncer([7, "ate", "", false, 9]);
silver537
@silver537
Mar 01 2017 01:51
@MattKim22 you're better off with an if statement
Matt K
@MattKim22
Mar 01 2017 01:52
thanks for the reply. why's that?
Adam VanZuiden
@adamvz
Mar 01 2017 01:52
I can't seem to get the code to enter this for loop:

function mutation(arr) {
  for (var i = 0; i < arr.legnth; i++) {
    arr[i] = arr[i].toLowerCase();
  }
  return arr;
}
Joseph
@revisualize
Mar 01 2017 01:52
@Secret1734 So, if there was a built-in javascript function that did what you're trying to make with your function isNumStr ... Would you use it?
Christopher
@Chris2W
Mar 01 2017 01:53
can anyone help me on "Convert Celsius to Fahrenheit"?
Sooraj
@S4j
Mar 01 2017 01:53
@XXiphias @sjames1958gm Tried this. if(str.replace(/\W/g,'').toLowerCase() === str.replace(/\W/g, '').toLowerCase().split('').reverse().join(''))
Joseph
@revisualize
Mar 01 2017 01:53
@Chris2W Sure.
@Chris2W What is your current function declaration?
Sooraj
@S4j
Mar 01 2017 01:53
Getting the ans except for ("_eye"
and
("0_0 (: /-\ :) 0-0")
Joseph
@revisualize
Mar 01 2017 01:53
@S4j What is \W doing?
Matt K
@MattKim22
Mar 01 2017 01:54
@silver537 I had it as an if statement earlier, but thought maybe i'd have more cases, depending on where the user was located
Sooraj
@S4j
Mar 01 2017 01:54
Replacing everything except alphanumeric
Matt K
@MattKim22
Mar 01 2017 01:54
as of now, there are only three, but i can't even get them working correctly
Christopher
@Chris2W
Mar 01 2017 01:54

@revisualize function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Joseph
@revisualize
Mar 01 2017 01:55
@Chris2W Okay so, you haven't done anything. .. What is the mathematical formula to convert celsius to fahrenheit?
Sooraj
@S4j
Mar 01 2017 01:55
@revisualize
Christopher
@Chris2W
Mar 01 2017 01:55
C(9/5 +32) right?
Joseph
@revisualize
Mar 01 2017 01:55
@Chris2W That's mathematically correct. However JavaScript sees C() as a function call. Not as math. So, you have to be explicit.
Ngoc Hoan Vu
@Hoanvn1734
Mar 01 2017 01:56
@revisualize Yes
Christopher
@Chris2W
Mar 01 2017 01:56
ah
Joseph
@revisualize
Mar 01 2017 01:56
@Secret1734 Then why aren't you using Boolean like the lesson links you to?
Chris Jantzen
@XXiphias
Mar 01 2017 01:58
@S4J maybe console.log the output and see what those 2 give you so you can figure out where it's going wrong
silver537
@silver537
Mar 01 2017 01:58
@MattKim22 well there is another way to write a switch to simulate an if statement. But its redundant.
Christopher
@Chris2W
Mar 01 2017 01:58

@revisualize so this is what i got so far, but i have to do more similar to that
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fahrenheit= -22

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(-30);

Matt K
@MattKim22
Mar 01 2017 01:59
@silver537 do you know what's currently wrong with the switch statement i'm using? i feel like it's something really small
http://codepen.io/MattKim22/pen/vxONKj?editors=1111 : in case someone else wants to take a crack at it
Joseph
@revisualize
Mar 01 2017 02:00
@Chris2W But, that isn't reflecting the mathematical function.
Ngoc Hoan Vu
@Hoanvn1734
Mar 01 2017 02:00
@revisualize I don't know how to use it
Joseph
@revisualize
Mar 01 2017 02:00
@Secret1734 It's a built-in function.
Chris Jantzen
@XXiphias
Mar 01 2017 02:01
@MattKim22 for your switch you should make it switch (data.country) and then do the case statements like case 'US':
Matt K
@MattKim22
Mar 01 2017 02:02
@XXiphias ohh, is that why @silver537 was saying it'd be better off using an if statement?
Chris Jantzen
@XXiphias
Mar 01 2017 02:02
with that few things it might be easier as an if statement
but could do either
Derek B. McIntire
@derekbmcintire
Mar 01 2017 02:02
Hey all, I'm a bit stuck on the palindrome challenge. I've got it working except for removing special characters and white spaces - searched around for some sollutions, attempted writing a for loop to do it, but there has to be an easier way that I just don't know and haven't seen yet. Can someone point me in the right direction?
Matt K
@MattKim22
Mar 01 2017 02:03
Ok thanks @XXiphias and @silver537
CamperBot
@camperbot
Mar 01 2017 02:03
:cookie: 871 | @silver537 |http://www.freecodecamp.com/silver537
:cookie: 362 | @xxiphias |http://www.freecodecamp.com/xxiphias
Derek B. McIntire
@derekbmcintire
Mar 01 2017 02:03
I'm trying to remove them from either a string or an array, whichever is easier.
CamperBot
@camperbot
Mar 01 2017 02:03
mattkim22 sends brownie points to @xxiphias and @silver537 :sparkles: :thumbsup: :sparkles:
Chris Jantzen
@XXiphias
Mar 01 2017 02:03
@derekbmcintire could do a simple regex replace
silver537
@silver537
Mar 01 2017 02:04
@MattKim22 because switches look at the parameter you passed in and executes the cooresponding cases based on the value of that parameter.
Its not necessarily a true and false statement like the if.
Derek B. McIntire
@derekbmcintire
Mar 01 2017 02:04
what is regex?
I tried using .replace but it told me it wasn't a method?
acarosell1
@acarosell1
Mar 01 2017 02:04
@sjames1958gm Looks like I need more guidance. How would I set this up to return "No such contact" AFTER all the contacts have been checked through the loops?
Chris Jantzen
@XXiphias
Mar 01 2017 02:04
a parsing language
Matt K
@MattKim22
Mar 01 2017 02:05
@XXiphias @silver537 i changed it to data.country and it was literally the same thing.
Derek B. McIntire
@derekbmcintire
Mar 01 2017 02:05
Okay, I'll look into that more - thanks!
Matt K
@MattKim22
Mar 01 2017 02:05
it just keeps jumping down to the default
Chris Jantzen
@XXiphias
Mar 01 2017 02:05
look into the string.replace function @derekbmcintire
Stephen James
@sjames1958gm
Mar 01 2017 02:06
@acarosell1 not all code needs to be in the loop
Matt K
@MattKim22
Mar 01 2017 02:07
@silver537 yeah, but i'm not really looking to get boolean values, per se. I want it to execute the code based on what country they're in.
Joseph
@revisualize
Mar 01 2017 02:07
@derekbmcintire You have to use the String.replace() method on that lesson.
Well. you don't have to.
But, I think I suggest it.
ESLMiguel
@ESLMiguel
Mar 01 2017 02:08
Good morning all :sunrise_over_mountains:
Matt K
@MattKim22
Mar 01 2017 02:08
@silver537 If they're located in the US, I want it to show just the city and state. If they're located outside the US, to print the city and country
a switch statement would work just fine, i would imagine. But obviously something's wrong with the code itself somewhere
Sooraj
@S4j
Mar 01 2017 02:12
Thanks a lot for the help @sjames1958gm @XXiphias . I wasn't using the brackets, the squared one.
CamperBot
@camperbot
Mar 01 2017 02:12
s4j sends brownie points to @sjames1958gm and @xxiphias :sparkles: :thumbsup: :sparkles:
:star2: 6089 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 363 | @xxiphias |http://www.freecodecamp.com/xxiphias
Stephen James
@sjames1958gm
Mar 01 2017 02:13
@S4j :+1:
curiousNoob
@curiousNoob
Mar 01 2017 02:15
Any suggestions where I can get quote from?
acarosell1
@acarosell1
Mar 01 2017 02:15
@sjames1958gm If I put the following outside of the loop I have an "Illegal return statement" and perhaps an unassigned variable. I am not seeing how I can get through all the contacts THEN return the "No such contact" statement.: if (contacts[i].firstName != firstName){
return "No such contact";}
Stephen James
@sjames1958gm
Mar 01 2017 02:19
@acarosell1 you don't need an if because if you fall out of the loop you know you didn't find the contact.
Make sure you didn't put the return outside the function
@curiousNoob http://api.forismatic.com/
Joseph
@revisualize
Mar 01 2017 02:21
cbot
CamperBot
@camperbot
Mar 01 2017 02:21
you called?
Chris Jantzen
@XXiphias
Mar 01 2017 02:24
Could try this beta exercise out and let me know if it passes for them? https://beta.freecodecamp.com/en/challenges/basic-javascript/global-scope-and-functions
It's very simple, just 2 lines of code to complete. For me the last test will not pass.
Kerry
@CatManThing
Mar 01 2017 02:24
hello hello... I need some guidance... just doing the intro to javascript, the final lesson where you convert fahrenheit to celsius... it's a little embarrassing I'm so bad at math... I don't even know where to start really
Kalin Parushev
@Kalinaki
Mar 01 2017 02:24
@camperbot cbot Do you know any good jokes?
Joseph
@revisualize
Mar 01 2017 02:24
@CatManThing Do you know how to multiply and add?
Kerry
@CatManThing
Mar 01 2017 02:24
u.u yes
ESLMiguel
@ESLMiguel
Mar 01 2017 02:24
@CatManThing you need the formula to convert?
Joseph
@revisualize
Mar 01 2017 02:24
@CatManThing Then you're fine.
Kerry
@CatManThing
Mar 01 2017 02:25
jee thanks
Joseph
@revisualize
Mar 01 2017 02:25
@CatManThing So, first.. What is the mathematical formula for converting Celsius to Fahrenheit?
ESLMiguel
@ESLMiguel
Mar 01 2017 02:25
cbot
CamperBot
@camperbot
Mar 01 2017 02:25
you called?
Kerry
@CatManThing
Mar 01 2017 02:26
I got that but I don't know how to write the code
fahrenheit = celsius*9/5;
celsius += 32;
thats as far as i got ._.
Joseph
@revisualize
Mar 01 2017 02:28
@CatManThing You should just make that one line.
@CatManThing Because if you look at your order. You're supposed to modify and return fahrenheit but, you're adding 32 to celsius
Kerry
@CatManThing
Mar 01 2017 02:29
That's it?! ba haha... sigh...
thanks
Bryan Reese
@breese8009
Mar 01 2017 02:33
hey guys.... im having an issue with !obj.HasOwnProperty(key) in the if statement...anyone see any reason it wouldnt work correctly?
var obj = {
  key: [1, 2, 5]
};

function getLastElementOfProperty(obj, key){
  var lastNum=obj[key].length-1;

  if(!Array.isArray(obj[key]) || !obj.hasOwnProperty(key)){
    return undefined;
  }
 return obj[key][lastNum];
}
getLastElementOfProperty(obj, 'key');
@revisualize i know u can help me...u there? lol
Coy Sanders
@coymeetsworld
Mar 01 2017 02:36
code looks fine to me @breese8009
although you may want to check hasOwnProperty before anything else
Bryan Reese
@breese8009
Mar 01 2017 02:37
@coymeetsworld I thought so too...but !obj.hasOwnProperty(key) is giving me the problem
Coy Sanders
@coymeetsworld
Mar 01 2017 02:38
in that test csae?
*case
AJ
@DracIdea
Mar 01 2017 02:38
Hi guys, having problems figuring out how to resolve this challenge

function nextInLine(arr, item) {
// Your code here

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));

Coy Sanders
@coymeetsworld
Mar 01 2017 02:38
seems like the code will run fine
Stephen James
@sjames1958gm
Mar 01 2017 02:38
@DracIdea
Bryan Reese
@breese8009
Mar 01 2017 02:39
it wants me to return undefined if its not an array at the property or if there is no property
Stephen James
@sjames1958gm
Mar 01 2017 02:39
@DracIdea inside the function use the two parameters/variables arr and item
@breese8009 Any specific test case it is faiing on?
Bryan Reese
@breese8009
Mar 01 2017 02:39
@DracIdea its hard for ppl to help u if u havent written any code in an attempt to solve it
AJ
@DracIdea
Mar 01 2017 02:40
well the issue is I don't know where to start
Coy Sanders
@coymeetsworld
Mar 01 2017 02:40
yes, but what if obj has no property of the variable key @breese8009 ?
Stephen James
@sjames1958gm
Mar 01 2017 02:40
@DracIdea Do you recall how to add a value to the end of an array
AJ
@DracIdea
Mar 01 2017 02:40
@sjames1958gm Ok thx, ill start there
CamperBot
@camperbot
Mar 01 2017 02:40
dracidea sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6090 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Coy Sanders
@coymeetsworld
Mar 01 2017 02:40
you need to verify that the property exists first, then you can look at it
Bryan Reese
@breese8009
Mar 01 2017 02:40
error...should return undefined if the property does not exist
AJ
@DracIdea
Mar 01 2017 02:40
I believe it's with .push
Coy Sanders
@coymeetsworld
Mar 01 2017 02:41
im guessing you're running a different test case than the one listed, in which case then yeah its the order like I mentioned
Stephen James
@sjames1958gm
Mar 01 2017 02:41
@breese8009 I am concerted that .length will cause an error for case where key is not defined
@DracIdea :+1:
Coy Sanders
@coymeetsworld
Mar 01 2017 02:41
that too @sjames1958gm @breese8009, need to check if the property exists before doing anything with it
Stephen James
@sjames1958gm
Mar 01 2017 02:41
@coymeetsworld :+1:
Bryan Reese
@breese8009
Mar 01 2017 02:41
ohhh i think i seee what u guys mean...brb
@coymeetsworld @sjames1958gm thanks for ur time guys
CamperBot
@camperbot
Mar 01 2017 02:41
breese8009 sends brownie points to @coymeetsworld and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2230 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
:star2: 6091 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Coy Sanders
@coymeetsworld
Mar 01 2017 02:41
"although you may want to check hasOwnProperty before anything else"
yeah np
Bryan Reese
@breese8009
Mar 01 2017 02:42
@coymeetsworld im confused by that..
like put it in another if statement?
or put in a var
?
Coy Sanders
@coymeetsworld
Mar 01 2017 02:44
you need to verify the property of an object exists before your try to reference it, or else you're going to get an error
thats probably what's happening to you, in some other test case. Is this from FCC?
like what if they key was 'blah' instead of 'key'?
and you tried to access obj['blah'].length?
Bryan Reese
@breese8009
Mar 01 2017 02:44
@coymeetsworld im using the peramater key... the rest is a test case
Coy Sanders
@coymeetsworld
Mar 01 2017 02:44
it wouldn't return 0 for you
it would complain and say I don't know what obj['blah'] is, obj doesn't have that property
Bryan Reese
@breese8009
Mar 01 2017 02:45
@coymeetsworld i solved it!
@coymeetsworld thank u thanku
CamperBot
@camperbot
Mar 01 2017 02:45
breese8009 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: breese8009 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Mar 01 2017 02:45
np
Bryan Reese
@breese8009
Mar 01 2017 02:45
@sjames1958gm thank u too man!
CamperBot
@camperbot
Mar 01 2017 02:45
breese8009 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: breese8009 already gave sjames1958gm points
Coy Sanders
@coymeetsworld
Mar 01 2017 02:45
yeah need to verify property exists first
Bryan Reese
@breese8009
Mar 01 2017 02:45
love u guys
yep
Coy Sanders
@coymeetsworld
Mar 01 2017 02:45
like with variables
Seth
@rifen
Mar 01 2017 02:46
So I am totally confused on Profile Lookup. I don't think I am even in the right ballpack lol
Coy Sanders
@coymeetsworld
Mar 01 2017 02:46
cant print x without defining x right?
Seth
@rifen
Mar 01 2017 02:46
ballpark*
Bryan Reese
@breese8009
Mar 01 2017 02:46
funny u said that...when i looked further into the error and it said precisely that
Coy Sanders
@coymeetsworld
Mar 01 2017 02:47
yeah
Bryan Reese
@breese8009
Mar 01 2017 02:47
@coymeetsworld yep yep
Robert Richey
@0x0936
Mar 01 2017 02:49
@rifen what have you tried so far?
Seth
@rifen
Mar 01 2017 02:50
'''
for (var i = 0; i < contacts.length; i++) {
if (contacts.hasOwnProperty[i]) {
return contacts[firstName];
} else {
return "No such contact";
}
if (contacts.hasOwnProperty(prop)) {
return contacts[prop];
} else {
return "No such property";
}
}
'''
CamperBot
@camperbot
Mar 01 2017 02:50
:bulb: to format code use backticks! ``` more info
Seth
@rifen
Mar 01 2017 02:50
  for (var i = 0; i < contacts.length; i++) {
    if (contacts.hasOwnProperty[i]) {
      return contacts[firstName];
    } else {
      return "No such contact";
    }
    if (contacts.hasOwnProperty(prop)) {
      return contacts[prop];
    } else {
      return "No such property";
    }
  }
Uros Tadic
@urketadic
Mar 01 2017 02:50

Hello everyone. I am having a problem with playing video in a background of a header. I have set header height to 100vh (because i want it to take full height of viewport) But the problem is now, if i resize the browser, the video is no longer 100% of the header, it gets smaller and smaller the more i resize.

This is video css

video#bgvid { 
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    -ms-transform: translateX(-50%) translateY(-50%);
    -moz-transform: translateX(-50%) translateY(-50%);
    -webkit-transform: translateX(-50%) translateY(-50%);
    transform: translateX(-50%) translateY(-50%);
    background: url(placeholder.jpg) no-repeat;
    background-size: cover; 
}
Seth
@rifen
Mar 01 2017 02:52
But like I said I have no idea what's going on
Do I need like multiple for loops inside eachother ?
Robert Richey
@0x0936
Mar 01 2017 02:52
@rifen when iterating over an array, each iteration will represent one element in the array. So, iterating over the contacts array, each iteration will represent one contact. Use the current contact for checking properties and values.
Steven Failla
@Stevo99
Mar 01 2017 02:53
@rifen u are close
acarosell1
@acarosell1
Mar 01 2017 02:53

@sjames1958gm How can I get my "No such contact" loop fall out in there?://Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line

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

if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];}

}

return "No such property";

}

// Only change code above this line

// Change these values to test your function
lookUpProfile("Harry","chocolate");

Seth
@rifen
Mar 01 2017 02:56
@Stevo99 I am :O ok. I will keep at it.
Steven Failla
@Stevo99
Mar 01 2017 02:56
try if (contacts[i].??) remember when you use .someName to look into the data
not actually .someName verbatim
David Morales
@davmor94
Mar 01 2017 02:57
Hey guys, Im working on the Steamroller challenge. I'm trying to solve it using recursion but im stuck. Can anyone suggest how to tweak my code to make it work? Im so close, I can feel it. My funcion is returnin newArr after it meets the first array.

function steamrollArray(arr) {
var newArr=[];

//return Array.isArray(arr[2]);

//takes an array produces an array element thats not an array and pushes it into newArr
function recurseArr(a){

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

//recursion where you take the array element (also an array) and apply the same function until you get an element

if(Array.isArray(a[i])){
  //&& i==a.length

return recurseArr(a[i]);
}


//case where the original array element is not an array but an element already
else{
  newArr.push(a[i]);
}

}
//returns the finished newArr once the function has gone through the entire original array
return newArr;
}

//end of recurseArr

return recurseArr(arr);

}
//test [1, 2, [2, 3, [4, 5, [5], 6]],[2], [[[4]]]]

steamrollArray([1, 2, [2, 3], 2, [[[4]]]]);

Robert Richey
@0x0936
Mar 01 2017 03:00
@acarosell1 you'll have to iterate through all the contacts before being able to determine if there is no such contact
AJ
@DracIdea
Mar 01 2017 03:03
Still don't know how to go about solving this

function nextInLine(arr, item) {
// Your code here

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));

I know I need to push the item to the array, but i'm not sure how to do this properly
tareq4
@tareq4
Mar 01 2017 03:05

function nextInLine(arr, item) {
// Your code here

return item;

}

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));

nextInLine([], 1) should return 1 <<<<

how could i know the variable of item ?

tareq4
@tareq4
Mar 01 2017 03:06
@DracIdea me too!!
@0x0936 why? ... is it because too hard or that is the challeng
Jose
@navarrocantero
Mar 01 2017 03:07
hi friends, I have one question
tareq4
@tareq4
Mar 01 2017 03:08
i dont think i can awnser it @navarrocantero lol
Robert Richey
@0x0936
Mar 01 2017 03:08
@tareq4 that's what push and shift do. push adds an element at the end of the array. shift removes the first element.
Jose
@navarrocantero
Mar 01 2017 03:08
wait wait i think i have thath xd
tareq4
@tareq4
Mar 01 2017 03:08
yeah i know
@0x0936
Jose
@navarrocantero
Mar 01 2017 03:09
im here

// Only change code below this line.
if (!trueOrFalse) {

 return "No, that was false";

}else{
return "Yes, that was true";
}

tareq4
@tareq4
Mar 01 2017 03:10
@0x0936 but look ... maybe it will be a stupid question ,but
why do i need to do that in this challeng
they didn't ask
i mean the push
and shift
Robert Richey
@0x0936
Mar 01 2017 03:11
Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
AJ
@DracIdea
Mar 01 2017 03:13
I think it's the syntax I'm having the hardest time with
Robert Richey
@0x0936
Mar 01 2017 03:15
@DracIdea arrays have methods for processing the elements within them. among those methods include push and shift. To use these methods, type the variable name containing the array (also works on array literals) then use dot notation and call the array method.
var arr = [1, 2, 3];
arr.push(4); // [1, 2, 3, 4]
AJ
@DracIdea
Mar 01 2017 03:16
@0x0936 nextInLine = arr.push(item); ..... is this along the right path?
Robert Richey
@0x0936
Mar 01 2017 03:16
yeah
Missposhtee
@Missposhtee
Mar 01 2017 03:18

var myVar = 87;

// Only change code below this line
myVar = 87 + 1;

help it keeps saying i should use ++ operator
AJ
@DracIdea
Mar 01 2017 03:21

@0x0936
function nextInLine(arr, item) {
// Your code here
nextInLine = arr.shift(arr.push(item));
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));

Robert Richey
@0x0936
Mar 01 2017 03:21
@Missposhtee do you know what the ++ does?
tareq4
@tareq4
Mar 01 2017 03:21
@Missposhtee i think you should replace the + 1 with ++
AJ
@DracIdea
Mar 01 2017 03:21
This is what I have so far. Syntax seems wrong though
tareq4
@tareq4
Mar 01 2017 03:21
it will add 1
Robert Richey
@0x0936
Mar 01 2017 03:23
@DracIdea you're getting closer. just push to the array as one statement, on one line. then assign to item the result from calling shift on the array. then return item
Missposhtee
@Missposhtee
Mar 01 2017 03:28
@0x0936 @0x0936 yes i do...it is increment +1
Nanang Hidayat
@nanankhidayat
Mar 01 2017 03:28
hi "You should assign processArg to processed" what does mean?
Manish Giri
@Manish-Giri
Mar 01 2017 03:29
@nanankhidayat call the function processArg
and assign the result to the variable processed
Nanang Hidayat
@nanankhidayat
Mar 01 2017 03:29
ok thks
derekmortel
@derekmortel
Mar 01 2017 03:30

var Bike = function() {

// Only change code below this line.
var gear = 0;

this.getGear = function(change) {
gear += change;
};

this.setGear = function() {
return gear;
};
};

Robert Richey
@0x0936
Mar 01 2017 03:30

@Missposhtee that's right.

You can easily increment or add one to a variable with the ++ operator.

To increase myVar by one, how would you write that?

derekmortel
@derekmortel
Mar 01 2017 03:30
any advice for this? not too sure what I'm doing wrong
Manish Giri
@Manish-Giri
Mar 01 2017 03:30
@derekmortel first, your functions are reversed
Missposhtee
@Missposhtee
Mar 01 2017 03:30
@tareq4 i did and it gives error
Manish Giri
@Manish-Giri
Mar 01 2017 03:30
getGear is supposed to return the gear
setGear is supposed to set it
@derekmortel
AJ
@DracIdea
Mar 01 2017 03:31

@0x0936 function nextInLine(arr, item) {
// Your code here
arr.push(item);
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));
Warmer or colder lol

derekmortel
@derekmortel
Mar 01 2017 03:31
thanks @Manish-Giri . lemme see what I can do
CamperBot
@camperbot
Mar 01 2017 03:31
derekmortel sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4518 | @manish-giri |http://www.freecodecamp.com/manish-giri
Robert Richey
@0x0936
Mar 01 2017 03:31
@DracIdea really close. shift is a method and needs to be called with parens ()
Missposhtee
@Missposhtee
Mar 01 2017 03:31
@0x0936 myVariable++
Robert Richey
@0x0936
Mar 01 2017 03:31
@Missposhtee that's right, and that's the right answer.
John Alcher
@alchermd
Mar 01 2017 03:32
Hello, I'm following the official React Documentation and noticed JSX prevents injection attacks. Can someone explain what it means? :smile_cat:
Missposhtee
@Missposhtee
Mar 01 2017 03:32
its says worng
Robert Richey
@0x0936
Mar 01 2017 03:32
@Missposhtee the editor will complain if you don't add a semi-colon at the end ; but you can still pass the challenge without it
AJ
@DracIdea
Mar 01 2017 03:32
@0x0936 You sir, are a gentleman and a scholar Thanks!!!
CamperBot
@camperbot
Mar 01 2017 03:32
dracidea sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 2666 | @0x0936 |http://www.freecodecamp.com/0x0936
Missposhtee
@Missposhtee
Mar 01 2017 03:32
that variable +87
i added the semicolon
Robert Richey
@0x0936
Mar 01 2017 03:33
@Missposhtee copy paste all your code again
@DracIdea Cheers
Missposhtee
@Missposhtee
Mar 01 2017 03:35
@0x0936 do you know how i can share my screenshot over here?
Robert Richey
@0x0936
Mar 01 2017 03:35
@Missposhtee just copy paste like you did before :point_up: February 28, 2017 8:18 PM
if you have a screenshot already, you can drag and drop it here to upload
Chris Cullen
@123xylem
Mar 01 2017 03:37

@123xylem


app.post("/addFriend", function(req,res){
    res.send("PostPage!");                                         //Post request HERE
});


app.get("/friends",function(req,res){
    var friends=["sam","bob","sue","baz"];

    res.render("friends",{friends:friends});
});

app.listen(process.env.PORT, process.env.IP,function(){
    console.log("post ON!")
})

Quick Question: When I post a POST request on cloud9 it treats it like a get request and says cant get page...
Ive tested thepost request page in postman and that works but cloud9 wont open it!
WHy!



<form action="/addFriend" mehtod="POST" >

    <input type ="text" placeholder="Friends Name">
    <button>Submit</button>
</form>

^FORM FOR post request

Robert Richey
@0x0936
Mar 01 2017 03:38
@Missposhtee if it will help, click the reset button to start over. there's only one line of code to change on this challenge
var myVar = 87;

// Only change code below this line
myVar = myVar + 1; // <--- change this line
Missposhtee
@Missposhtee
Mar 01 2017 03:40
@0x0936 whats the line of code to change?
J. Cardenas
@ewrjontan
Mar 01 2017 03:41
Anyone mind helping with the weather challenge?
Robert Richey
@0x0936
Mar 01 2017 03:41
change myVar = myVar + 1; into the answer you posted above using the increment operator ++
@ewrjontan sure
Missposhtee
@Missposhtee
Mar 01 2017 03:42
@0x0936 i did still giving error....can u teach me how to copy or screenshot so u see wat am talking about
Seth Samson
@BikeGuyBoston
Mar 01 2017 03:42
Hello, i am stuck! Using objects for lookups. i dont understand how to get the function to use the value givenvar myDog = "Hunter";
var dogs = {
Fido: "Mutt",
Hunter: "Doberman",
Snoopie: "Beagle"
}
var breed = dogs[myDog];
console.log(breed);// "Doberman"

oops wrong code Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

var lookup = {

alpha:"Adams",
bravo:"Boston",
charlie:"Chicago",
delta:"Denver",
echo:"Easy",

foxtrot:"Frank",
default:"undefined",
};
var result1 = lookup[val];
console.log(result1);

// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");

Robert Richey
@0x0936
Mar 01 2017 03:43
@Missposhtee highlight all of your code and press CTRL + C to copy it, then click here and press CTRL + V to paste it
Missposhtee
@Missposhtee
Mar 01 2017 03:45

Increment a Number with JavaScript
You can easily increment or add one to a variable with the ++ operator.

i++;

is the equivalent of

i = i + 1;

Note
The entire line becomes i++;, eliminating the need for the equal sign.

Instructions
Change the code to use the ++ operator on myVar.

Hint
Learn more about Arithmetic operators - Increment (++).

Run tests (ctrl + enter)
Reset Help Bug

myVar = 87

myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line

1

2
var myVar = 87;
3

4
// Only change code below this line
5
myVar = myVar++;
6

7

8

var myVar = 87;

// Only change code below this line
myVar = myVar+1;

Robert Richey
@0x0936
Mar 01 2017 03:48
@ewrjontan I recommend avoiding openweather and instead using an API like Dark Sky or Simple Weather. If you go with simple weather, you'll need to import the cdn from here. If you go with Dark Sky, you'll need to create an account to get an API key - there's no problem with using a client key on codepen - it will be public, but you're not paying for the key (it's easy to revoke and get a new key if that becomes important, but it won't)
Steven Failla
@Stevo99
Mar 01 2017 03:48
@Missposhtee remember the ++ operator replaces the need for the = operator
and you want to add 1 to 87 not 1 to myVar
Missposhtee
@Missposhtee
Mar 01 2017 03:49
@Stevo99 i did that too it didnt work
Robert Richey
@0x0936
Mar 01 2017 03:49
@Missposhtee just use myVar++; you don't need the myVar = part there.
Steven Failla
@Stevo99
Mar 01 2017 03:49
ur overthinking it
Seth
@sethdcd
Mar 01 2017 03:53

can someone please help me understand why this is working

  $.ajax ( {
    type: 'GET',
    url: 'https://quotesondesign.com/wp-json/posts',
    success: function ( data ) {
      var post = data.shift();

      $(".message").html(post.content);
    },
    cache: false
  } );  // end ajax

but this doesn't work?

  $.ajax ( {
    type: 'GET',
    url: 'https://quotesondesign.com/wp-json/posts',
    success: function ( data ) {            
      $(".message").html(data[0].content);
    },
    cache: false
  } );  // end ajax

i think it has to do with the data.shift but it's weird because i figured data[0] would be the same thing??

Robert Richey
@0x0936
Mar 01 2017 03:56
@sethdcd works for me. what error are you getting?
Seth
@sethdcd
Mar 01 2017 03:57

@0x0936 data doesn't show up when i run the second one in my html :/ here is the codepen..

https://codepen.io/sethdcd/pen/aJOZWW?editors=1010

sigh... now it's working, lol wth
Robert Richey
@0x0936
Mar 01 2017 03:59

@sethdcd your url is not requesting a random quote like their example shows

https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1

Seth
@rifen
Mar 01 2017 03:59
I feel so close to getting Profile Lookup done. Here is my code.
```
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      return contacts[i][firstName];
    } else {
      return "No such contact";
    } 
    if (contacts[i].firstName.hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else {
     return "No such property";
    }
  }
Robert Richey
@0x0936
Mar 01 2017 04:01
@rifen why are you returning contacts[i][firstName]?
Seth
@rifen
Mar 01 2017 04:03
@0x0936 Good Call. I am not sure.
should it be return contacts[i].firstName[firstName];
Robert Richey
@0x0936
Mar 01 2017 04:04
@rifen why would you want to return the name of the contact? the challenge is not asking for that
Seth
@rifen
Mar 01 2017 04:04
OOOOOOOOOOOh you'rs right crap
lol
Seth
@sethdcd
Mar 01 2017 04:05
@0x0936 ah thank you! that was my next question as to why it wasn't generating anything else :D
CamperBot
@camperbot
Mar 01 2017 04:05
sethdcd sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 2667 | @0x0936 |http://www.freecodecamp.com/0x0936
Robert Richey
@0x0936
Mar 01 2017 04:05
@rifen also, you can't return 'No such contact' until your loop has seen all contacts
@sethdcd Cheers
Joey
@pbandjaysandwich
Mar 01 2017 04:07
'''
CamperBot
@camperbot
Mar 01 2017 04:07
:bulb: to format code use backticks! ``` more info
Joey
@pbandjaysandwich
Mar 01 2017 04:08

'''

function factorialize(num) {
return num;
}

factorialize(5);

CamperBot
@camperbot
Mar 01 2017 04:08
:bulb: to format code use backticks! ``` more info
Joey
@pbandjaysandwich
Mar 01 2017 04:09
```

```
function factorialize(num) {
return num;
}

factorialize(5);

haha trying to figure out the mark down
Robert Richey
@0x0936
Mar 01 2017 04:10
```
// code here
```
Joey
@pbandjaysandwich
Mar 01 2017 04:12
function factorialize(num) {
  return num;
}

factorialize(5);
YUS
Robert Richey
@0x0936
Mar 01 2017 04:13
:+1:
Andrew
@AndriiKost
Mar 01 2017 04:25

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
return contacts[i][prop];
} else if (contacts[i].hasOwnProperty(prop) === false ) {
return "No such property";
} else if (contacts[i].hasOwnProperty(firstName) === false ) {
return "No such contact";
}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

should return "Vos" but returning "No such contact"
Why?

ESLMiguel
@ESLMiguel
Mar 01 2017 04:25
Do they really expect me to come up with my own code to find if a number is prime?
ive been trying for 2 days now...
Robert Richey
@0x0936
Mar 01 2017 04:26
@ESLMiguel have you tried googling for the algo on finding primes? it may not be in JS, but it should help
Robert J Barbush
@rjbarbush
Mar 01 2017 04:27
I'm working on the "Stand in Line" challenge in Basic Javascript. Where do I even begin?
ESLMiguel
@ESLMiguel
Mar 01 2017 04:27
@0x0936 but wouldnt that just be copying someone else's code?
if I have that part, the rest is super easy
Seth
@rifen
Mar 01 2017 04:27
That's part of coding @ESLMiguel
Robert Richey
@0x0936
Mar 01 2017 04:28
and if it is in JS, don't copy paste - that's plagiarism (presenting someone else's work as your own)
@ESLMiguel but the concept will be the same no matter the language. once you understand the algo, you can write the JS
Seth
@rifen
Mar 01 2017 04:30
Alright feeling closer now. @0x0936 Still feel dumb though lol
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].firstName.hasOwnProperty(prop)) {
     return contacts[i][prop];

    } else {
     return "No such property";
    }
     return "No such contact";
  }


// Only change code above this line
}
Andrew
@AndriiKost
Mar 01 2017 04:33
still return "No such property"
Robert Richey
@0x0936
Mar 01 2017 04:34
@rifen it might help if you see it in pseudo code
for (contact in contacts)
  if contact's first name is firstName and contact has property prop
    return prop's value
  else
    return no such prop

if code execution reaches here without returning anything yet, it means there's no such contact
Robert Richey
@0x0936
Mar 01 2017 04:40
@ewrjontan the app id you're using appears to be wrong. see this page
jSwtch
@jSwtch
Mar 01 2017 04:40
Hey can someone help me with a quick understanding?
Nanang Hidayat
@nanankhidayat
Mar 01 2017 04:41
hi any clue "Stand In Line" task?
Robert Richey
@0x0936
Mar 01 2017 04:43
@nanankhidayat you'll need the array methods .push() and .shift() - if you don't know what they do, Google using the term js push and js shift and click the MDN link (mozilla developer network)
jSwtch
@jSwtch
Mar 01 2017 04:44
@nanankhidayat http://devdocs.io/ for the method search
Nanang Hidayat
@nanankhidayat
Mar 01 2017 04:44
Thks
Andrew
@AndriiKost
Mar 01 2017 04:45

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
return contacts[i][prop];
} else if (contacts[i].hasOwnProperty(prop) === false ) {
return "No such property";
} else if (contacts[i].hasOwnProperty(firstName) === false ) {
return "No such contact";
}
}
// Only change code above this line
}

Can somebody tell me why this don't work ??

jSwtch
@jSwtch
Mar 01 2017 04:45
@AndriiKost you should use the
code
```
"yourcode"
```
@AndriiKost what challenge is that for - what is the name
Andrew
@AndriiKost
Mar 01 2017 04:47
Profile Lookup
Sumit Ranjan
@sumitranjan
Mar 01 2017 04:48
Any one has gone through the course JavaScript: Understanding the Weird Parts | Udemy. I am planning to buy the course. Igany one has gone through this please give review at feedback of this course.
Andrew
@AndriiKost
Mar 01 2017 04:49
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
    return contacts[i][prop];
  } else if (contacts[i].hasOwnProperty(prop) === false ) {
    return "No such property";
  } else if (contacts[i].hasOwnProperty(firstName) === false ) {
    return "No such contact";
  } 
}
// Only change code above this line
}
jSwtch
@jSwtch
Mar 01 2017 04:49
the code from all my chalenges reset anyone else have this problem?
Andrew Nichols
@frenata
Mar 01 2017 04:50
You should still be able to see submitted solutions on your profile page.
jSwtch
@jSwtch
Mar 01 2017 04:52
@frenata yeah they are there just one from the map
Andrew Nichols
@frenata
Mar 01 2017 04:52
But yeah I've had challenges reset before.
Juliza
@ARAGX
Mar 01 2017 04:53
Hey ca someone help me?
I mean can
I been stuck on the object properties private challenge can someone help me with a quick explanation if possible.
Andrew Nichols
@frenata
Mar 01 2017 04:58
What exactly is confusing you, @ARAGX ?
Billy Derringer
@billyderringer
Mar 01 2017 04:59
Hey everyone I am stuck on the Profile Lookup challenge. The only thing that is not testing correctly is to return the "value" of the property. Any thoughts? ```
` function lookUpProfile(firstName, prop){ // Only change code below this line for(var i=0;i<contacts.length;i++){ if(contacts[i].firstName != firstName){ return "No such contact"; }else if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)){ return contacts[i][prop]; }return "No such property"; } // Only change code above this line }
Sorry, I don't know how to properly paste code:(
jSwtch
@jSwtch
Mar 01 2017 05:00

@AndriiKost

if (contacts[i].hasOwnProperty(prop))

returns true if true and returns false if false - i dont think you need to set ==true/false

@billyderringer return contacts[i][prop];
Joseph
@revisualize
Mar 01 2017 05:01
Hi.
@AndriiKost HEY!
Andrew
@AndriiKost
Mar 01 2017 05:02
@revisualize Hi
Joseph
@revisualize
Mar 01 2017 05:02
@billyderringer @AndriiKost Okay.. I see BOTH of your problems.
They're the SAME!
You're just creating the same problem differently
@AndriiKost @billyderringer I'm going to simplify this...
Let's say you have an array!
var contacts = [ "A" , "H" , "S" , "K" ];
Let's say you're looking for "K" but, you check if "A" != "K"
You'll get TRUE
Therefore the IF block for TRUE will run.
AND....
The return statement ends function execution and specifies a value to be returned to the function caller.
SO!
@AndriiKost @billyderringer I pose this thought question.
Let's say you were at a big business event and you're quite popular (with all those skills you have) throughout the event you got handed 200 business cards (Which will remain unordered). Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
james clark
@james0212
Mar 01 2017 05:05
``` 

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here

checkObj.hasOwnProperty("gift");
checkObj.hasOwnProperty("pet");
checkObj.hasOwnProperty("house");
return "Not Found";
}

// Test your code by modifying these values
checkObj("pony");

Billy Derringer
@billyderringer
Mar 01 2017 05:05
@revisualize after looping completely?
Joseph
@revisualize
Mar 01 2017 05:06
@billyderringer YES!
james clark
@james0212
Mar 01 2017 05:06
Instructions
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
Joseph
@revisualize
Mar 01 2017 05:06
@james0212 You're not understanding what .hasOwnProperty() returns
@james0212 .hasOwnProperty() is a method that you use on an object. and checkObj is a function.
@james0212 The hasOwnProperty() method returns a boolean indicating whether the object has the specified property.
Billy Derringer
@billyderringer
Mar 01 2017 05:08
@revisualize I see! So I need to return contacts[i][prop]; first, and then "No such..."
Joseph
@revisualize
Mar 01 2017 05:08
@billyderringer Depends on your logic.
@billyderringer All of your code does NOT need to be in the for loop.
You're setting that constraint upon yourself. Not the lesson.
Hell .. You don't even need a for loop
Billy Derringer
@billyderringer
Mar 01 2017 05:11
@revisualize I think I see what you mean. Let me work a little more to see if I'm getting it. Thanks for your help!
CamperBot
@camperbot
Mar 01 2017 05:11
billyderringer sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3376 | @revisualize |http://www.freecodecamp.com/revisualize
Andrew Nichols
@frenata
Mar 01 2017 05:11
Gotta think outside the box for loop, heh.
Joseph
@revisualize
Mar 01 2017 05:11
Just a little.
Andrew
@AndriiKost
Mar 01 2017 05:11
for (var i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName === firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];
  }  
    else  {
    return "No such property";
  } 
  }}
    return "No such contact";
oooohooo
Joseph
@revisualize
Mar 01 2017 05:11
@AndriiKost :D
Andrew
@AndriiKost
Mar 01 2017 05:12
@revisualize thank you man :)
CamperBot
@camperbot
Mar 01 2017 05:12
andriikost sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3377 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 01 2017 05:12
@AndriiKost Now do you want 4 other ways to solve that lesson?
Andrew Nichols
@frenata
Mar 01 2017 05:12
@billyderringer Love the attitude. :)
Andrew
@AndriiKost
Mar 01 2017 05:12
yes
Billy Derringer
@billyderringer
Mar 01 2017 05:13
@frenata Thanks!
CamperBot
@camperbot
Mar 01 2017 05:13
billyderringer sends brownie points to @frenata :sparkles: :thumbsup: :sparkles:
:cookie: 443 | @frenata |http://www.freecodecamp.com/frenata
Bigyan Karki
@bigyankarki
Mar 01 2017 05:13

function sumFibs(num) {
  var x = [];

  x[0] = 0;
  x[1] = 1;

  for (var i = 2; i < num; i++) {
    x[i] = x[i-2] + x[i-1];
    return x;
  }

}


sumFibs(1000);
I am trying to print the fibonacci sequence, whats wrong with this code?
Joseph
@revisualize
Mar 01 2017 05:14
@frenata HTTPS?
443
LOL!
Andrew Nichols
@frenata
Mar 01 2017 05:14
Hmm? What about HTTPS?
Joseph
@revisualize
Mar 01 2017 05:14
http protocol over TLS/SSL
Port 443
@frenata You know.. The protocol you use when you want to do any online shopping or banking.
Andrew Nichols
@frenata
Mar 01 2017 05:15
Yeah just seemed like a non-sequitur.
Joseph
@revisualize
Mar 01 2017 05:15
It's kind of important.
Jeff
@JSchock16
Mar 01 2017 05:16
how do I share code? I really need to get through stand in line.
Andrew Nichols
@frenata
Mar 01 2017 05:16
I know what it is, I don't know why you were mentioning it to me.
Joseph
@revisualize
Mar 01 2017 05:16
about @frenata
CamperBot
@camperbot
Mar 01 2017 05:16
:cookie: 443 | @frenata |http://www.freecodecamp.com/frenata
Joseph
@revisualize
Mar 01 2017 05:16
443
?
I r funneh?
Andrew Nichols
@frenata
Mar 01 2017 05:16
Oh lol
Andrew
@AndriiKost
Mar 01 2017 05:16
@JSchock16
```
"yourcode"
```
Andrew Nichols
@frenata
Mar 01 2017 05:16
Yes, I am finally secure, please no one thank me anymore.
Joseph
@revisualize
Mar 01 2017 05:17

@JSchock16
If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

Andrew Nichols
@frenata
Mar 01 2017 05:18
Sorry for missing the joke @revisualize I tune out the brownie point messages. :laughing:
Bigyan Karki
@bigyankarki
Mar 01 2017 05:20
@frenata

function sumFibs(num) {

  var a = 0;
  var b= 1;
  var c= 1;

  for (var i = 2; i < num; i++) {
    c = a+b;
    a=b;
    b=c;
  }

  return c;
}


sumFibs(14);
whats wrong with this code?
it should be printing the sequence isnt it?
Andrew Nichols
@frenata
Mar 01 2017 05:21
"What's wrong with this code?" Making me feel like I'm back in school, heh.
You're not printing anything at all.
Nitin
@thenm
Mar 01 2017 05:22
how can I get the user's input from the text-box and append it to the api call?
api.openweathermap.org/data/2.5/weather?q=London
London is supposed to be added after the user has entered the city name and pressed the button
Andrew Nichols
@frenata
Mar 01 2017 05:26
@thenm You might want to check out the onSubmit or onClick event handlers. Might also get better help in #HelpFrontEnd too.
Nitin
@thenm
Mar 01 2017 05:28
@frenata #HelpFrontEnd is it another chat room?
Andrew Nichols
@frenata
Mar 01 2017 05:28
Yes, more focused on the projects.
Ty N.
@mynameislink
Mar 01 2017 05:29
So very stuck on the 'Word Blanks' test. I get it, but....for some reason I'm wrong. lol
Bigyan Karki
@bigyankarki
Mar 01 2017 05:29
haha

function sumFibs(num) {

  var a = 0;
  var b= 1;
  var c= 1;
  var arr= [];

  for (var i = 2; i < num; i++) {
    c = a+b;
    a=b;
    b=c;
    arr.push(c);
  }
  return arr;
}


sumFibs(14);
well this should work now
but its not loading
Andrew Nichols
@frenata
Mar 01 2017 05:30
I mean, you're still not printing anything.
Bigyan Karki
@bigyankarki
Mar 01 2017 05:30
return arr should return the values, isnt it andrew?
Andrew Nichols
@frenata
Mar 01 2017 05:31
@mynameislink Could easily be a small error preventing it from working... or of course it's always possible that even though you think you understand it that you don't! :laughing:
Erik
@Luna-Coder
Mar 01 2017 05:32
Hello campers! Would someone help me find a bug with my WeatherApp?
Andrew Nichols
@frenata
Mar 01 2017 05:33
@bigyankarki It appears to be generating the sequence almost correctly, but that isn't the assignment.
Billy Derringer
@billyderringer
Mar 01 2017 05:33
@revisualize I finally got it! You rock!
Bigyan Karki
@bigyankarki
Mar 01 2017 05:35
@frenata yes i know but i was just checking... :)
Ty N.
@mynameislink
Mar 01 2017 05:35
Lol anyone know how to do this one? The word blanks program in JS?
Andrew Nichols
@frenata
Mar 01 2017 05:35
You aren't quite generating the sequence correctly.
@mynameislink Try explaining your approach.
Ty N.
@mynameislink
Mar 01 2017 05:39
@frenata I need to have a variable (that acts like an array), be attached by....
@frenata I just realized I don't even know how to explain this lol
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:40
guys how do i fix this?

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.

var gear = 20;

this.getGear = function(gear) {

return gear;
};

this.setGear = function(gear) {

return gear;
};
};

var myCar = new Car();

var myBike = new Bike();

private gear; getGear and setGear public
whats wrong
Ty N.
@mynameislink
Mar 01 2017 05:41
@anandpotukchi you need to set the arguments for the variables 'myCar' and 'myBike' at the end from what I can tell
Andrew Nichols
@frenata
Mar 01 2017 05:42
@mynameislink Rubber Ducking, it works!
Ty N.
@mynameislink
Mar 01 2017 05:43
Say what @frenata ??
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:43
@mynameislink not working
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:43
hi, Quick one. How do you view and utilize the result of the hasOwnProperty(); command?
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:44
@BikeGuyBoston hasOwnProperty(property_ name)
Ty N.
@mynameislink
Mar 01 2017 05:44
@frenata hahah thanks man
CamperBot
@camperbot
Mar 01 2017 05:44
mynameislink sends brownie points to @frenata :sparkles: :thumbsup: :sparkles:
:cookie: 444 | @frenata |http://www.freecodecamp.com/frenata
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:45
@BikeGuyBoston this checks whether that property exists
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:46
yes. I want to utilize the resulting true or false to trigger an if then statement
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:46
@BikeGuyBoston what's the challenge. read oyut the instructions\
  • paste ins here
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:47

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
var result ="";
myObj.default="Not Found";

myObj.hasOwnProperty(checkProp);

}

// Test your code by modifying these values
checkObj("gift");

testing objects for properties.
Andrew Nichols
@frenata
Mar 01 2017 05:48
@BikeGuyBoston Read The Docs!
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:49
if(myObj.hasOwnProperty(checkProp)) {
//code } else { }
@BikeGuyBoston
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:50
@ frenata... never knew about that....
Andrew Nichols
@frenata
Mar 01 2017 05:50
It's linked on the challenge page. Start reading those links. :)
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:51
@anandpotukchi thanks! im learning!
CamperBot
@camperbot
Mar 01 2017 05:51
bikeguyboston sends brownie points to @anandpotukchi :sparkles: :thumbsup: :sparkles:
:cookie: 230 | @anandpotukchi |http://www.freecodecamp.com/anandpotukchi
Andrew Nichols
@frenata
Mar 01 2017 05:51
Or googling "js functionIWantToKnowAbout" and clicking on the MDN link (probably top result)
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:51
@frenata
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:51
@BikeGuyBoston what he means is read the goddamn entire thing. all the instructions
god
anyoine found the answer to my problem?
  • anyone
Andrew Nichols
@frenata
Mar 01 2017 05:54
Your question was about private properties?
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:54
yeah
Andrew Nichols
@frenata
Mar 01 2017 05:54
AFAIK, the main difference is whether you declare with var foo or this.foo
Anand Potukuchi
@anandpotukchi
Mar 01 2017 05:55
yeah declared var as private and functions as public
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:57
@frenata "links in the challenge page" ? Are you referring to the description of the challenge? The keywords are red and dont link anywhere? Am i in the wrong place?
Andrew Nichols
@frenata
Mar 01 2017 05:58
Which challenge are you on?
Seth Samson
@BikeGuyBoston
Mar 01 2017 05:59
testing objects for properties
Andrew Nichols
@frenata
Mar 01 2017 05:59
Ah, yeah. So unfortunately they don't have links on that page. :(
Sorry about that, it's common for the challenges to link directly to the docs.
Seth Samson
@BikeGuyBoston
Mar 01 2017 06:00
gotcha... thanks. Late night tonight. Ive been working hard.
i appreciate the help'
Andrew Nichols
@frenata
Mar 01 2017 06:01
Googling "js hasOwnProperty" is still a good general strategy. Reading docs can be hard, but it's a skill you'll want to cultivate.
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 06:02
Hi, Which method I have to use in Counting Cards challenge? Loops?
Andrew Nichols
@frenata
Mar 01 2017 06:03
@anandpotukchi Just looked at this. Take another look at your implementation of "setGear"
Manish Giri
@Manish-Giri
Mar 01 2017 06:03
@SewwandiD don't really need loops
you can get by with switch/if
Chris Jantzen
@XXiphias
Mar 01 2017 06:03
@SewwandiD really just if statements... oh and I guess typeof
typeof for if it's a letter or number. though you could probably do something else without it too
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 06:05
@Manish-Giri @XXiphias Okay.. I'll try more..
Markus Kiili
@Masd925
Mar 01 2017 06:11
@SewwandiD You can use switch, if-else, or a lookup object for the evaluate card -> change count part.
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 06:14
@Masd925 Okay.. I will let you know my final output.. (Y)
Nitin
@thenm
Mar 01 2017 06:21
@frenata Thanks was having a meeting
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 06:33
Opps.. it's whole lot of errors..
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case 01:
      (card=2,3,4,5,6);
      return "5 Bet";

     case 02:
      (card=7,8,9);
      return "0 Hold";

      case 03:
      (card=10,J,Q,K,A);
      return "-5 Hold";

      case 04:
      (card=3,7,Q,8,A)||(3,2,A,10,K);
      return "-1 Hold";

      case 05:
      (card=2,J,9,2,7)||(card=2,J,9,2,7);
      return "1 Bet
Chris Jantzen
@XXiphias
Mar 01 2017 06:34
that is not how you do a switch statement
this (card=2,3,4,5,6); does not do anything
i would take another look at how switch statements working, specifically looking how to do multiple cases and noting the need of break; statements
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 06:36
@XXiphias Hell yeah!! I totally forgot that.. Btw thanks..I'll have a try & come back..
CamperBot
@camperbot
Mar 01 2017 06:36
sewwandid sends brownie points to @xxiphias :sparkles: :thumbsup: :sparkles:
:cookie: 364 | @xxiphias |http://www.freecodecamp.com/xxiphias
Chris Jantzen
@XXiphias
Mar 01 2017 06:36
no worries. hopefully you can figure it out :)
Joseph
@revisualize
Mar 01 2017 06:44
@SewwandiD You're not reading the instructions.
Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
ESLMiguel
@ESLMiguel
Mar 01 2017 06:53
Ok these intermediate algorithms are getting crazy... I can't imagine how hard the advanced ones are
Andrew Nichols
@frenata
Mar 01 2017 06:53
They make you think.
Mac
@itchick85
Mar 01 2017 06:56
Is anyone eles having trouble typing anything in the challenge finding the remainder in Java Script ?
Markus Kiili
@Masd925
Mar 01 2017 06:56
@itchick85 Try resetting the challenge.
Mac
@itchick85
Mar 01 2017 06:57
I did same thing
Joseph
@revisualize
Mar 01 2017 06:57

@itchick85
What is the returned value of num ... var num = 4 + 3;
What is the returned value of num ... var num = 10 / 5;
What is the returned value of num ... var num = 5 * 3;

Remainder:
http://images.tutorvista.com/cms/images/38/remainder1.PNG
13 % 2 is 1 ... 26 % 5 is 1 ... 24 % 6 is 0
24 % 5 is 4 ... 219 % 20 is 19
Just like in my examples above you use the % operator just like any other math operator (+, -, *, /)

@itchick85 Show me what you're doing.
@Masd925 :wave:
Markus Kiili
@Masd925
Mar 01 2017 06:59
@revisualize Good morning.
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 06:59
@revisualize noted..thanks!! But it's hard still..
CamperBot
@camperbot
Mar 01 2017 06:59
sewwandid sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3380 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 01 2017 06:59
@Masd925 Good Night. :P
@SewwandiD There are two different blocks of code. One for modifying count based upon the card value. ... One for returning the count based upon counts value.
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 07:01
hmm..
Austin Tice
@AustinTice
Mar 01 2017 07:02
@SewwandiD are you still needing help with the blackjack solution?
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 07:04
@AustinTice yes..
still doing
Austin Tice
@AustinTice
Mar 01 2017 07:05
let me see what code you have currently, and I will try and help out to the best of my ability.
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 07:09
: @AustinTice
```
break;
```

var count = 0;

function cc(card) {


  // Only change code below this line
  switch(card){
    case 01:
      (card=2,3,4,5,6);
      return "5 Bet";
      break;

     case 02:
      (card=7,8,9);
      return "0 Hold";
      break;

      case 03:
      (card=10,J,Q,K,A);
      return "-5 Hold";
      break;

      case 04:
      (card=3,7,Q,8,A);
      case 05:
      (3,2,A,10,K);
      return "-1 Hold";
      break;

      case 06:
      (card=2,J,9,2,7);
      case 07:
      (card=2,J,9,2,7);
      return "1 Bet";
      break;


  // 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');
Chris Jantzen
@XXiphias
Mar 01 2017 07:12
have you changed anything? The switch statement still needs fixing
oh wait, you added the breaks
you still need to fix your cases
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 07:12
@XXiphias INSERT BREAKS
YEAH
Chris Jantzen
@XXiphias
Mar 01 2017 07:13
case 06:
      (card=2,J,9,2,7);
This is not the proper way to do a case
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 07:13
"J" should be like that nah??
Andrew Nichols
@frenata
Mar 01 2017 07:13
break and return are duplicative anyway, you don't need both in an switch.
Chris Jantzen
@XXiphias
Mar 01 2017 07:13
all that will do is if the card is a 06, it will enter that and exit the function returning "1 Bet" (which is further down in the code after the case 07
Austin Tice
@AustinTice
Mar 01 2017 07:14
try this,
Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 07:16
@frenata okay.. got your point..Thanks!
CamperBot
@camperbot
Mar 01 2017 07:16
sewwandid sends brownie points to @frenata :sparkles: :thumbsup: :sparkles:
:cookie: 448 | @frenata |http://www.freecodecamp.com/frenata
Austin Tice
@AustinTice
Mar 01 2017 07:16

switch(card) { case 2: case 3: case 4: case 5: case 6:

this general syntax should help you, and also be sure to make your J,Q, and K strings like "J" "Q" "K"

David Castillo
@djames1109
Mar 01 2017 07:16

Hi There! I need help.
How come I'm receiving an error: x is undefined?
Here's my code:

function titleCase(str) {
var str_array=str.split(' ');

for(var x=0; x<=(str_array.length); x++){
var temp=str_array[x][0].toUpperCase();
var temp2=str_array[x].replace(/./,temp);
str_array[x]=temp2;
}
var result=str_array.join(' ');

return result;
}

titleCase("I'm a little tea pot");

Sewwandi Dharmapriya
@SewwandiD
Mar 01 2017 07:17
@XXiphias if the card is 6 , then it is 5 bet..isn't it?
Chris Jantzen
@XXiphias
Mar 01 2017 07:18
@SewwandiD i dont think you want to do it like that. I dont remember off the top of my head but dont you want to increment or decrement a count? And then if that count is positive or negative, Bet or Stay?
Manish Giri
@Manish-Giri
Mar 01 2017 07:18
Hold
Chris Jantzen
@XXiphias