These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Jan 2017
andercodder
@andercodder
Jan 17 2017 00:00 UTC
@Dueldrawer8 yes...but it is not returnin the first name it jumps to else statement and return the code inside else statement
@Dueldrawer8 but my if stament is al right i think cos if return the firstName inside else statement it returns what it should be
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 00:02 UTC
if (contacts[0].firstName === firstName) {
 if (contacts[0].hasOwnProperty(prop)) {
            return contacts[0][prop];
Naeri Adam Fernandez
@naeri-kailash
Jan 17 2017 00:03 UTC
@JLuboff i have tried all sorts of weird combinations haha, so should i call arr[i][j]? something like
product = product * (arr[i][j]);
holy shit it worked yay!!!! thaaaaaanks :D :D
Jason Luboff
@JLuboff
Jan 17 2017 00:03 UTC
Yup, there you go
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 00:03 UTC
the arrays variable name is contacts..to access the first object within the array.. use contacts[0]
Jason Luboff
@JLuboff
Jan 17 2017 00:04 UTC
@naeri-kailash It could also be simplified to product *= arr[i][j] but works perfectly fine the way you have it
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 00:04 UTC
then to access the firstName you just do contacts[0].firstName
Naeri Adam Fernandez
@naeri-kailash
Jan 17 2017 00:04 UTC
yeah :) true true
andercodder
@andercodder
Jan 17 2017 00:04 UTC
@Dueldrawer8 ok... i tried something it seems returning undefined with your code it will help me alot now i know my error
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 00:05 UTC
@andercodder with a for loop..obvousily you would replace i inside the brackets
andercodder
@andercodder
Jan 17 2017 00:05 UTC
@Dueldrawer8 thank you man very thank you
CamperBot
@camperbot
Jan 17 2017 00:05 UTC
andercodder sends brownie points to @dueldrawer8 :sparkles: :thumbsup: :sparkles:
:cookie: 423 | @dueldrawer8 |http://www.freecodecamp.com/dueldrawer8
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 00:06 UTC
@andercodder welcome, if you need anymore help let me know.. and you can also checkout the wiki and it will give an explanation as well as hints
andercodder
@andercodder
Jan 17 2017 00:07 UTC
@Dueldrawer8 :+1: :smile: :sparkles:
Adam
@adamakers
Jan 17 2017 00:07 UTC
Can anyone tell me why my code is pushing every item from the array into the prototype?
https://codepen.io/MrAdam/pen/vgGoGN?editors=0012
for example, the first object should have a property of oMove: ['1'], and the next object should have oMove: ['2'], instead they all have oMove: [1,2,3,4,5,6,7,8]
Albert L. C.
@sirus3020
Jan 17 2017 00:09 UTC
I have a question. Why can't I split the array with the error: TypeError: arr.split is not a function.
Jason Luboff
@JLuboff
Jan 17 2017 00:10 UTC
@sirus3020 Did you give split an argument by which to split?
Albert L. C.
@sirus3020
Jan 17 2017 00:10 UTC
arr = arr.split(' ');
Adam
@adamakers
Jan 17 2017 00:10 UTC
cant split with arrays
its not a method
for arrays
Jason Luboff
@JLuboff
Jan 17 2017 00:10 UTC
Yup...split is used on a string, not an array
Albert L. C.
@sirus3020
Jan 17 2017 00:11 UTC
alright. thanks
so how would I split the string in the arrays?
Jason Luboff
@JLuboff
Jan 17 2017 00:13 UTC
@sirus3020 You would need to access them via their index then run split
Adam
@adamakers
Jan 17 2017 00:13 UTC
you mean like [''hello world'', "my name is"] to [['hello', 'world'], ['my', 'name', 'is']]?
Albert L. C.
@sirus3020
Jan 17 2017 00:13 UTC
yes
Adam
@adamakers
Jan 17 2017 00:13 UTC
you would need to iterate over the list
Albert L. C.
@sirus3020
Jan 17 2017 00:14 UTC
ok. thanks. @JLuboff @adamakers
CamperBot
@camperbot
Jan 17 2017 00:14 UTC
sirus3020 sends brownie points to @jluboff and @adamakers :sparkles: :thumbsup: :sparkles:
:cookie: 647 | @jluboff |http://www.freecodecamp.com/jluboff
:cookie: 317 | @adamakers |http://www.freecodecamp.com/adamakers
Adam
@adamakers
Jan 17 2017 00:14 UTC
so say
```
var arr = [''hello world'', "my name is"];
for (var i = 0; i < arr.length: i++) {}
damn
var arr = [''hello world'', "my name is"];
for (var i = 0; i < arr.length: i++) {
    arr[i].split(' ');
}
try that
Adam
@adamakers
Jan 17 2017 00:23 UTC
I'm trying to create a function that will reference a list and for each item of that list it will make a copy of an existing object and push the array item to another list inside of the object. instead what my code is doing is pushing all of the items to the array in the object. Anyone able to see what is going on?
https://codepen.io/MrAdam/pen/vgGoGN?editors=0012
objects should look something like, obj1 = {xMove: ['1']}, obj2 = {xMove: ['2']}, obj3 = {xMove: ['3']}..etc... instead I'm getting obj1 = {xMove: [1,2,3,4,5,6...]}, obj2 = {xMove: [1,2,3,4,5,6...]}, obj3 = {xMove: [1,2,3,4,5,6...]}....
mzedlach
@mzedlach
Jan 17 2017 00:27 UTC
Hello everyone :)
kevinliu6102
@kevinliu6102
Jan 17 2017 00:29 UTC

i'm having trouble understanding this function:

function permute(string) {
    function recur(string, prefix) {
        if (string.length === 0) {
            return [prefix];
        } else {
            var out = [];
            for (var i = 0; i < string.length; i++) {
                var pre = string.substring(0, i);
                var post = string.substring(i + 1);
                out = out.concat(recur(pre + post, string[i] + prefix));
            }
            return out;
        }
    }
    var distinct = {};
    recur(string, "").forEach(function(result) {
        distinct[result] = true;
    });
    return Object.keys(distinct);
}

in the recursive function, when is string.length ever === 0?

mzedlach
@mzedlach
Jan 17 2017 00:29 UTC
I'm working on "Sum All Primes" The explanation says to sum all the primes all the way up to the input value. And then also add the input value. But, they say that sumPrimes(10) should return 17.... I don't follow.... All the prime numbers up until 10 and including 10 would be..... 2, 3, 5, 7, 10
Oh, wait... something just clicked... input should only be added if it is also a prime.
NEVERMIND! :)
Bozhidar Dimitrov
@phiratio
Jan 17 2017 00:35 UTC
@kevinliu6102 "".length() returns 0
mzedlach
@mzedlach
Jan 17 2017 00:35 UTC
Can anyone explain what this means? "if (!sieve[i]) " sieve is an empty array. What does the exclamation at hte start mean?
Coy Sanders
@coymeetsworld
Jan 17 2017 00:35 UTC
@joehesse you want to set the answer variable
not create new variables like a b c defaultStatement
@mzedlach means not
basically returns the opposite true/false value of the statement.
Stephen James
@sjames1958gm
Jan 17 2017 00:37 UTC
@mzedlach logical not
mzedlach
@mzedlach
Jan 17 2017 00:37 UTC
mmmm.... I'm following the guide on this challenge and it does !make sense.
Stephen James
@sjames1958gm
Jan 17 2017 00:37 UTC
@joehesse YOu need to set the return variable - see the return statement
Adam
@adamakers
Jan 17 2017 00:37 UTC
thumbs up for the pun
mzedlach
@mzedlach
Jan 17 2017 00:37 UTC
:)
Stephen James
@sjames1958gm
Jan 17 2017 00:37 UTC
@mzedlach NICE
mzedlach
@mzedlach
Jan 17 2017 00:38 UTC
ach. I don't understand how to even come up with what htey came up with.
Stephen James
@sjames1958gm
Jan 17 2017 00:38 UTC
@mzedlach !sieve[i] would seem to me to test if sieve[i] is zero or not
kevinliu6102
@kevinliu6102
Jan 17 2017 00:39 UTC
@phiratio right but for each recursion, i'm reading that string is always pre + post of the previous recursion, and i'm having trouble picturing how pre + post is ever an empty string
mzedlach
@mzedlach
Jan 17 2017 00:39 UTC
It's the "Sum All Primes" challenge
@sjames1958gm
Stephen James
@sjames1958gm
Jan 17 2017 00:39 UTC
@mzedlach you are trying to implement the sieve method?
mzedlach
@mzedlach
Jan 17 2017 00:40 UTC
@sjames1958gm It looks like they just made an empty array called sieve. Let me post their code.
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 00:40 UTC
function getProductOfAllElementsAtProperty(obj, key) {
  // your code here
  for(var strange in obj){
    if(Array.isArray(obj[strange])){
         var total = 1;
        for(var i = 0; i < obj[strange].length; i++){
            total*= obj[key][i];
      }

  }
      else if(obj[strange].length < 0){
          return 0;
      }
      else{
          return 0;
      }
     }
     return total;
}




var obj = {
  key: []
};
var output = getProductOfAllElementsAtProperty(obj, 'key');
console.log(output);
wondering why if i have an empty array it isnt returning 0 rather than 1?
mzedlach
@mzedlach
Jan 17 2017 00:40 UTC
function sumPrimes(num) {
  var res = 0;

  // Function to get the primes up to max in an array
  function getPrimes(max) {
    var sieve = [];
    var i;
    var j;
    var primes = [];
    for (i = 2; i <= max; ++i) {
      if (!sieve[i]) {
        // i has not been marked -- it is prime
        primes.push(i);
        for (j = i << 1; j <= max; j += i) {
          sieve[j] = true;
        }
      }
    }

    return primes;
  }

  // Add the primes
  var primes = getPrimes(num);
  for (var p = 0; p < primes.length; p++) {
    res += primes[p];
  }

  return res;
}

// test here
sumPrimes(10);
This just feels like a huge conceptual jump.
Stephen James
@sjames1958gm
Jan 17 2017 00:42 UTC
@mzedlach I guess it depends on the fact that sieve[i] that is not set is the same false.
Bozhidar Dimitrov
@phiratio
Jan 17 2017 00:43 UTC
@kevinliu6102 lets try to figure it out together can you give the code/sourse page of it?
mzedlach
@mzedlach
Jan 17 2017 00:43 UTC
@sjames1958gm Can you rephrase that? I don't understand your sentence ^^
kevinliu6102
@kevinliu6102
Jan 17 2017 00:44 UTC
@phiratio it's just an independent exercise, i came across out trying to figure out how to approach "no repeats please" algorithm problem. here is the source: https://www.reddit.com/r/dailyprogrammer/comments/164zvs/010713_challenge_116_easy_permutation_of_a_string/c7stc9m/
Stephen James
@sjames1958gm
Jan 17 2017 00:44 UTC
@mzedlach if sieve[i] is not true then i is a prime. The algorithm is to first set all the values to false, but for js sieve[i] that is not set is undefined which is also 'false'
Adam
@adamakers
Jan 17 2017 00:44 UTC

if I do

var testArr = ['1', '2', '3', '4', '5'];
var obj = {
   things: []
}

testArr.forEach(function(item){
    var newObj = Object.create(obj);
    newObj.things.push(item);
    console.log(newObj)    
});

then why does each obj have a prop of things: ['1', '2', '3', '4', '5'] instead of one object havingthings:['1']and the next object havingthings: ['2']```?

Stephen James
@sjames1958gm
Jan 17 2017 00:46 UTC
@adamakers all the things refer to the same array that you created at the top. Object.create does only a shallow copy
mzedlach
@mzedlach
Jan 17 2017 00:47 UTC
@sjames1958gm But sieve[i] is going to give you a number. How can that be a true or false statement?
Stephen James
@sjames1958gm
Jan 17 2017 00:47 UTC
@Dueldrawer8 Because you do total = 1 if isArray is true.
Bozhidar Dimitrov
@phiratio
Jan 17 2017 00:48 UTC
@kevinliu6102 that's too advanced for my humble skills :D
Stephen James
@sjames1958gm
Jan 17 2017 00:48 UTC
@mzedlach No, sieve[i] is either true or undefined. See where it is set to true below. The idea is that when you find sieve[i] = undefined (!sieve[i])
You mark all the multiples of i with true to indicated they are not prime
Adam
@adamakers
Jan 17 2017 00:48 UTC
@sjames1958gm so instead its just adding it to the prototype (which would be obj correct?) instead of the newObj?
Stephen James
@sjames1958gm
Jan 17 2017 00:49 UTC
@adamakers No I don't think so - each instance has a things property they just happen to all reference the same array
mzedlach
@mzedlach
Jan 17 2017 00:49 UTC
@sjames1958gm is sieve a random array name? They could have just as well named it "apples"?
Stephen James
@sjames1958gm
Jan 17 2017 00:50 UTC
@mzedlach Yes, it is only sieve because that is the algorithm being implemented.
Adam
@adamakers
Jan 17 2017 00:51 UTC
@sjames1958gm hmm... is there a way to implement what I am trying to do? Get it so that each object has just the one array item in it?
halloween
@shawnchenxmu
Jan 17 2017 00:51 UTC
、、、

// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = ""; // Change this line
、、、

mzedlach
@mzedlach
Jan 17 2017 00:51 UTC
@sjames1958gm Things are just flying over my head
Stephen James
@sjames1958gm
Jan 17 2017 00:52 UTC
@adamakers if you did newObj.things = [item];that would create a new array each time.
halloween
@shawnchenxmu
Jan 17 2017 00:53 UTC
HELP!How could I access the secondTree?
Adam
@adamakers
Jan 17 2017 00:53 UTC
@sjames1958gm with what Im doing im trying to push them to an array with already existing numbers instead of create a new array
Stephen James
@sjames1958gm
Jan 17 2017 00:54 UTC
@mzedlach So the array is empty.
the first value of i is 2
sieve[2] doesn't exist so is undefined !sieve[2] is true so the if passes the test.
2 is pushed onto the primes array - then the loop start at 4 and goes by twos (setting each value to true marking it for later as not prime)
Adam
@adamakers
Jan 17 2017 00:54 UTC
@shawnchenxmu try myPlants[1].list[1];
Coy Sanders
@coymeetsworld
Jan 17 2017 00:55 UTC
@adamakers please don't try to give out the answers when people are asking for help in the future
Stephen James
@sjames1958gm
Jan 17 2017 00:55 UTC
@adamakers With push you are adding to the existing array
halloween
@shawnchenxmu
Jan 17 2017 00:56 UTC
@adamakers It works! Thank you! But why doing this?
CamperBot
@camperbot
Jan 17 2017 00:56 UTC
shawnchenxmu sends brownie points to @adamakers :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @adamakers |http://www.freecodecamp.com/adamakers
Adam
@adamakers
Jan 17 2017 00:57 UTC
@coymeetsworld got it
because you have a couple things going on here
Coy Sanders
@coymeetsworld
Jan 17 2017 00:57 UTC
couldn't read it correctly as it wasn't formatted but yeah that was right
sanjay-sopho
@sanjay-sopho
Jan 17 2017 00:57 UTC
some one help me with this. I can't figure out what's wrong with this code
function rot13(str) { // LBH QVQ VG!
  var dec="";
  function name(str){ 
    var s=[]; 
    for(var i=0; i<str.length; i++)
    { 
      s[i] = (str.charCodeAt(i)-65+13)%26+65;
    }
    return s;
  }
  dec.fromCharCode(name(str));
  dec.join("");
  return dec;
}
Chika Chikwendu
@CheeZeee
Jan 17 2017 00:58 UTC
Guys, please I'm missing something but I really don't know what it is...help out!

//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) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      return "No such property";
    }
    return "No such contact";
  }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Coy Sanders
@coymeetsworld
Jan 17 2017 00:58 UTC
@sanjay-sopho that's not how you add to an array
there are array functions you can use to add items to an array
Victoria Zambrano
@vzambrano98
Jan 17 2017 00:58 UTC
I don't understand what I'm doing wrong here. The test runs (showing me what answers I should be getting) aren't making sense in and of themselves, and I"m struggling with this concept as a whole.....if anyone has a moment to maybe explain why I'm on the struggle bus I'd really appreciate it.
var Bike = function() {

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



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

this.getGear = function(){
    return gear;
  };
};
var myCar = new Car();

var myBike = new Bike();
Make Object Properties Private
Coy Sanders
@coymeetsworld
Jan 17 2017 00:58 UTC
also fromCharCode takes a character in, not a String I believe
sanjay-sopho
@sanjay-sopho
Jan 17 2017 00:58 UTC
@coymeetsworld like push ?
thanks
Coy Sanders
@coymeetsworld
Jan 17 2017 00:58 UTC
yes
sanjay-sopho
@sanjay-sopho
Jan 17 2017 00:59 UTC
I am from c background. I keep making such mistakes
thanks anyway
Coy Sanders
@coymeetsworld
Jan 17 2017 00:59 UTC
@vzambrano98 did you do the same for Car?
no problem
also @vzambrano98 that's not how you set the gear for a Bike
its not the same as accelerating for a car
Adam
@adamakers
Jan 17 2017 01:00 UTC
@shawnchenxmu your inital structure is an array, inside that array you have an object, thats the first item in the array. the second item in the array, the one we are interested in has an index of 1. we access that item by going myPlants1. Then we need to access the second item just in that obj. doing that we can go myPlants1.list. we wont do myPlants1 because that would look for the property of 1 so instead we go myPlants1.list. Then to access the second item in the list we just add a 1 to the end of that, getting myPlants1.list1
Victoria Zambrano
@vzambrano98
Jan 17 2017 01:01 UTC
@coymeetsworld The car part is from their section, before mine.
also I don't understand why it's not the same....
Islam Ibakaev
@dagman
Jan 17 2017 01:01 UTC
you guys how do you handle this issue?
Handling of 'touchstart' input event was delayed for 164 ms due to main thread being busy. Consider marking event handler as 'passive' to make the page more responsive.
Coy Sanders
@coymeetsworld
Jan 17 2017 01:01 UTC
@vzambrano98 hmmm i feel like that should've been covered and tested in a previous challenge
but for car you increment the speed, but bike you just change it
Adam
@adamakers
Jan 17 2017 01:02 UTC
@sjames1958gm so im just SOL then? Cant push the item to the existing array?
Victoria Zambrano
@vzambrano98
Jan 17 2017 01:02 UTC
@coymeetsworld explain this as if I were five, because what you're saying isn't clickin
Coy Sanders
@coymeetsworld
Jan 17 2017 01:03 UTC
oh wait that is in the same challenge
John Nunns
@johnnunns
Jan 17 2017 01:03 UTC
hey guys do we have any good example problems that would explain how to transform an array of data into an object format??
Coy Sanders
@coymeetsworld
Jan 17 2017 01:03 UTC
did you ever own a variable speed bike @vzambrano98 ?
Adam
@adamakers
Jan 17 2017 01:03 UTC
@sjames1958gm trying to use it for the minimax algorithm to determine the next possible gamestates
halloween
@shawnchenxmu
Jan 17 2017 01:03 UTC
@adamakers Thank you very much! You are so nice!
CamperBot
@camperbot
Jan 17 2017 01:03 UTC
shawnchenxmu sends brownie points to @adamakers :sparkles: :thumbsup: :sparkles:
:warning: shawnchenxmu already gave adamakers points
Coy Sanders
@coymeetsworld
Jan 17 2017 01:03 UTC
theres just a dial on the handle and you change it and then its set. So if you're on speed 1 and want to go to speed 4, you don't go to 2 then 3, its just 4
so whatever value you get to setGear, thats what you make gear, you don't increment it to what it has. If you did that, then the example above if you set the speed to 4 it would be 5
mzedlach
@mzedlach
Jan 17 2017 01:05 UTC

@sjames1958gm Okay, thank you so much for "Explaining it like I'm 5" That seriously helped :) (I know that may sound like sarcasm. But, no sarcasm!) So it all makes sense up until this point:

for (j = i << 1; j <= max; j += i) {  
sieve[j] = true;

So, first line --> I'm reading that << has something to do with binary notation? I do understand that this section has something to do with all following multiples created from i value. So, i = 2 would propogate 4, 6, 8, 10 (If the input was 10). So I don't understand the << ..... and if sieve[j] = true (or even if it equaled false...) so what? I don't see what happens there.

CamperBot
@camperbot
Jan 17 2017 01:05 UTC
:star2: 5373 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
mzedlach sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Victoria Zambrano
@vzambrano98
Jan 17 2017 01:05 UTC
@coymeetsworld ooooooohhhhh!!!!! see that's so much better, so then I wouldn't use += I would just use... gear=change
right?
Coy Sanders
@coymeetsworld
Jan 17 2017 01:05 UTC
yep
Victoria Zambrano
@vzambrano98
Jan 17 2017 01:06 UTC
YAY! okay, I would have never gotten that lol I"ll give it a try, thanks for your help
@coymeetsworld thanks*
CamperBot
@camperbot
Jan 17 2017 01:06 UTC
vzambrano98 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1833 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jan 17 2017 01:06 UTC
no problem
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 01:08 UTC

@sjames1958gm

function getProductOfAllElementsAtProperty(obj, key) {
  // your code here
  for(var strange in obj){
        if(obj[strange].length > 0){
        var total = 1;
            for(var i = 0; i < obj[strange].length; i++){
            total*= obj[key][i];
      }
      return total;
  }
    else if(!Array.isArray(obj[strange])){
      return 0;
  }

  }


}




var obj = {
   key: []
};
var output = getProductOfAllElementsAtProperty(obj, 'key');
console.log(output);

now if the property at the key is an empty array..it needs to return 0 but it is returning undefined

AndrewScr
@AndrewScr
Jan 17 2017 01:08 UTC
i find the instructions rather vague
Stephen James
@sjames1958gm
Jan 17 2017 01:15 UTC
@AndrewScr Copy the test string and replace the keywords with the values from the table then remove all spaces
@Dueldrawer8 Init total before the if so that it is set when the if test false
Jean Baptiste Kwizera
@jbkwizera
Jan 17 2017 01:17 UTC

hello...
Is it legal to assign IIFE to a variable?
Like

var m = (foo(){
    var a = 2;
    return a;
}();

Is this legal? Does it have any bad side effects?

Randy Goldsmith
@Dueldrawer8
Jan 17 2017 01:18 UTC
@sjames1958gm these are the other 3 objctives i have to do :
Notes:
  • If the array is empty, it should return 0.
  • If the property at the given key is not an array, it should return 0.
  • If there is no property at the given key, it should return 0.
@sjames1958gm tried using Array.isArray but that doesnt work
John Nunns
@johnnunns
Jan 17 2017 01:19 UTC
If i wanted to change [['myName', 'John'],['yourName, 'Ed']] to {myName: "John", yourName: "Ed"} where would I even start?
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 01:19 UTC
@sjames1958gm keeps saying its NaN
for example if i make the key a string
also used typeOf
@sjames1958gm nvm got it although its long
Adam
@adamakers
Jan 17 2017 01:24 UTC
@sjames1958gm i think i might have a solution. I could just create a new array like you suggested, and then concat the two. just tested it and it works
Randy Goldsmith
@Dueldrawer8
Jan 17 2017 01:24 UTC
function getProductOfAllElementsAtProperty(obj, key) {

  for(var strange in obj){
      var total = 1;
        if(Array.isArray(obj[strange]) && obj[strange].length > 0){
            for(var i = 0; i < obj[strange].length; i++){
                total*= obj[key][i];
            }
            return total;
  }
    else{
      return 0;
        }
    }
}
Chris Harrison
@ceharrison
Jan 17 2017 01:28 UTC

Im having a little problem figuring out what's wrong here:
var count = 0;

function cc(card) {
// Only change code below this line
for (card) {
if (card =2,3,5,6) {
count ++;
} else (card =10, 'J', 'Q','K','A') {
count --;
}
}
}
return count;

Adam
@adamakers
Jan 17 2017 01:36 UTC
@ceharrison is card supposed to be an array?
Trying to figure out the for loop
CoryCMyers
@CoryCMyers
Jan 17 2017 01:38 UTC
Question! When would it be useful or required to delete a property from an object using delete object.property? Would it not just be better to edit the object all together?
zhekau
@zhekau
Jan 17 2017 01:43 UTC
Hi everyone! Could anyone help me with the Arguments Optional challenge? I read about closures but it does not make too much sense for me. Why when I run addTogether(2)([3]); it says addTogether(...) is not a function?
John T. Knox
@JTKnox91
Jan 17 2017 01:48 UTC

Could use some help with the Babel compilier.
http://codepen.io/JTKnox91/pen/zNxyXP?editors=0010

Look at line 1134 uncomplied and line 1443 compilied.

Usually any this is turned into _thisXX. For instance this.player in the uncompiled constructor for Map becomes _this23.player. In the I am expecting line 1134 to compile into _thisXX.player.location but instead remains as this.player.location, which is undefined when that method is called. What am I doing wrong here that's stopping the Babel from compiling that method the way it compiles the other methods?

c0mplexm0z
@c0mplexm0z
Jan 17 2017 01:51 UTC

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

New to javascript and this is doing my head in!
I need to add the number to the end of the array and remove the first?
raghu-nx
@raghu-nx
Jan 17 2017 01:52 UTC
@ jbkwizera
c0mplexm0z
@c0mplexm0z
Jan 17 2017 01:53 UTC
Anyone?
raghu-nx
@raghu-nx
Jan 17 2017 01:54 UTC
there is nothing wrong by assigning a IIFE to a variable as far as I know. IIFEs are useful in the context of closures. In the specific example you have provided, there isn’t much value
Yoel Trujillo
@y0el22
Jan 17 2017 01:54 UTC

hi guys any help here?


function titleCase(str) {
  var arrayNew = str.split(" ");

  for(var i= 0; i<arrayNew.length; i++){
     arrayNew[i].charAt(0).toUpperCase();
      equis = arrayNew.join(" ");

  }
  return equis;
}

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

do you know why the code is not working?

raghu-nx
@raghu-nx
Jan 17 2017 01:55 UTC
@c0mplexm0z try looking at MDN documentation when you have questions about methods related to certain classes
John T. Knox
@JTKnox91
Jan 17 2017 02:00 UTC

@y0el22

function titleCase(str) {
  var arrayNew = str.split(" ");

  for(var i= 0; i<arrayNew.length; i++){
     arrayNew[i].charAt(0).toUpperCase(); //this doesn't actually assign anything, try " arrayNew[i] = ..." and then what you had written before.
      equis = arrayNew.join(" "); //this only needs to be done once, so you could move it out of the for loop

  }
  return equis;
}

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

Let me know how those changes work

Greg Duncan
@GregatGit
Jan 17 2017 02:01 UTC
@y0el22 you should try using the debugger to see what you are getting
AndrewScr
@AndrewScr
Jan 17 2017 02:02 UTC
@sjames1958gm thanks Stephen
CamperBot
@camperbot
Jan 17 2017 02:02 UTC
andrewscr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5374 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Yoel Trujillo
@y0el22
Jan 17 2017 02:03 UTC
@GregatGit i'm getting the string normal
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:04 UTC
I have and still cannot get my head around it
Justin Vigil
@jvigil243
Jan 17 2017 02:04 UTC
need some help on this 1st lesson of javascript
Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
Greg Duncan
@GregatGit
Jan 17 2017 02:04 UTC
@y0el22 are you trying to uppercase the sentence one letter at a time and add it to the array?
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:04 UTC
maybe im just fucking stupid
Yoel Trujillo
@y0el22
Jan 17 2017 02:05 UTC
@JTKnox91 sorry i understand but i don't know how to do it
Joe Escobedo
@joeEscob1023
Jan 17 2017 02:06 UTC

So on one of the lessons it says that this:

var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16; // Change this Line
var player = testObj[playerNumber]; // Change this Line

prints out "Montana"

but i put it in the browser console and it says undefined ..why is that?

Yoel Trujillo
@y0el22
Jan 17 2017 02:07 UTC
@GregatGit yes i¡m doing that no?
Greg Duncan
@GregatGit
Jan 17 2017 02:08 UTC
@y0el22 toUpperCase() does change the orginal so
var a = 'a';
var capitalA = a.toUpperCase();

// a is still 'a' and capitalA is 'A'
raghu-nx
@raghu-nx
Jan 17 2017 02:09 UTC
@c0mplexm0z you basically need to remove the first element of the array: use shift method and to add the given item at the end of the array, use push method
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:10 UTC
@raghu-nx yes but I need the function to return the shift.
It's this bit I am stuck with
Yoel Trujillo
@y0el22
Jan 17 2017 02:11 UTC
@GregatGit let me see what i'm doing wrong
Jean-Philippe Sirois
@veksen
Jan 17 2017 02:11 UTC
@TacoJoe because in the console, the testObj is undefined
run testObj in the console
raghu-nx
@raghu-nx
Jan 17 2017 02:11 UTC
@c0mplexm0z oh ok, shift method removes the first element and returns that value.
var shiftedVal = arr.shift()
Michael Pimentel Jr
@mtpjr88
Jan 17 2017 02:11 UTC

help ```

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < multiplyAll.length; i++){
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

```

CamperBot
@camperbot
Jan 17 2017 02:11 UTC
no wiki entry for: function multiplyallarr var product 1 only change code below this line for var i0 i multiplyalllength i only change code above this line return product modify values below to test your codemultiplyall1234567
Michael Pimentel Jr
@mtpjr88
Jan 17 2017 02:11 UTC

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < multiplyAll.length; i++){
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Joe Escobedo
@joeEscob1023
Jan 17 2017 02:12 UTC
@veksen var player = console.log( testObj[playerNumber]); this seemed to work
Yoel Trujillo
@y0el22
Jan 17 2017 02:12 UTC
@y0el22
sorry guys i really don't get this problem
maybe later i can i don't know :(
Joe Escobedo
@joeEscob1023
Jan 17 2017 02:13 UTC
is that what you meant?
Jean-Philippe Sirois
@veksen
Jan 17 2017 02:14 UTC
yes and no, type: testObjin the console
Stephen James
@sjames1958gm
Jan 17 2017 02:14 UTC
@mtpjr88 Look at the example - it shows how to do the two loops and how to access the value
Dan
@RetartedZombie
Jan 17 2017 02:15 UTC
@CheeZeee I got stuck on this too. It seems the return "No such contact" inside the first for loop is where it's getting stuck. Because you're iterating through each member and not all of them are contacts[i].firstName === firstName.
I got around this by adding a boolean:
function lookUpProfile(firstName, prop){
// Only change code below this line
  var hasName = false;
    for(var i=0; i< contacts.length; i++){
        if(contacts[i].firstName == firstName){
            hasName = true;
            if(contacts[i].hasOwnProperty(prop)){
                return contacts[i][prop];
            }
            return "No such property";
        }
    }
    if(hasName === false){return "No such contact";}

// Only change code above this line
}
CamperBot
@camperbot
Jan 17 2017 02:15 UTC
:bulb: to format code use backticks! ``` more info
Greg Duncan
@GregatGit
Jan 17 2017 02:15 UTC
@y0el22 try writing out each of the steps you want to do - your first step would be to make the str lowercase
Joe Escobedo
@joeEscob1023
Jan 17 2017 02:15 UTC
@veksen woo! thanks!
CamperBot
@camperbot
Jan 17 2017 02:15 UTC
tacojoe sends brownie points to @veksen :sparkles: :thumbsup: :sparkles:
:cookie: 109 | @veksen |http://www.freecodecamp.com/veksen
Yoel Trujillo
@y0el22
Jan 17 2017 02:15 UTC
@GregatGit all the string lowercase first?
Greg Duncan
@GregatGit
Jan 17 2017 02:17 UTC
@y0el22 yes titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") and titleCase("sHoRt AnD sToUt") need it
Stephen James
@sjames1958gm
Jan 17 2017 02:17 UTC
@RetartedZombie just FYI the boolean is not needed because you return when the firstName is matched the only way to fall out of the loop is if there is no match on firstName
Greg Duncan
@GregatGit
Jan 17 2017 02:17 UTC
@y0el22 don't code it - just write the steps you need to take
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:17 UTC
nextInLine([5,6,7,8,9], 1) should return 5 . ??
Stephen James
@sjames1958gm
Jan 17 2017 02:18 UTC
@c0mplexm0z Yes, you add 1 to the end and remove and return 5 from the front.
raghu-nx
@raghu-nx
Jan 17 2017 02:19 UTC
Yeah it should return 5 and the array should be modified as 6,7,8,9,1
Colin McAtee
@colinmac17
Jan 17 2017 02:19 UTC
Hello FCC friends, I need some guidance with the "stand in line" challenge. I think that I will need to use the .unshift() function and .push() function but am having trouble after attempting a few times.
raghu-nx
@raghu-nx
Jan 17 2017 02:19 UTC
I’m not sure if you understand what I meant.
Basically var ele = arr.shift() would pop the first element from the array and return it
Now for a function to reuturn a value you need to use return statement. So, essentially it would be return ele;
Dan
@RetartedZombie
Jan 17 2017 02:22 UTC
Thanks @sjames1958gm . Must have been getting stuck on something else then :)
CamperBot
@camperbot
Jan 17 2017 02:22 UTC
retartedzombie sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5375 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 17 2017 02:22 UTC
unshift adds to the front - @colinmac17
Chris Harrison
@ceharrison
Jan 17 2017 02:23 UTC

Not quite sure what im missing here, should return a count of -5, i think:
var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2,3,4,5,6) {
return count ++;
} else if (card == 10, 'K', 'Q', 'J', 'A') {
return count --;
}
return count;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

sorry, should return 5
Stephen James
@sjames1958gm
Jan 17 2017 02:24 UTC
@ceharrison card == 2, 3, 4, 5, 6 is not how you test for various values you need ||
Colin McAtee
@colinmac17
Jan 17 2017 02:24 UTC
ah I did mean shift() @sjames1958gm still having trouble. I was using a for loop but having trouble getting it to work
Chris Harrison
@ceharrison
Jan 17 2017 02:24 UTC
could you expand?
@sjames1958gm
Chris Harrison
@ceharrison
Jan 17 2017 02:25 UTC
so there's not a short way to write it?
Stephen James
@sjames1958gm
Jan 17 2017 02:25 UTC
@colinmac17 This does not require a loop - just two statements one to add item to the end of arr and one to remove and return the first value of arr
@ceharrison no, you could use a switch / case but that is even longer
Johnny
@JohnnyBizzel
Jan 17 2017 02:26 UTC
@mtpjr88
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++){
    if(Array.isArray(arr[i])) {
      product = arr[i].reduce(function(a,e) {
        return a * e
      }, product);
    } else {
      product *= arr[i];
    }
  }
  // Only change code above this line
  return product;
}
Chris Harrison
@ceharrison
Jan 17 2017 02:26 UTC
ok, i'll give that a shot, thanks
John Nunns
@johnnunns
Jan 17 2017 02:27 UTC
var customerData = {
  'Joe': {
    visits: 1
  },
  'Carol': {
    visits: 2
  },
  'Howard': {
    visits: 3
  },
  'Carrie': {
    visits: 4
  }
};

function greetCustomer(firstName) {
  var greeting = '';

  if(customerData['firstName'].visits === 1){
      greeting = "Welcome back, " + firstName + "! We're glad you liked us the first time!"
  }else if()

  return greeting;
}
greetCustomer("Joe")
can anyone see here why visits is coming up as undefined?
when I replace ['firstName'] with ['Joe'], it works, but I want it to work for all customers
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:29 UTC
@sjames1958gm go to question 176 on the map
John Nunns
@johnnunns
Jan 17 2017 02:29 UTC
I've also tried if(customerData.property.visits===1)
raghu-nx
@raghu-nx
Jan 17 2017 02:29 UTC
customerData[‘firstName’] => access property firstName on the object
customerData[firstName] => access property where the property name is the value of the variable firstName
Stephen James
@sjames1958gm
Jan 17 2017 02:30 UTC
@c0mplexm0z if you are talking stand in line I am quite familir with it
raghu-nx
@raghu-nx
Jan 17 2017 02:30 UTC
basically ‘firstName’ is a string but you want to access it as a variable
John Nunns
@johnnunns
Jan 17 2017 02:31 UTC
what's the order again? object, property, value?
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:31 UTC
so when the testArr is 1,2,3,4,5 - how can nextInLine([5,6,7,8,9], 1) return 5?
Chris Harrison
@ceharrison
Jan 17 2017 02:31 UTC

@sjames1958gm can you explain why this returns "4":
var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card == 4 || card ==5 || card == 6) {
return count ++;
} else if (card == 10 || card == 'K' ||card == 'Q' ||card == 'J' ||card == 'A') {
return count --;
}
return count;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

raghu-nx
@raghu-nx
Jan 17 2017 02:32 UTC
yeah [] notation or .(dot) both try to access the property of an object. So the expression evaluates to value of the property
Stephen James
@sjames1958gm
Jan 17 2017 02:32 UTC
@ceharrison because return count ++ returns the value of count before the last increment.
You should not return there or in the else
Because you need to test count > 0 to determine what to return.
AndrewScr
@AndrewScr
Jan 17 2017 02:34 UTC
can i ask for more help again with the escape sequences
var myStr = "FirstLine\n\SecondLine\rThirdLine\";
is the solution i have so far
John Nunns
@johnnunns
Jan 17 2017 02:36 UTC
i got it. Thanks @raghu-nx
CamperBot
@camperbot
Jan 17 2017 02:36 UTC
johnnunns sends brownie points to @raghu-nx :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @raghu-nx |http://www.freecodecamp.com/raghu-nx
Colin McAtee
@colinmac17
Jan 17 2017 02:37 UTC
@sjames1958gm thanks for the tip!
CamperBot
@camperbot
Jan 17 2017 02:37 UTC
colinmac17 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5376 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 17 2017 02:37 UTC
@colinmac17 :+1:
@AndrewScr Your last \ is out of place there should be a \ escaped after SecondLine
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:38 UTC
function nextInLine(arr, item) {
arr.push(item);
var shiftedVar = arr.shift();
return shiftedVar;
}
About time
CamperBot
@camperbot
Jan 17 2017 02:38 UTC
you need to ask about @someone!
raghu-nx
@raghu-nx
Jan 17 2017 02:39 UTC
@c0mplexm0z nice!
AndrewScr
@AndrewScr
Jan 17 2017 02:39 UTC
@sjames1958gm var myStr = "FirstLine\n \SecondLine\r\ ThirdLine"; // Change this line
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:40 UTC
@raghu-nx cheers man!
AndrewScr
@AndrewScr
Jan 17 2017 02:40 UTC
like that?
it still doesn't like it
Chris Harrison
@ceharrison
Jan 17 2017 02:40 UTC
@sjames1958gm im a little confused how to return a < or > 0 after the "if else"
Stephen James
@sjames1958gm
Jan 17 2017 02:40 UTC
@AndrewScr The other side of the \r and then remove all the spaces
@ceharrison Another if / else
if count > 0
else
Chris Harrison
@ceharrison
Jan 17 2017 02:42 UTC
does that require different indents than the previous if/else statements?
Michael Pimentel Jr
@mtpjr88
Jan 17 2017 02:42 UTC

i need help```function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length[i]; i++){
product *= arr1;
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

```

AndrewScr
@AndrewScr
Jan 17 2017 02:42 UTC
@sjames1958gm thanks again
CamperBot
@camperbot
Jan 17 2017 02:42 UTC
andrewscr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: andrewscr already gave sjames1958gm points
AndrewScr
@AndrewScr
Jan 17 2017 02:43 UTC
still not going
var myStr = "FirstLine\n\SecondLine\rThirdLine"; // Change this line
Michael Pimentel Jr
@mtpjr88
Jan 17 2017 02:43 UTC
some help
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length[i]; i++){
  product *= arr[1];
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Dylan
@dhcodes
Jan 17 2017 02:43 UTC
@mtpjr88 that looks close, but you want to use [i] in your loop
AndrewScr
@AndrewScr
Jan 17 2017 02:43 UTC
var myStr = "FirstLine\n\SecondLine\rThirdLine"; // Change this line
var myStr = "FirstLine\n\SecondLine\rThirdLine"; // Change this line
wtf the chat is removing a slash
Dylan
@dhcodes
Jan 17 2017 02:43 UTC
@mtpjr88 also, I think you may need nested loops (an i loop and a j loop)
Stephen James
@sjames1958gm
Jan 17 2017 02:44 UTC
@AndrewScr On either end of SecondLine there should be escape backslashes
Dylan
@dhcodes
Jan 17 2017 02:44 UTC
@AndrewScr put your code inbetween single or triple backticks
raghu-nx
@raghu-nx
Jan 17 2017 02:44 UTC
@mtpjr88 each element in the arr argument itself is an array. so yeah as @dhcodes said
c0mplexm0z
@c0mplexm0z
Jan 17 2017 02:45 UTC
@raghu-nx PM'ed you man
AndrewScr
@AndrewScr
Jan 17 2017 02:46 UTC
var myStr = "FirstLine\n\SecondLine\rThirdLine"; // Change this line
chat still removing backslashes
Dylan
@dhcodes
Jan 17 2017 02:47 UTC
@AndrewScr you should put it between backticks
Chris Harrison
@ceharrison
Jan 17 2017 02:47 UTC

I'm still not sure why this is returning "5":
var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card == 4 || card ==5 || card == 6) {
count ++;
} else if (card == 10 || card == 'K' ||card == 'Q' ||card == 'J' ||card == 'A') {
count --;
}
return count;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

AndrewScr
@AndrewScr
Jan 17 2017 02:47 UTC
whats a backtick?
@dhcodes
Rony Vidaur
@RonyVidaur
Jan 17 2017 02:47 UTC
@AndrewScr `
is under the esc key
Dylan
@dhcodes
Jan 17 2017 02:48 UTC
what he said
'''
CamperBot
@camperbot
Jan 17 2017 02:48 UTC
:bulb: to format code use backticks! ``` more info
Dylan
@dhcodes
Jan 17 2017 02:48 UTC
click 'more info'
AndrewScr
@AndrewScr
Jan 17 2017 02:49 UTC
thank you
Michael Pimentel Jr
@mtpjr88
Jan 17 2017 02:49 UTC
@raghu-nx @dhcodes so I got it right
but i dont fully understand it

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++){
  for (var j = 0; j < arr[i].length; j++){
    product *= arr[i][j];
  }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
AndrewScr
@AndrewScr
Jan 17 2017 02:49 UTC
the lesson doesn't mention backticks
Rony Vidaur
@RonyVidaur
Jan 17 2017 02:49 UTC
@ceharrison hmmm you're calling the function 5 times and every card number you're sending increments the count variable by 1
AndrewScr
@AndrewScr
Jan 17 2017 02:50 UTC
maybe i missed it earlier
Dylan
@dhcodes
Jan 17 2017 02:52 UTC
@AndrewScr i'm saying the chat is removing your backspace becuase you're not formatting it as code in the chat (by using backticks)
AndrewScr
@AndrewScr
Jan 17 2017 02:52 UTC
oh
there i was typing it into the editor wondering why you were suggesting i type invalid js
var myStr = "FirstLine\n\\SecondLine\\rThirdLine"; // Change this line
:)
John Nunns
@johnnunns
Jan 17 2017 02:53 UTC
var customerData = {
  'Joe': {
    visits: 1
  },
  'Carol': {
    visits: 2
  },
  'Howard': {
    visits: 3
  },
  'Carrie': {
    visits: 4
  }
};

function greetCustomer(firstName) {
  var greeting = '';
    if(customerData[firstName] !== firstName){
        greeting = "Welcome! Is this your first time?"
    }if(customerData[firstName].visits === 1){
      greeting = "Welcome back, " + firstName + "! We're glad you liked us the first time!"
    }else {
      greeting = "Welcome back, " + firstName + "! So glad to see you again!"
    }


  return greeting;
}
greetCustomer("John")
any ideas why a new customer isn't working?
Dylan
@dhcodes
Jan 17 2017 02:53 UTC
@mtpjr88 you have 1, and then the first i loop loops through the outside array (the one with all the sub arrays), then the j loop loops through all the individual items in each subarray and *= multiplies them with 1 and returns the new value
Chris Harrison
@ceharrison
Jan 17 2017 02:53 UTC
i guess im not following @RonyVidaur...
raghu-nx
@raghu-nx
Jan 17 2017 02:53 UTC
@mtpjr88 ok when i generally face such issues, i would start down with a pen and paper and write down the values of i and j and update the values by executing the function by hand
that provides great clarity
i would suggest doing that and if you still have issues you can ask again
CoryCMyers
@CoryCMyers
Jan 17 2017 02:54 UTC
I think I may have a bug on my hands. This is on the Iterate with Javascript for Loops. It wants me to push 1-5 to myArray and I am doing that but it still says that myArray should equal [1,2,3,4,5] Which it does.
// Example
var ourArray = [];

for (var i = 0; i < 5; i++) {
  ourArray.push(i);
}

// Setup
var myArray = [];

// Only change code below this line.
for (var i = 0; i <= 5; i++) {
  myArray.push(i);
}
John Nunns
@johnnunns
Jan 17 2017 02:54 UTC
sorry, let me correct myself. Changed "if" to "else if" but now it prints the first greeting for everyone
Dylan
@dhcodes
Jan 17 2017 02:54 UTC
proud of you @CoryCMyers for checking your bug in the chat first ;)
CoryCMyers
@CoryCMyers
Jan 17 2017 02:55 UTC
@dhcodes Thankee Sai
Dylan
@dhcodes
Jan 17 2017 02:56 UTC
@CoryCMyers i think your issue is i<=5 should be i<5
CoryCMyers
@CoryCMyers
Jan 17 2017 02:57 UTC
@dhcodes it asks for it to push 1-5 to the array though, would'nt i<5 only push 1-4?
Long Vu
@longorjames
Jan 17 2017 02:57 UTC
I'm stuck on this Word Blanks

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
My myAdjective myNoun myAdverb myVerb straight into the pile of leaves.

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

idk if I'm supposed to make a sentence or what
the directions are confusing me
Dylan
@dhcodes
Jan 17 2017 02:57 UTC
@CoryCMyers no because remember that while i<5, i will increment up to 5 and be pushed
so even when i is 4, the loop will run
Rony Vidaur
@RonyVidaur
Jan 17 2017 02:58 UTC
@ceharrison you're making these cc(2); cc(3); cc(4); cc(5); cc(6);
count++
count was 0, now it is 1
and so on
Chris Harrison
@ceharrison
Jan 17 2017 02:59 UTC
I see that they would add up to a 5. I'm confused on how show a "bet" or "hold" givin a >0 or <0.
CoryCMyers
@CoryCMyers
Jan 17 2017 02:59 UTC
@dhcodes Just tried that fix and it only displayed up to 4 in the check your results area.
Rony Vidaur
@RonyVidaur
Jan 17 2017 02:59 UTC
@ceharrison oh
Dylan
@dhcodes
Jan 17 2017 02:59 UTC
@CoryCMyers can you paste your url
CoryCMyers
@CoryCMyers
Jan 17 2017 03:00 UTC
@dhcodes This is with the i<5 want me to do it after running how I had it originally?
Long Vu
@longorjames
Jan 17 2017 03:01 UTC
Has anyone done the Word Blanks project before?
Dylan
@dhcodes
Jan 17 2017 03:01 UTC
@longorjames yes
Long Vu
@longorjames
Jan 17 2017 03:01 UTC
I don't understand how they want me to start it
do I start making a sentence ?
and then just fill in spots with myNoun, myAdjective, etc.?
Dylan
@dhcodes
Jan 17 2017 03:02 UTC
@CoryCMyers ah,
my bad
you were rigth
Long Vu
@longorjames
Jan 17 2017 03:02 UTC
I know how Mad Libs works... but I'm really confused
Dylan
@dhcodes
Jan 17 2017 03:02 UTC
but your i should be 1
@CoryCMyers
Long Vu
@longorjames
Jan 17 2017 03:02 UTC

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

CoryCMyers
@CoryCMyers
Jan 17 2017 03:03 UTC
@dhcodes oh I feel silly. they want 1-5 and I have 0 in there
Long Vu
@longorjames
Jan 17 2017 03:03 UTC

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Greg Duncan
@GregatGit
Jan 17 2017 03:03 UTC
@johnnunns if they are back you should make their visits go up by 1, or if it's there first time add them to the customerData obj with visists at 1
Dylan
@dhcodes
Jan 17 2017 03:03 UTC
@longorjames set the result equal to a string made of the function's arguments concatenated together
@CoryCMyers :+1:
CoryCMyers
@CoryCMyers
Jan 17 2017 03:03 UTC
@dhcodes thanks
CamperBot
@camperbot
Jan 17 2017 03:03 UTC
corycmyers sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1697 | @dhcodes |http://www.freecodecamp.com/dhcodes
John Nunns
@johnnunns
Jan 17 2017 03:04 UTC
@GregatGit it specifically tells me to not worry about a count++, but the code still doesn't run correctly. I think the problem is in the first if statement.
Dylan
@dhcodes
Jan 17 2017 03:05 UTC
@longorjames this is one of the first challenges with a reusable function. The tests will supply different values to the arguments of the function (ex. myNoun) so your job is to build a string using those variable names (and spaces inbetween) and then assign it to result
Andy
@drywallandy
Jan 17 2017 03:05 UTC

// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

can anyone tell me why this isn't working for me. I am new to all this

Long Vu
@longorjames
Jan 17 2017 03:06 UTC
@drywallandy delete myStr[0]=
Dylan
@dhcodes
Jan 17 2017 03:06 UTC
@drywallandy remove the last line
Long Vu
@longorjames
Jan 17 2017 03:06 UTC
yeah what Dylan said
Greg Duncan
@GregatGit
Jan 17 2017 03:06 UTC
@johnnunns your if condition logic is a little off
AndrewScr
@AndrewScr
Jan 17 2017 03:08 UTC
can anyone help me
still not workng
Andy
@drywallandy
Jan 17 2017 03:08 UTC
thanks, I was almost going to start beating my head against the wall
AndrewScr
@AndrewScr
Jan 17 2017 03:08 UTC
var myStr = "FirstLine\n\\SecondLine\rThirdLine"; // Change this line
Long Vu
@longorjames
Jan 17 2017 03:08 UTC
@dhcodes sooooo result = "My" + myAdjective + myNoun + myAdverb + myVerb " into the pile of leaves.";
Dylan
@dhcodes
Jan 17 2017 03:09 UTC
@longorjames yeah but with some spaces
ex. "My "
and spaces in between the arguments
Long Vu
@longorjames
Jan 17 2017 03:09 UTC
it just gives me an error with unexpected string
also it asks for an extra word blank with cats and stuff
Krittiya Clark
@krittiyaclark
Jan 17 2017 03:10 UTC
Hey guys - I need help with the Convert Celsius to Fahrenheit challenge!
Dylan
@dhcodes
Jan 17 2017 03:10 UTC
@longorjames you need to have a + before the last line
Greg Duncan
@GregatGit
Jan 17 2017 03:10 UTC
@johnnunns it is always going to check this if(customerData[firstName].visits === 1) and for "Joe" it doesn't exist so you will get an error
Long Vu
@longorjames
Jan 17 2017 03:10 UTC
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
do I just add that or am I supposed to change the dog stuff
Dylan
@dhcodes
Jan 17 2017 03:10 UTC
@longorjames those tests will be passed to the function
so just fix the function
you don't need to write the function for each test
@krittiyaclark what's up
Long Vu
@longorjames
Jan 17 2017 03:11 UTC
result = "My " + myAdjective + myNoun + myAdverb + myVerb + " into the pile of leaves.";
Dylan
@dhcodes
Jan 17 2017 03:11 UTC
@longorjames but you need spaces between your variables
Long Vu
@longorjames
Jan 17 2017 03:12 UTC
? there are spaces?
I'm confused
Krittiya Clark
@krittiyaclark
Jan 17 2017 03:12 UTC
@dhcodes got stuck. not understand.
Dylan
@dhcodes
Jan 17 2017 03:12 UTC
@longorjames not between your variable
Greg Duncan
@GregatGit
Jan 17 2017 03:12 UTC
@johnnunns if the first condition is correct you want it to exit the function immediately - not make anymore evalution - so instead of setting greeting to "Welcome! Is this your first time?" just return "Welcome! Is this your first time?";
Krittiya Clark
@krittiyaclark
Jan 17 2017 03:12 UTC
@dhcodes "The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32."
Dylan
@dhcodes
Jan 17 2017 03:13 UTC
@krittiyaclark understandable; the tests will give you a celsius value
Long Vu
@longorjames
Jan 17 2017 03:13 UTC
my variables?
Moisés Man
@moigithub
Jan 17 2017 03:13 UTC
@longorjames WHY u added space on ur "My "+myAdjective ?
Long Vu
@longorjames
Jan 17 2017 03:13 UTC
you mean the myAdjective and stuff
Dylan
@dhcodes
Jan 17 2017 03:13 UTC
you need to return a formula using the variable celsius @krittiyaclark
Long Vu
@longorjames
Jan 17 2017 03:13 UTC
@moigithub Dylan said I needed spaces
Dylan
@dhcodes
Jan 17 2017 03:13 UTC
@moigithub hey that's fine
he just needs spaces between the variables
Long Vu
@longorjames
Jan 17 2017 03:13 UTC
i don't understand how to add spaces between the variables, aren
Dylan
@dhcodes
Jan 17 2017 03:14 UTC
@longorjames myVariable + " " + nextVariable
Long Vu
@longorjames
Jan 17 2017 03:14 UTC
aren't there already spaces?
.... oh
Dylan
@dhcodes
Jan 17 2017 03:14 UTC
;)
otherwise they'd all be smashed together
Long Vu
@longorjames
Jan 17 2017 03:14 UTC
do i put a space in between the quotes
or just leave empty quotes?
Dylan
@dhcodes
Jan 17 2017 03:14 UTC
you put a space
Long Vu
@longorjames
Jan 17 2017 03:15 UTC
ok it worked. that is odd o.O
not intuitive at all....
@dhcodes thank you very much
CamperBot
@camperbot
Jan 17 2017 03:15 UTC
longorjames sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1698 | @dhcodes |http://www.freecodecamp.com/dhcodes
Long Vu
@longorjames
Jan 17 2017 03:15 UTC
@dhcodes thank you very much
CamperBot
@camperbot
Jan 17 2017 03:15 UTC
:warning: longorjames already gave dhcodes points
longorjames sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
Krittiya Clark
@krittiyaclark
Jan 17 2017 03:15 UTC

@dhcodes I got this --> function convertToF(celsius) {
var fahrenheit = (celsius(9/5))+32;
// Only change code below this line

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

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

Dylan
@dhcodes
Jan 17 2017 03:15 UTC
@longorjames that's how you build strings with variables though
Moisés Man
@moigithub
Jan 17 2017 03:16 UTC
@krittiyaclark u need an * to multiplicate values
Dylan
@dhcodes
Jan 17 2017 03:16 UTC
@krittiyaclark looks good, just add a * after celsius
and return fahrenheit
Long Vu
@longorjames
Jan 17 2017 03:16 UTC
idk how I was supposed to know that though, it wasn't discussed in any previous teachings of how to use strings
or variables
Dylan
@dhcodes
Jan 17 2017 03:16 UTC
sure it was
Long Vu
@longorjames
Jan 17 2017 03:17 UTC
we were taught to add strings
Dylan
@dhcodes
Jan 17 2017 03:17 UTC
Constructing Strings with Variables
Long Vu
@longorjames
Jan 17 2017 03:17 UTC
not strings and variables
Dylan
@dhcodes
Jan 17 2017 03:17 UTC
and concatenating strings
Long Vu
@longorjames
Jan 17 2017 03:17 UTC
nor did they use empty space quotes in between
Dylan
@dhcodes
Jan 17 2017 03:17 UTC
yeah, you have to merge the ideas
this challenge is a common question in the chat
no worries
Long Vu
@longorjames
Jan 17 2017 03:18 UTC
well i just felt the core ideas to put together weren't given is what i mean
Dylan
@dhcodes
Jan 17 2017 03:19 UTC
i get that
Long Vu
@longorjames
Jan 17 2017 03:19 UTC
so idk who makes this website or the projects but I think they should add smaller steps in between or more hints or something
I'm just glad there are people to get help from on here cause i'd probably give up...
Dylan
@dhcodes
Jan 17 2017 03:20 UTC
well there is this issue freeCodeCamp/freeCodeCamp#9233
but the changes won't be live until the next site update
Krittiya Clark
@krittiyaclark
Jan 17 2017 03:21 UTC
@dhcodes Hey - that it! lol
Thanks:)
Rebecca
@alimily
Jan 17 2017 03:22 UTC

function reverseString(str) {
var array=str.split(" ");

for(i=0;i<array.length;i++){
array[i]=array[i].reverse();
}
str=array.join(" ");

return str;

                 }

reverseString("Greetings from Earth");

Krittiya Clark
@krittiyaclark
Jan 17 2017 03:22 UTC
@dhcodes Thanks:)
CamperBot
@camperbot
Jan 17 2017 03:22 UTC
krittiyaclark sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1699 | @dhcodes |http://www.freecodecamp.com/dhcodes
Rebecca
@alimily
Jan 17 2017 03:22 UTC
what is wrong with these codes
Dylan
@dhcodes
Jan 17 2017 03:22 UTC
you're welcome! great job getting it mostly on your own
that's a hard challenge @krittiyaclark
Rebecca
@alimily
Jan 17 2017 03:23 UTC
function reverseString(str) {
var array=str.split(" ");
for(i=0;i<array.length;i++){
array[i]=array[i].reverse();
}
str=array.join(" ");
return str;
Dylan
@dhcodes
Jan 17 2017 03:23 UTC
@alimily you are splitting on the spaces
I think you want to split on ""
which means split every character
what challenges is that
Rebecca
@alimily
Jan 17 2017 03:24 UTC
no every word
Reverse a String
i want to splitting every word ,and reverse every word
then join them to a string again
Dylan
@dhcodes
Jan 17 2017 03:25 UTC
gotcha
Rebecca
@alimily
Jan 17 2017 03:27 UTC
yes
Dylan
@dhcodes
Jan 17 2017 03:27 UTC
@alimily array[i] is a string
Rebecca
@alimily
Jan 17 2017 03:28 UTC
why is a string
i can undetstand
Dylan
@dhcodes
Jan 17 2017 03:29 UTC
because it's the first word in the array you made
Rebecca
@alimily
Jan 17 2017 03:29 UTC

function reverseString(str) {
var array=[];
array=str.split(" ");

for(i=0;i<array.length;i++){
array[i]=array[i].reverse();
}
str=array.join(" ");

return str;

                 }

reverseString("Greetings from Earth");

Dylan
@dhcodes
Jan 17 2017 03:29 UTC
you cannot run reverse() on a string
Rebecca
@alimily
Jan 17 2017 03:29 UTC
this will be ok?
Dylan
@dhcodes
Jan 17 2017 03:30 UTC
you need to split array[i] on a "" and then run reverse on that
i gotta go though. Good luck!
Rebecca
@alimily
Jan 17 2017 03:31 UTC
ok
thks
Krate2016
@Krate2016
Jan 17 2017 03:32 UTC
Challenge 161 Global Scope and Functions help
I have defined myGlobal variable, declared, it, and avoid declaring oopsGlobal. I am having a hard time assigning values to myGlobal and oopsGlobal. Where should I start reviewing?
Manish Giri
@Manish-Giri
Jan 17 2017 03:36 UTC
@Krate2016 post your code here
Krate2016
@Krate2016
Jan 17 2017 03:38 UTC

@Manish-Giri // Declare your variable here
var myGlobal = [10];

function fun1() {var myGlobal = 10; return myGlobal;}
// Assign 5 to oopsGlobal Here

oopsGlobal = [5];
function fun2() {oopsGlobal = 5; return oopsGlobal;}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Manish Giri
@Manish-Giri
Jan 17 2017 03:38 UTC
@Krate2016 what's with the arrays?
var myGlobal = [10];
oopsGlobal = [5];
shouldn't it be just a plain number?
also, this is where your code goes

// Declare your variable here
//myGlobal here

function fun1() {
  // Assign 5 to oopsGlobal Here
 //your oopsGlobal assignment should be here  
}
not sure what this is for
function fun1() {var myGlobal = 10; return myGlobal;}
// Assign 5 to oopsGlobal Here

oopsGlobal = [5];
function fun2() {oopsGlobal = 5; return oopsGlobal;}
Krate2016
@Krate2016
Jan 17 2017 03:42 UTC
@Manish-Giri That was my bad, thanks!
CamperBot
@camperbot
Jan 17 2017 03:42 UTC
krate2016 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3829 | @manish-giri |http://www.freecodecamp.com/manish-giri
Rebecca
@alimily
Jan 17 2017 03:42 UTC

function reverseString(str) {
var array=[];
array=str.split(" ");
array.reverse();
str=array.join(" ");
return str;

                 }

reverseString("Greetings from Earth");

hello
everyone
please,help me
Manish Giri
@Manish-Giri
Jan 17 2017 03:44 UTC

@alimily this is your expected output

reverseString("Greetings from Earth") should return "htraE morf sgniteerG".

this is your actual output -

"Earth from Greetings"

Greg Duncan
@GregatGit
Jan 17 2017 03:46 UTC
@alimily str = str.split(" ");
no need for a new variable
Manish Giri
@Manish-Giri
Jan 17 2017 03:46 UTC
@alimily you are just changing the order of the words - 1 2 3 becomes 3 2 1
but you need ro reverse each word too
Ammy3165
@Ammy3165
Jan 17 2017 03:55 UTC

hi, help to solve this challenge(chunkey monkey),
function chunkArrayInGroups(arr, size) {
// Break it up.

if(size<=arr.length){
return arr.slice(0,size);
}else
return "it's out of array";

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

J. Kelley
@jothetraveler
Jan 17 2017 04:05 UTC

Evening! Some assistance would be greatly appreciated! I'm getting a message saying break is unreachable after return.
var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case (2):
case (3):
case (4):
case (5):
case (6):
return count + 1;
break;
case (7):
case (8):
case (9):
return count;
break;
case (10):
case ('J'):
case ('Q'):
case ('K'):
case ('A'):
return count - 1;
break;
}

return "Change Me";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Ammy3165
@Ammy3165
Jan 17 2017 04:08 UTC
hey is there anyone to give me assistance on above posted challenge
Greg Duncan
@GregatGit
Jan 17 2017 04:10 UTC
@jothetraveler don't use return in the switch - just assing count a value
M.Sohaib
@coolcoder007
Jan 17 2017 04:12 UTC

var myVar = 87;

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

what,s wrong with my code
Ammy3165
@Ammy3165
Jan 17 2017 04:13 UTC
@coolcoder007 what's the challenge
M.Sohaib
@coolcoder007
Jan 17 2017 04:14 UTC
increment the number with javaScript

var myVar = 87;

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

Greg Duncan
@GregatGit
Jan 17 2017 04:14 UTC
@coolcoder007 myVar++;
M.Sohaib
@coolcoder007
Jan 17 2017 04:14 UTC
@Ammy3165 h
@GregatGit thanks
CamperBot
@camperbot
Jan 17 2017 04:15 UTC
coolcoder007 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 827 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jan 17 2017 04:16 UTC
@Ammy3165 you are just returning on slice of the array - you have to return all the numbers
Joseph
@revisualize
Jan 17 2017 04:18 UTC
Hello. :)

@coolcoder007

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

@jothetraveler 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.
Doegena Fennich
@Doegena
Jan 17 2017 04:19 UTC

Need some help

How do you make a selectbox with the switch statement ?

<select>

<optgroup>Group 1</optgroup>

<option>1</option>

<option>2</option>

<option>3</option>

<optgroup>Group 2</optgroup>
etc

@revisualize Hey Joseph good timing :D

Joseph
@revisualize
Jan 17 2017 04:20 UTC
@Doegena No idea.
@Doegena If I was trying to create HTML entries like that .. I wouldn't use a switch at all.
@Doegena So, I have no idea how to do that with a switch statement.
I would use nested objects with properties that I wanted to define.
Doegena Fennich
@Doegena
Jan 17 2017 04:28 UTC
@revisualize me neither, but need to make it with a switch statement, if i can do this and some other random tests/projects (drawing application, basic chatserver), i will graduate in 1 or 2 years instead of 3. well if i pass the test
J. Kelley
@jothetraveler
Jan 17 2017 04:28 UTC
@GregatGit @revisualize Thank you. I think I see where I went wrong now
CamperBot
@camperbot
Jan 17 2017 04:28 UTC
jothetraveler sends brownie points to @gregatgit and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 828 | @gregatgit |http://www.freecodecamp.com/gregatgit
:star2: 2995 | @revisualize |http://www.freecodecamp.com/revisualize
Doegena Fennich
@Doegena
Jan 17 2017 04:30 UTC
@revisualize but i have currently no idea how to make a chatserver with javascript
deepakSpatil
@deepakSpatil
Jan 17 2017 04:38 UTC
@deepakSpatil
ant idea why this graph is broken?
http://bl.ocks.org/mhawksey/1505811
Barry Stepp
@barrystepp
Jan 17 2017 04:41 UTC
function caseInSwitch(val) {
var answer = "";
switch (val) {
case 1:
answer = "alpha";
break;
Emily Sperry
@sperrye
Jan 17 2017 04:42 UTC
is there some obvious reason I don't know about that I can't use .toUpperCase() ?
Barry Stepp
@barrystepp
Jan 17 2017 04:42 UTC

function caseInSwitch(val) {
var answer = "";

switch (val) {
case 1:
answer = "alpha";
break;

Can anyone explain what i'm doing wrong here?

Joseph
@revisualize
Jan 17 2017 04:42 UTC
@Doegena You have no idea how to make a chat server with JavaScript. Well neither do I. Nor do I care to learn.
@barrystepp You haven't finished it?
Emily Sperry
@sperrye
Jan 17 2017 04:43 UTC

```function myReplace(str, before, after) {
var newStr = str.split(' ');

var index = newStr.indexOf(before);

if (index !== -1) {
if (index[0] === index[0].toUpperCase())
newStr[index] = after[0].toUpperCase() + after.slice(1);
}

//capitalization

return newStr.join(' ');
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
```

Joseph
@revisualize
Jan 17 2017 04:43 UTC
@sperrye Strings are immutable.
Barry Stepp
@barrystepp
Jan 17 2017 04:44 UTC

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
answer = "alpha";
break;

case 2:
answer = "beta";
break;

case 3:
answer = "gamma";
break;

case 4:
answer = "delta";

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

@barrystepp Does that work?
@barrystepp OH!
@barrystepp
return answer; }
is inside of your switch case for 4
@barrystepp It should be outside of your switch.
Barry Stepp
@barrystepp
Jan 17 2017 04:45 UTC
@revisualize THANK YOU!!!!
CamperBot
@camperbot
Jan 17 2017 04:45 UTC
barrystepp sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2996 | @revisualize |http://www.freecodecamp.com/revisualize
Barry Stepp
@barrystepp
Jan 17 2017 04:46 UTC
I hate it when its something so simple as that... but at least i know i got the general concept.... just messed up on that little curly guy.
Joseph
@revisualize
Jan 17 2017 04:47 UTC
@sperrye index is a number.
Emily Sperry
@sperrye
Jan 17 2017 04:47 UTC
@revisualize Thanks, I did figure it out :)
CamperBot
@camperbot
Jan 17 2017 04:47 UTC
sperrye sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2997 | @revisualize |http://www.freecodecamp.com/revisualize
Emily Sperry
@sperrye
Jan 17 2017 04:48 UTC
Oh look, another algorithm challenge..
Joseph
@revisualize
Jan 17 2017 04:48 UTC
@sperrye Did you solve it?
@sperrye Did you ever go to that meetup thing?
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:50 UTC
I am stuck on this challenge.
Joseph
@revisualize
Jan 17 2017 04:50 UTC
@kayvanote Which?
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:50 UTC
profile Lookup
Joseph
@revisualize
Jan 17 2017 04:50 UTC
@kayvanote How can I help?
Doegena Fennich
@Doegena
Jan 17 2017 04:51 UTC

@revisualize OOOhh, misunderstood the question, if the user CLICKS a genre the user needs to see the movies of that genre :laughing:

example

 case '0': 
        document.getElementById('v').innerHTML ='<ul><li>example<li></ul>';
       break;
Joseph
@revisualize
Jan 17 2017 04:51 UTC
@kayvanote What is the current state of your function?
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:51 UTC
should paste it?
Joseph
@revisualize
Jan 17 2017 04:51 UTC
@kayvanote Just the function. Not the large array of object. Just the function.
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:52 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts.hasOwnProperty(firstName) === false) {
return "No such contact";}
else if (contacts.hasOwnProperty(prop) === false) {
return "No such property";}
else if (contacts.hasOwnProperty(firstName) === true && contacts.hasOwnProperty(prop) === true) {
return contacts[prop];}
// Only change code above this line
}
Joseph
@revisualize
Jan 17 2017 04:52 UTC
@kayvanote Okay.
First issue.
@kayvanote We have an array of objects representing different people in our contacts lists.
Example: var contacts = [ { ... } , { ... } , { ... } , { ... } ];
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:53 UTC
okay
yes true
Joseph
@revisualize
Jan 17 2017 04:54 UTC
@kayvanote So, you're not accessing the array element correctly. Nor are you iterating across the array elements
@kayvanote Do you understand what I mean?
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:55 UTC
I tried iterating with a for loop.
Joseph
@revisualize
Jan 17 2017 04:55 UTC
It is okay to say no. I can help you understand.
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:55 UTC
yes
Joseph
@revisualize
Jan 17 2017 04:55 UTC
@kayvanote Well, you need one for this lesson.
Kayvan Taherpour
@kayvanote
Jan 17 2017 04:57 UTC
if I used for (var i = 0; i < contacts.length ; i++ )
and then maybe an inner loop
Joseph
@revisualize
Jan 17 2017 04:58 UTC
@kayvanote Why would you need an inner loop?
Objects don't have .lengths
Chinmaya B
@sharang108
Jan 17 2017 05:02 UTC
Esacpe Sequences are not working in JS possible bug/
?
Liz Chen
@moist17
Jan 17 2017 05:02 UTC

Hi everyone, I often get stuck at 'why only looping once' problem...like this twitch project
https://jsfiddle.net/k456czcm/
though it logs every stram IDs i set up, it just can't return all the streams IDs into HTML

wonder anyone could help me? thanks.
I encountered similar problems lots of time while doing other projects, but I just couldn't figure out ... /_\

Chinmaya B
@sharang108
Jan 17 2017 05:02 UTC
This is my code
var myStr = "FirstLine\n\SecondLine\\n\rThirdLine";
Kayvan Taherpour
@kayvanote
Jan 17 2017 05:02 UTC
thank you for the hints and the link, appreciated!
Liz Chen
@moist17
Jan 17 2017 05:03 UTC
though it logs every stram IDs i set up, it just can't return all the streams IDs into HTML
Chinmaya B
@sharang108
Jan 17 2017 05:03 UTC
var myStr="FirstLine\n\SecondLine\\n\rThirdLine";
output : var myStr = "FirstLine\n\SecondLine\\n\rThirdLine";
Manuel Rauda
@Gameruler1
Jan 17 2017 05:04 UTC
Hey guys I'm stuck in "Using Objects for Lookups" can someone help me
Chinmaya B
@sharang108
Jan 17 2017 05:04 UTC
@Vizij Every this is returned as it is even If I try this
myStr ="Firstline\nString2";
I will get output: "Firstline\nString2";
Ammy3165
@Ammy3165
Jan 17 2017 05:07 UTC

@revisualize hi, I am stuck here, Pls look into,
function chunkArrayInGroups(arr, size) {
// Break it up.

var newArray= [];

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

newArray.push(arr.slice(0,size));
arr= arr.slice(size);

}
return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Joseph
@revisualize
Jan 17 2017 05:07 UTC
@sharang108 Why are you escaping a newline after SecondLine?
@sharang108 There isn't a bug. You aren't doing it correctly.
arkosingh
@arkosingh
Jan 17 2017 05:09 UTC
how to?
FirstLine
\SecondLine\
ThirdLine
Joseph
@revisualize
Jan 17 2017 05:09 UTC
@Ammy3165 may I recommend using www.pythontutor.com/javascript.html
Coy Sanders
@coymeetsworld
Jan 17 2017 05:09 UTC
@moist17 I don't think you want to create a new get request with each streamer
Joseph
@revisualize
Jan 17 2017 05:09 UTC
@arkosingh How do you escape a newline in a string?
arkosingh
@arkosingh
Jan 17 2017 05:09 UTC
var myStr="FirstLine \"SecondLine\" \rThirdLine";
// Change this line
Coy Sanders
@coymeetsworld
Jan 17 2017 05:09 UTC
you should just append to the page you have using jQuery, that would be my suggestion
Manuel Rauda
@Gameruler1
Jan 17 2017 05:10 UTC
does anyone know how to solve "Using Objects for Lookups"?
Joseph
@revisualize
Jan 17 2017 05:10 UTC
@Gameruler1 I do.
@arkosingh Why are you escaping quotes?
arkosingh
@arkosingh
Jan 17 2017 05:10 UTC
how to do?
Manuel Rauda
@Gameruler1
Jan 17 2017 05:10 UTC
@revisualize can you please help me
arkosingh
@arkosingh
Jan 17 2017 05:11 UTC
"-(
Joseph
@revisualize
Jan 17 2017 05:11 UTC
@Gameruler1 Can you please post your code? Instead of just asking for help?
@arkosingh FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Manuel Rauda
@Gameruler1
Jan 17 2017 05:11 UTC

// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
val = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
"": undefined
};

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

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

Joseph
@revisualize
Jan 17 2017 05:11 UTC
@arkosingh Replace the words with the escape characters.
@Gameruler1 Your object should NOT be overwriting the val parameter
@Gameruler1 It tells you what your object should be called in the instructions.
@arkosingh How do you escape a newline?
@arkosingh How do you escape a backslash?
@arkosingh How do you escape a carriage-return?
Ammy3165
@Ammy3165
Jan 17 2017 05:14 UTC

hi, I am stuck here, Pls look into,
function chunkArrayInGroups(arr, size) {
// Break it up.

var newArray= [];

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

newArray.push(arr.slice(0,size));
arr= arr.slice(size);

}
return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Joseph
@revisualize
Jan 17 2017 05:14 UTC
@Ammy3165 Did you use pythontutor.com like I suggested?
@Ammy3165 Because I think you should be adding size to your i as you iterate across your array (arr).
Justin
@tanpaopao
Jan 17 2017 05:15 UTC
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
 for (var i=0; i < arr.length; i++) {
    for (var j=0; j< arr[i].length; j++) { 
    product = product * arr[i][j]*arr[i++][j++];
}
}  
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
product = product arr[i][j]arr[i++][j++] is this sentence wrong?
Ammy3165
@Ammy3165
Jan 17 2017 05:16 UTC
@revisualize I haven't learn to code in python yet.
Joseph
@revisualize
Jan 17 2017 05:16 UTC
@Ammy3165 www.pythontutor.com/javascript.html has NOTHING to do with python.
@tanpaopao remove *arr[i++][j++];
Justin
@tanpaopao
Jan 17 2017 05:17 UTC
As I understanding, arr[i][j] is only a element of an array.
Brian
@BrianCodes33
Jan 17 2017 05:17 UTC
someone mind helping me w/ a codewars challenge?
M.Sohaib
@coolcoder007
Jan 17 2017 05:17 UTC
anybody knows how to pass this challenge
Justin
@tanpaopao
Jan 17 2017 05:17 UTC
@revisualize Could you explain it? Thank you again.
CamperBot
@camperbot
Jan 17 2017 05:17 UTC
tanpaopao sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3001 | @revisualize |http://www.freecodecamp.com/revisualize
M.Sohaib
@coolcoder007
Jan 17 2017 05:17 UTC
Convert Celsius to Fahrenheit
Brian
@BrianCodes33
Jan 17 2017 05:17 UTC
@coolcoder007 yes what do you need
M.Sohaib
@coolcoder007
Jan 17 2017 05:18 UTC
i need a code
Joseph
@revisualize
Jan 17 2017 05:18 UTC
@coolcoder007 You do need code.
Brian
@BrianCodes33
Jan 17 2017 05:18 UTC
do you have any code you can provide?
Joseph
@revisualize
Jan 17 2017 05:18 UTC
What is your code? Have you done anything?
Brian
@BrianCodes33
Jan 17 2017 05:18 UTC
lol @revisualize
M.Sohaib
@coolcoder007
Jan 17 2017 05:18 UTC

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
farenheit=(celsius *(9/5))+32;

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

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

Joseph
@revisualize
Jan 17 2017 05:18 UTC
@coolcoder007 farenheit is misspelled.
fahrenheit
Solved.
NEXT!
Ezra
@EzraPlato
Jan 17 2017 05:19 UTC
Can someone help me with 152 ... This is where I am:

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var myNoun = "dog";

var myStr = "Hello my name is" + myNoun + "i am a" + wordBlanks[wordBlanks.length -3] + "that" + wordBlanks[wordBlanks.length -2] + "very" + wordBlanks[wordBlanks.length -1] + "HOWS THAT?";
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Justin
@tanpaopao
Jan 17 2017 05:19 UTC
@revisualize you are excellent, thank you so much.
CamperBot
@camperbot
Jan 17 2017 05:19 UTC
tanpaopao sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: tanpaopao already gave revisualize points
Liz Chen
@moist17
Jan 17 2017 05:20 UTC

@coymeetsworld thanks! but sorry i don't quite understand...you mean this part

    if (data.stream === null) {
      showName = channelName;
      showOnline = 'Offline';
      showLogo = 'http://s.jtvnw.net/jtv_user_pictures/hosted_images/GlitchIcon_PurpleonWhite.png';
      showUrl = 'https://www.twitch.tv/'+channelName+'';
    } else if (data.stream === undefined) {
        showName = 'Accnount Closed';
      showOnline = 'Account Closed'
      showLogo = 'http://s.jtvnw.net/jtv_user_pictures/hosted_images/GlitchIcon_PurpleonWhite.png';
      showUrl = 'Account Closed';
    } else {
        showName = data.stream.channel.status;
      showOnline = 'Online';
      showLogo = data.stream.channel.logo;
      showUrl = data.stream.channel.url;
    }
    console.log(showName, showOnline, showLogo, showUrl);
    renderHTML();

should move out from request.onload function?

CamperBot
@camperbot
Jan 17 2017 05:20 UTC
moist17 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1834 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Joseph
@revisualize
Jan 17 2017 05:20 UTC
@EzraPlato Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks
and with four parameter of myNoun, myAdjective, myVerb and myAdverb`.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are variable-like objects that represent the values that get passed into your function from the function call (arguments). (You basically treat them like variables.)
M.Sohaib
@coolcoder007
Jan 17 2017 05:20 UTC
@revisualize still not working i think my logic is not right
Zerka1982
@Zerka1982
Jan 17 2017 05:20 UTC
Hello guys
Joseph
@revisualize
Jan 17 2017 05:20 UTC
@coolcoder007 show me.
Manuel Rauda
@Gameruler1
Jan 17 2017 05:20 UTC
thanks @revisualize i figured it out -
CamperBot
@camperbot
Jan 17 2017 05:20 UTC
gameruler1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3002 | @revisualize |http://www.freecodecamp.com/revisualize
Manuel Rauda
@Gameruler1
Jan 17 2017 05:21 UTC

// 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",
"": undefined
};
result = lookup[val];
// Only change code above this line
return result;
}

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

Coy Sanders
@coymeetsworld
Jan 17 2017 05:21 UTC
no @moist17 i meant the request object:
var url = 'https://wind-bow.gomix.me/twitch-api/streams/'+channelName+'';
var request = new XMLHttpRequest();
request.open('GET', url, true);

request.onload = function() {
Joseph
@revisualize
Jan 17 2017 05:21 UTC
@Gameruler1 Grats.
arkosingh
@arkosingh
Jan 17 2017 05:21 UTC
how to?
Ezra
@EzraPlato
Jan 17 2017 05:21 UTC
@revisualize thank you. I will try to figure it out with the hint. Thanks again.
CamperBot
@camperbot
Jan 17 2017 05:21 UTC
ezraplato sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3003 | @revisualize |http://www.freecodecamp.com/revisualize
arkosingh
@arkosingh
Jan 17 2017 05:21 UTC
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Joseph
@revisualize
Jan 17 2017 05:21 UTC
@arkosingh How do you escape a newline?
@arkosingh How do you escape a backslash?
@arkosingh How do you escape a carriage-return?
arkosingh
@arkosingh
Jan 17 2017 05:22 UTC
by using \ @revisualize
Chinmaya B
@sharang108
Jan 17 2017 05:22 UTC
@arkosingh I have same problem
M.Sohaib
@coolcoder007
Jan 17 2017 05:22 UTC
@revisualize i have done thank you
CamperBot
@camperbot
Jan 17 2017 05:22 UTC
coolcoder007 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3004 | @revisualize |http://www.freecodecamp.com/revisualize
arkosingh
@arkosingh
Jan 17 2017 05:22 UTC
:-) @sharang108
Joseph
@revisualize
Jan 17 2017 05:22 UTC
:|
arkosingh
@arkosingh
Jan 17 2017 05:23 UTC
@revisualize pls help me
struggling here
Joseph
@revisualize
Jan 17 2017 05:23 UTC
@arkosingh And you're not answering my questions.
@arkosingh I'm asking what are you drinking.
And you're replying with: "A liquid."
I'm sitting here like.. No shit man you don't drink solids.
Brian
@BrianCodes33
Jan 17 2017 05:24 UTC
function convertCF(num, scale){
  if (scale === "c") {
    return (num - 32) * 5 / 9;
  } else if (scale === "f") {
    return (num * 9/5) + 32
  } else if (scale === null || scale === '') {
    return (num - 32) * 5 / 9;
  } else {
    throw Error;
  }
}
can someone see why this function isn't passing?
Joseph
@revisualize
Jan 17 2017 05:24 UTC
@arkosingh How do you escape a newline?
@arkosingh How do you escape a backslash?
@arkosingh How do you escape a carriage-return?
@arkosingh 3 questions. ... 3 different answers.
arkosingh
@arkosingh
Jan 17 2017 05:24 UTC
by // for backslash
Joseph
@revisualize
Jan 17 2017 05:24 UTC
Incorrect.
arkosingh
@arkosingh
Jan 17 2017 05:24 UTC
@revisualize
Chinmaya B
@sharang108
Jan 17 2017 05:25 UTC
@arkosingh Is the '\n' printing as it is for you/
?
Joseph
@revisualize
Jan 17 2017 05:26 UTC
@sharang108 He hasn't used any of the correct escape sequences.
Ezra
@EzraPlato
Jan 17 2017 05:26 UTC
@revisualize Why does this not work

myNoun = wordBlanks[wordBlanks.length -4].

myStr = "Hello my name is" + myNoun + "i am a" + myAdjective + "that" + myVerb + "very" + myAdverb + "HOWS THAT?";

Joseph
@revisualize
Jan 17 2017 05:26 UTC
@EzraPlato Because this myNoun = wordBlanks[wordBlanks.length -4]. is nothing.
And you're overwriting myNoun with nothing.
@EzraPlato Also, you don't have spaces between your variables parameters.
@EzraPlato Peopledon'twritelikethis.
People write like this.
Chinmaya B
@sharang108
Jan 17 2017 05:27 UTC
@revisualize Okay But I I have used correct sequences and still I don't get the correct output, possibility of a bug?
Joseph
@revisualize
Jan 17 2017 05:27 UTC
@sharang108 Show me.
Chinmaya B
@sharang108
Jan 17 2017 05:27 UTC
pkay
@revisualize Input : var myStr ="FirstLine\r\SecondLine\r\ThirdLine"; // Change this line
Joseph
@revisualize
Jan 17 2017 05:29 UTC
@sharang108 You don't have the correct sequence.
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
@sharang108 You're escaping a carriage-return where you should be escaping a newline.
@sharang108 You're escaping a carriage-return before backslash after SecondLine.
Ezra
@EzraPlato
Jan 17 2017 05:30 UTC
@revisualize I don't understand where I don't have spaces
O NOW I DO
Joseph
@revisualize
Jan 17 2017 05:30 UTC
"Hello my name isdogI am a
Chinmaya B
@sharang108
Jan 17 2017 05:30 UTC

@revisualize output: var myStr ="FirstLine\r\SecondLine\r\ThirdLine"; // Change this line

@revisualize Okay thanks that works! :D

CamperBot
@camperbot
Jan 17 2017 05:30 UTC
sharang108 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3005 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jan 17 2017 05:30 UTC
@sharang108 That isn't correct either.
Ezra
@EzraPlato
Jan 17 2017 05:31 UTC
@revisualize is anything right
Ayush Bahuguna
@relentless-coder
Jan 17 2017 05:31 UTC
previously, by using getElementsByTagName i'd get a node list, but after I've replaced the content on my file with a handlebars template the same getElements is giving me a HTMLcollection. Is this something that happens or am I just connecting two separate instances?
Joseph
@revisualize
Jan 17 2017 05:31 UTC
You have to assign 'FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine' to the variable myStr.
But, you have to replace the words with the proper escape sequences.
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
FirstLine\nbackslashSecondLinebackslashcarriage-returnThirdLine
FirstLine\n\\SecondLinebackslashcarriage-returnThirdLine
FirstLine\n\\SecondLine\\carriage-returnThirdLine
FirstLine\n\\SecondLine\\\rThirdLine
And you assign that to myStr as a string.
dsillydude
@dsillydude
Jan 17 2017 05:31 UTC

whats wrong with my code?
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var p = 0; p < arr.length; p++) {

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

}
 arr = product * arr[i];
  }

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Joseph
@revisualize
Jan 17 2017 05:31 UTC
You need to learn how to use escape sequences in JS.
Chinmaya B
@sharang108
Jan 17 2017 05:32 UTC
@revisualize The problem was with the incorrect mapping of escaping newline etc, thanks again
CamperBot
@camperbot
Jan 17 2017 05:32 UTC
sharang108 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: sharang108 already gave revisualize points
Joseph
@revisualize
Jan 17 2017 05:32 UTC
@dsillydude You're not accessing the child array elements.
dsillydude
@dsillydude
Jan 17 2017 05:32 UTC
@revisualize how ?
Joseph
@revisualize
Jan 17 2017 05:32 UTC
@dsillydude Why are you creating p but not using it?
@dsillydude
var nArr = [ ["b1" , "d1"] , ["f2" , "h2"] , ["j3" , "l3"] ];
what is: nArr[1];?
dsillydude
@dsillydude
Jan 17 2017 05:34 UTC
@revisualize oh should be the first array right
Joseph
@revisualize
Jan 17 2017 05:34 UTC
@dsillydude I am looking for an exact answer here. That is ambiguous.
dsillydude
@dsillydude
Jan 17 2017 05:34 UTC
nArr1 = [b1 , d1]
Joseph
@revisualize
Jan 17 2017 05:35 UTC
Incorrect.
dsillydude
@dsillydude
Jan 17 2017 05:35 UTC
oh wait
[f2 ,h2] that was zero lol
Bigyan Karki
@bigyankarki
Jan 17 2017 05:35 UTC

function getIndexToIns(arr, num) {
  arr = arr.sort();
  for (var i = 0; i< arr.length; i++){
    if (arr[i] >= num) {
      return i;
    }
    else if (arr[i] == num) {
      return i;
  }


}
}

getIndexToIns([2, 5, 10], 15);
Joseph
@revisualize
Jan 17 2017 05:35 UTC
@dsillydude How do you access: "j3" ?
Ammy3165
@Ammy3165
Jan 17 2017 05:35 UTC

@revisualize pls see what's the problem now,
function chunkArrayInGroups(arr, size) {
// Break it up.

var newArray= [];

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

newArray.push(arr.slice(0,size));
arr= arr.slice(size);

}
return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Bigyan Karki
@bigyankarki
Jan 17 2017 05:36 UTC
can anyone help me in this where do i belong challenge?

function getIndexToIns(arr, num) {
  arr = arr.sort();
  for (var i = 0; i< arr.length; i++){
    if (arr[i] >= num) {
      return i;
    }
    else if (arr[i] == num) {
      return i;
  }


}
}

getIndexToIns([2, 5, 10], 15);
dsillydude
@dsillydude
Jan 17 2017 05:36 UTC
@revisualize by using this code [2]
Hassaan Hafeez
@HassHz
Jan 17 2017 05:36 UTC
@bigyankarki arr.sort() will not sort the array numerically
Bigyan Karki
@bigyankarki
Jan 17 2017 05:37 UTC
how will sort then?
Joseph
@revisualize
Jan 17 2017 05:37 UTC
@dsillydude I'm sorry. That isn't an answer I can work with.
@bigyankarki The answer is on the help page for .sort()
dsillydude
@dsillydude
Jan 17 2017 05:37 UTC
@revisualize this one nArr2;
Joseph
@revisualize
Jan 17 2017 05:38 UTC
@dsillydude Incorrect.
@dsillydude What is nArr[2] ?
Ayush Bahuguna
@relentless-coder
Jan 17 2017 05:38 UTC
getElementsByTagName is returning an html collection. isn't it supposed to return a node list? I was getting a node list, but when I replace content on my file with handlebars template i've been getting an htmlCollection
dsillydude
@dsillydude
Jan 17 2017 05:38 UTC
@revisualize thats actually doesnt exist
Joseph
@revisualize
Jan 17 2017 05:38 UTC

@dsillydude Yes it does.

@dsillydude
var nArr = [ ["b1" , "d1"] , ["f2" , "h2"] , ["j3" , "l3"] ];

Ammy3165
@Ammy3165
Jan 17 2017 05:39 UTC

pls see what's the problem now,
function chunkArrayInGroups(arr, size) {
// Break it up.

var newArray= [];

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

newArray.push(arr.slice(0,size));
arr= arr.slice(size);

}
return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Joseph
@revisualize
Jan 17 2017 05:39 UTC
@Ammy3165 I'm looking.
Richard
@richafig
Jan 17 2017 05:39 UTC
Can anyone help with Stand in Line? It says arr.push is not a function.
dsillydude
@dsillydude
Jan 17 2017 05:40 UTC
@revisualize how i thought i only got one array and many sub array or am i forgetting sumn here..
Manish Giri
@Manish-Giri
Jan 17 2017 05:40 UTC
@richafig your code?
Joseph
@revisualize
Jan 17 2017 05:40 UTC
@dsillydude You haven't answered my question yet.
Richard
@richafig
Jan 17 2017 05:40 UTC

function nextInLine(arr, item) {
arr.push(item);
arr.unshift();// Your code here

return arr[0]; // Change this line
}

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

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

Joseph
@revisualize
Jan 17 2017 05:41 UTC
@dsillydude I'm trying to help you but, I don't know where your knowledge is lacking.
@richafig How do you remove the first element from an array?
Manish Giri
@Manish-Giri
Jan 17 2017 05:41 UTC
@richafig arr.unshift()?
Richard
@richafig
Jan 17 2017 05:41 UTC
.unshift, right?
Joseph
@revisualize
Jan 17 2017 05:41 UTC
@richafig Incorrect.
dsillydude
@dsillydude
Jan 17 2017 05:41 UTC
@revisualize i see im trying to put things together lemme answer your qn now
Joseph
@revisualize
Jan 17 2017 05:42 UTC
@dsillydude I'm trying to help you put things together.
@dsillydude But, I need exact answers from you to help.
Zerka1982
@Zerka1982
Jan 17 2017 05:42 UTC
Guys , anybody did exercise 217 ?
Manish Giri
@Manish-Giri
Jan 17 2017 05:42 UTC
@richafig .unshift() is like .push(), to the front.
Joseph
@revisualize
Jan 17 2017 05:42 UTC
@Zerka1982 Lessons don't have numbers. What is the name of the lesson?
Zerka1982
@Zerka1982
Jan 17 2017 05:42 UTC
Testing Objects for Properties
Richard
@richafig
Jan 17 2017 05:42 UTC
@Manish-Giri So, I'm actually adding a number, right?
Joseph
@revisualize
Jan 17 2017 05:43 UTC

@dsillydude
var nArr = [ ["b1" , "d1"] , ["f2" , "h2"] , ["j3" , "l3"] ];

How do you access "j3"?

Manish Giri
@Manish-Giri
Jan 17 2017 05:43 UTC
@richafig yes, that's what you're doing. But that's not what you're supposed to do.
but the syntax is wrong, anyway.
Richard
@richafig
Jan 17 2017 05:43 UTC
Oh, ok. @Manish-Giri Thanks for the hint. I guess I have to try something else.
CamperBot
@camperbot
Jan 17 2017 05:43 UTC
richafig sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3831 | @manish-giri |http://www.freecodecamp.com/manish-giri
grantknaver
@grantknaver
Jan 17 2017 05:43 UTC
Ok I know what this means addTogether(2,3)
What does this mean though addTogether(2)(3)?
Richard
@richafig
Jan 17 2017 05:43 UTC
@Manish-Giri How, or what, is wrong?
Joseph
@revisualize
Jan 17 2017 05:44 UTC
@grantknaver Currying.
@richafig
Joseph
@revisualize
Jan 17 2017 05:44 UTC

How do you add a number (item) to the end of an array (arr)? What does this method return?
How do you remove the first element from an array (arr)? What does this method return?

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The shift() method removes the first element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

Ayush Bahuguna
@relentless-coder
Jan 17 2017 05:44 UTC
I am trying to convert a htmlCollection into an array, but I am receiving an empty array. @Manish-Giri
dsillydude
@dsillydude
Jan 17 2017 05:44 UTC
@revisualize okay by going with the nArr = [1]
Zerka1982
@Zerka1982
Jan 17 2017 05:45 UTC
try this nArr[2,0]
grantknaver
@grantknaver
Jan 17 2017 05:45 UTC
@revisualize thanks I am reading about it now
CamperBot
@camperbot
Jan 17 2017 05:45 UTC
grantknaver sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3006 | @revisualize |http://www.freecodecamp.com/revisualize
dsillydude
@dsillydude
Jan 17 2017 05:45 UTC
@revisualize i think i forgot array challenges
Mark
@raghuvir
Jan 17 2017 05:45 UTC
Hello wise js gurus - ive written addTogether so that when addTogether(2)(3); is invoked, it will return a function which should then take 3 as an argument, which i think is the point of the assignment. But get an error: addTogether... is not a function. addTogether(2,3) works fine, but the other is also a requisite scenario.
Zerka1982
@Zerka1982
Jan 17 2017 05:45 UTC
guys any help with with Testing Objects for Properties
Joseph
@revisualize
Jan 17 2017 05:45 UTC
@Zerka1982 That's incorrect.
@Zerka1982 What does your code look like?
@Ammy3165 I'm looking I'm confused. I'm sorry. I can't help with that one.
Zerka1982
@Zerka1982
Jan 17 2017 05:46 UTC

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

function checkObj(checkProp) {
// Your Code Here

myObj.hasOwnProperty(chechProp);
}

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

Joseph
@revisualize
Jan 17 2017 05:46 UTC
@Zerka1982 Okay.
Ammy3165
@Ammy3165
Jan 17 2017 05:47 UTC
@revisualize I am waiting for your response
Ayush Bahuguna
@relentless-coder
Jan 17 2017 05:47 UTC
@Manish-Giri yes I've looked into it, but i'm still receiving an empty array.
var elements = document.getElementsByTagName('li');
    console.log("before click");
    console.log(elements);
    pullData();
    var arr = [].slice.call(elements);
    console.log(arr);
@Manish-Giri
Joseph
@revisualize
Jan 17 2017 05:47 UTC
@Ammy3165 I'm looking on pythontutor. and I can't figure out why you're not pushing.
@Zerka1982 The hasOwnProperty() method returns a boolean indicating whether the object has the specified property.
@Ammy3165 OH!
@Ammy3165 TRY
@Ammy3165 i<=arr.length;
Bigyan Karki
@bigyankarki
Jan 17 2017 05:49 UTC

function getIndexToIns(arr, num) {
  arr = arr.sort(function (a, b) {
    return a-b;
  });
  for (var i = 0; i< arr.length; i++){
    if (arr[i] >= num) {
      return i;
    }
}
}

getIndexToIns([2, 5, 10], 15);
Manish Giri
@Manish-Giri
Jan 17 2017 05:50 UTC
@relentless-coder is elements being returned correctly?
Bigyan Karki
@bigyankarki
Jan 17 2017 05:50 UTC
can somoeone let me know how can i write the code if the num is grater than all the elements in the array?
Ayush Bahuguna
@relentless-coder
Jan 17 2017 05:51 UTC
@Manish-Giri yes, me send in a snapshot of it.
Ammy3165
@Ammy3165
Jan 17 2017 05:51 UTC
@bigyankarki what's the challenge name?
Ayush Bahuguna
@relentless-coder
Jan 17 2017 05:52 UTC
blob
@Manish-Giri
Bigyan Karki
@bigyankarki
Jan 17 2017 05:52 UTC
@Ammy3165 the challenge name is where do i Belong
Joseph
@revisualize
Jan 17 2017 05:53 UTC
@Ammy3165 That doesn't quite work.
@Ammy3165 Here are the notes that I wrote for that lesson:
need to create a new array.
need to .push elements to the new array.
need to slice elements off of the array as they are added to the new array
Ayush Bahuguna
@relentless-coder
Jan 17 2017 05:54 UTC
@Manish-Giri Just to let you know, I wasn't facing this issue before I replaced content on my html with a handlebars template. does it have something to do with that?
Joseph
@revisualize
Jan 17 2017 05:55 UTC
@Ammy3165 I know what your problem is!
Hassaan Hafeez
@HassHz
Jan 17 2017 05:56 UTC
@bigyankarki What if none of the arr[i]'s are greater than num? Maybe you should check if num is greater than arr[i] and use a variable to get the index instead of returning in the for loop
Ammy3165
@Ammy3165
Jan 17 2017 05:56 UTC
thanks for the reference for pythonTutor.com, ,@revisualize
CamperBot
@camperbot
Jan 17 2017 05:56 UTC
ammy3165 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3007 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jan 17 2017 05:56 UTC
@Ammy3165 Okay. I know what is going on.
@Ammy3165 Here's what you're doing.
M.Sohaib
@coolcoder007
Jan 17 2017 05:56 UTC
var myStr = "FirstLine \n Second line \r Third Line"; // Change this line
need help
Joseph
@revisualize
Jan 17 2017 05:57 UTC
@coolcoder007 You're not escaping any of the backslashes.
@coolcoder007 Second line is not the same as SecondLine
@coolcoder007 Third Line is not the same as ThirdLine
M.Sohaib
@coolcoder007
Jan 17 2017 05:57 UTC
where to put \ backslash
Joseph
@revisualize
Jan 17 2017 05:58 UTC
@coolcoder007 'FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine'
Manish Giri
@Manish-Giri
Jan 17 2017 05:58 UTC
@relentless-coder might be, I've not worked much with Handlebar to say for sure..
Tiffany
@tiffanymakes
Jan 17 2017 05:59 UTC
Hi, I am having two issues with my Wikipedia viewer. 1) The search results aren't being added to the page 2) I can't run a 2nd search query after the 1st. I was wondering if anyone help me figure out what is wrong with my logic, and point me in the right direction? http://codepen.io/tiffanymakes/pen/egzmdP
Joseph
@revisualize
Jan 17 2017 06:01 UTC
@Ammy3165 Sorry, I'm distracted. I'm getting work emails at 10pm.
@Ammy3165 You're iterating across your array. But, you're constantly making your array smaller.
Ammy3165
@Ammy3165
Jan 17 2017 06:02 UTC
thanks for your response @revisualize
CamperBot
@camperbot
Jan 17 2017 06:02 UTC
ammy3165 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: ammy3165 already gave revisualize points
Joseph
@revisualize
Jan 17 2017 06:03 UTC
@Ammy3165 Sorry. For my distractions. I'm trying to help people and looking at all of my work emails. You shouldn't be overwriting arr
Coy Sanders
@coymeetsworld
Jan 17 2017 06:04 UTC
@tiffanymakes if you use a submit button and a form, you're going to need to prevent the default behavior of those which is to send a request out
Manish Giri
@Manish-Giri
Jan 17 2017 06:04 UTC
@tiffanymakes you sure action="query" is the best way to go?
Tiffany
@tiffanymakes
Jan 17 2017 06:06 UTC
@coymeetsworld so maybe I should use an input button instead of a submit button?
Joseph
@revisualize
Jan 17 2017 06:07 UTC
@Ammy3165 I SOLVED IT USING YOUR CODE!
Manish Giri
@Manish-Giri
Jan 17 2017 06:07 UTC

@tiffanymakes you can still use form-submit if you fix this

prevent the default behavior

Joseph
@revisualize
Jan 17 2017 06:07 UTC
@Ammy3165 I had to delete a bunch of stuff.
but, I solved it.
LOL!
Coy Sanders
@coymeetsworld
Jan 17 2017 06:07 UTC
you could @tiffanymakes, or just prevent default behavior. It would probably be simpler to just omit the form and submit button though and just use a regular button
Zerka1982
@Zerka1982
Jan 17 2017 06:07 UTC
guys need ur help with exercise 216 (Javascript)
Coy Sanders
@coymeetsworld
Jan 17 2017 06:07 UTC
you then would give that button an onclick handler in jQuery to get the search text and put it into your API call
Ammy3165
@Ammy3165
Jan 17 2017 06:08 UTC
@revisualize where is the fix ?
Coy Sanders
@coymeetsworld
Jan 17 2017 06:08 UTC
and then use jQuery to modify the page locally
Joseph
@revisualize
Jan 17 2017 06:08 UTC
@Ammy3165 So, first off you need to stop overwriting arr as your i variable counts up.
@Ammy3165 Then you need to use i and size in your .slice()
Tiffany
@tiffanymakes
Jan 17 2017 06:10 UTC
@Manish-Giri I'm not sure, the other method I tried was action="opensearch", but it gave me an array that was hard to do a for loop with.
Joseph
@revisualize
Jan 17 2017 06:10 UTC
@Ammy3165 That isn't exactly the answer but, damn it is really close.
Tiffany
@tiffanymakes
Jan 17 2017 06:10 UTC
@coymeetsworld by a regular button, do you mean type="button"?
Coy Sanders
@coymeetsworld
Jan 17 2017 06:11 UTC
yes
Joseph
@revisualize
Jan 17 2017 06:11 UTC
@Ammy3165 I could give you the exact answer but.. I kind of don't want to.... :P ?
@Ammy3165 I would if you really want me to.
M.Sohaib
@coolcoder007
Jan 17 2017 06:11 UTC
@revisualize var myStr="FirstLine\r\SecondLine\\rThirdLine";
Ammy3165
@Ammy3165
Jan 17 2017 06:11 UTC
@revisualize I am really frustated?
M.Sohaib
@coolcoder007
Jan 17 2017 06:11 UTC
still not working
Manish Giri
@Manish-Giri
Jan 17 2017 06:12 UTC
@tiffanymakes it's quite easy, you just need to loop through the array, pick the item from the current index from each of the arrays, and combine the three things (title, text and link) to form the result..
Joseph
@revisualize
Jan 17 2017 06:12 UTC
@coolcoder007 You went from escaping a newline before SecondLine to now escaping a carriage-return where you should be escaping a newline.
@Ammy3165 newArray.push(arr.slice(i,i+size));
@coolcoder007 You have to assign 'FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine' to the variable myStr.
But, you have to replace the words with the proper escape sequences.
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
FirstLine\nbackslashSecondLinebackslashcarriage-returnThirdLine
FirstLine\n\\SecondLinebackslashcarriage-returnThirdLine
FirstLine\n\\SecondLine\\carriage-returnThirdLine
FirstLine\n\\SecondLine\\\rThirdLine
And you assign that to myStr as a string.
Tiffany
@tiffanymakes
Jan 17 2017 06:15 UTC
@coymeetsworld thank you, the search results are now showing. I didn't realize it was because of the "submit". I need to read up on how button submit works.
CamperBot
@camperbot
Jan 17 2017 06:15 UTC
tiffanymakes sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1837 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jan 17 2017 06:16 UTC
nice @tiffanymakes yeah look it up for HTML not JavaScript
M.Sohaib
@coolcoder007
Jan 17 2017 06:17 UTC
@revisualize problem fixed again thanks
CamperBot
@camperbot
Jan 17 2017 06:17 UTC
coolcoder007 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: coolcoder007 already gave revisualize points
Brian
@BrianCodes33
Jan 17 2017 06:17 UTC
hey someone mind helping me w/ a problem on code wars
Ammy3165
@Ammy3165
Jan 17 2017 06:17 UTC
newArray.push(arr.slice(i,i+size));                                           I did this too @revisualize  But didn't worked.
Joseph
@revisualize
Jan 17 2017 06:17 UTC
@coolcoder007 Do you understand why you do that?
@Ammy3165 Show me.
Ammy3165
@Ammy3165
Jan 17 2017 06:18 UTC

function chunkArrayInGroups(arr, size) {
// Break it up.

var newArray= [];

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

newArray.push(arr.slice(i,i+size));
arr= arr.slice(size);

}
return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Joseph
@revisualize
Jan 17 2017 06:18 UTC
@Ammy3165 You're still overwriting arr.
@Ammy3165 You can't overwrite array.
@Ammy3165 You can't make arr get smaller as you grow i
M.Sohaib
@coolcoder007
Jan 17 2017 06:18 UTC
@revisualize yes i figured it out :+1:
Ammy3165
@Ammy3165
Jan 17 2017 06:18 UTC
okk that's good
Joseph
@revisualize
Jan 17 2017 06:18 UTC
@Ammy3165 <= should be <
Ammy3165
@Ammy3165
Jan 17 2017 06:19 UTC
@revisualize finally lots off of thanks
CamperBot
@camperbot
Jan 17 2017 06:19 UTC
ammy3165 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: ammy3165 already gave revisualize points
Joseph
@revisualize
Jan 17 2017 06:19 UTC
@Ammy3165 You should really look that over to understand it. It's quite confusing.
@BrianCodes33 I could try. I don't know how well I'd do.
@BrianCodes33 Should I get a shot of Captain before I travel down this rabbit hole?
Manish Giri
@Manish-Giri
Jan 17 2017 06:22 UTC
@tiffanymakes yes that link
Ammy3165
@Ammy3165
Jan 17 2017 06:22 UTC

okk I was doing one more iteration, but now I have this one, still confusing;function chunkArrayInGroups(arr, size) {
// Break it up.

var newArray= [];

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

newArray.push(arr.slice(i,i+size));
arr= arr.slice(size);

}
return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Manish Giri
@Manish-Giri
Jan 17 2017 06:22 UTC
Screenshot from 2017-01-17 01-22-03.png
@tiffanymakes
Brian
@BrianCodes33
Jan 17 2017 06:22 UTC
Create a function called convertCF() that accepts 2 arguments, an integer of the temperature, and a string of length 1 ("c" or "f") denoting which scale the integer should be converted to (Celsius and Fahrenheit, respectively). The function should return a number, which is the conversion from one scale to the other.
function convertCF(num, scale){
  if (scale === "c") {
    return (num - 32) * 5 / 9;
  } else if (scale === "f") {
    return (num * 9/5) + 32
  }  else if (scale !== "c" && scale !== "f"){
    throw Error;
  }  else {
    return (num - 32) * 5 / 9;
  }
}
Devin Dixon
@devlikesramen
Jan 17 2017 06:23 UTC
can someone tell me why the first part of this code isn't executing correctly?
if (val > 5) {
result = "Bigger than 5";
} else {
result = "5 or Smaller";
// Only change code above this line
return result;
}
Brian
@BrianCodes33
Jan 17 2017 06:23 UTC
@devlikesramen close your else block
with a closing bracket
Joseph
@revisualize
Jan 17 2017 06:23 UTC
@BrianCodes33 Can you show me a function call?
Brian
@BrianCodes33
Jan 17 2017 06:24 UTC
convertCF(32, "c")
Manish Giri
@Manish-Giri
Jan 17 2017 06:24 UTC
@BrianCodes33 you need to check if scale(the second) argument was passed in, as I was saying.
Devin Dixon
@devlikesramen
Jan 17 2017 06:24 UTC
it is closed
Brian
@BrianCodes33
Jan 17 2017 06:24 UTC
@Manish-Giri c
Joseph
@revisualize
Jan 17 2017 06:24 UTC
@BrianCodes33 Okay so, those are in order.
@devlikesramen No it isn't.
Manish Giri
@Manish-Giri
Jan 17 2017 06:24 UTC
and then rearrange your conditions accordingly.
Devin Dixon
@devlikesramen
Jan 17 2017 06:25 UTC
i didn't paste my closing bracket but its there and still not working
Joseph
@revisualize
Jan 17 2017 06:25 UTC
@BrianCodes33 Let's see.
Brian
@BrianCodes33
Jan 17 2017 06:25 UTC
so the way i do that is to check if scale is null?
Zerka1982
@Zerka1982
Jan 17 2017 06:26 UTC
Guys please tell me why "Not Found" does not return

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

function checkObj(checkProp) {
// Your Code Here

if (myObj.hasOwnProperty("checkProp")); {
return myObj[checkProp]; }
return "Not Found" ; }
// Test your code by modifying these values
checkObj("gift");

Manish Giri
@Manish-Giri
Jan 17 2017 06:26 UTC
@BrianCodes33 I think you can use the arguments object
make an array out of it, check if the length is 1.
Joseph
@revisualize
Jan 17 2017 06:26 UTC
@Zerka1982 "checkProp" this is a string. Not a variable.
Brian
@BrianCodes33
Jan 17 2017 06:26 UTC
@devlikesramen did you set your variable result so it knows to check what result is
Zerka1982
@Zerka1982
Jan 17 2017 06:27 UTC
@revisualize hmmmm
Tiffany
@tiffanymakes
Jan 17 2017 06:27 UTC
@Manish-Giri sorry, I'm still experimenting; I can't seem to get it to work. Thank you for checking up on me!
CamperBot
@camperbot
Jan 17 2017 06:27 UTC
tiffanymakes sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3832 | @manish-giri |http://www.freecodecamp.com/manish-giri
Sam MacHose
@Mac33d
Jan 17 2017 06:27 UTC
I'm having trouble with the "escape sequences in strings" exercise.
Joseph
@revisualize
Jan 17 2017 06:27 UTC
@Mac33d What does your string look like?
Sam MacHose
@Mac33d
Jan 17 2017 06:27 UTC
var myStr ="FirstLine\n\SecondLine\r\ThirdLine";
no matter where i put my \ it doesent show up
backslash i mean
Devin Dixon
@devlikesramen
Jan 17 2017 06:27 UTC
@BrianCodes33 i just had to move my return statement outside of the if/else statement, thanks!
Joseph
@revisualize
Jan 17 2017 06:27 UTC
@Mac33d Because you aren't escaping a backslash correctly.
CamperBot
@camperbot
Jan 17 2017 06:27 UTC
devlikesramen sends brownie points to @briancodes33 :sparkles: :thumbsup: :sparkles:
:cookie: 29 | @briancodes33 |http://www.freecodecamp.com/briancodes33
Joseph
@revisualize
Jan 17 2017 06:28 UTC
@Mac33d How do you escape a backslash?
Sam MacHose
@Mac33d
Jan 17 2017 06:28 UTC
just two \
Joseph
@revisualize
Jan 17 2017 06:28 UTC
@Mac33d Yes.
Sam MacHose
@Mac33d
Jan 17 2017 06:28 UTC
it doesent show up when i enter it tho
Joseph
@revisualize
Jan 17 2017 06:28 UTC
@Mac33d Fix your order:
SecondLinebackslashcarriage-return
@Mac33d You're escaping a carriage-return before the backslash.
@Mac33d Show me.
Sam MacHose
@Mac33d
Jan 17 2017 06:29 UTC
ok
Brian
@BrianCodes33
Jan 17 2017 06:29 UTC
@Manish-Giri seems like your way is complete different than mine
Manish Giri
@Manish-Giri
Jan 17 2017 06:30 UTC
@tiffanymakes sure thing, holler if you need help with that approach
CamperBot
@camperbot
Jan 17 2017 06:30 UTC
holler back!
Sam MacHose
@Mac33d
Jan 17 2017 06:30 UTC
var myStr ="FirstLine\n\\SecondLine\r\ThirdLine";
Joseph
@revisualize
Jan 17 2017 06:30 UTC
@Mac33d You're escaping a carriage-return before the backslash.
@Mac33d Fix your order:
SecondLinebackslashcarriage-return
Brian
@BrianCodes33
Jan 17 2017 06:30 UTC
@Manish-Giri yes i do
Joseph
@revisualize
Jan 17 2017 06:30 UTC
@Mac33d You're not escaping the backslash before SecondLine correctly. Why do you have \\\?
Flying_Fish
@FlyingFish195
Jan 17 2017 06:32 UTC
<p>how can I do this??</p>
Sam MacHose
@Mac33d
Jan 17 2017 06:32 UTC
It said to enter backslash "\" newline "\n" and carriage return "\r"
Joseph
@revisualize
Jan 17 2017 06:32 UTC
@Mac33d No.
@Mac33d You have to assign 'FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine' to the variable myStr.
But, you have to replace the words with the proper escape sequences.
Sam MacHose
@Mac33d
Jan 17 2017 06:33 UTC
oh
Garo
@Garabed96
Jan 17 2017 06:33 UTC
how long does the basic algorith scripting take? just curious how long it took whoever finished it
Joseph
@revisualize
Jan 17 2017 06:33 UTC
@Mac33d FirstLine then newline then backslash then SecondLine then backslash then carriage-return then ThirdLine
Without all of the thens nor spaces
Brian
@BrianCodes33
Jan 17 2017 06:33 UTC
@Manish-Giri did you fix it?
Sam MacHose
@Mac33d
Jan 17 2017 06:33 UTC
ill try that out
Manish Giri
@Manish-Giri
Jan 17 2017 06:33 UTC
@BrianCodes33 no I'm showing you what the problem is
you call convertCF(50) and you wrongly get the error
Joseph
@revisualize
Jan 17 2017 06:35 UTC
@BrianCodes33 I'm pretty sure I want to solve the challenge. LOL
Brian
@BrianCodes33
Jan 17 2017 06:35 UTC
hah @revisualize
Manish Giri
@Manish-Giri
Jan 17 2017 06:36 UTC
@BrianCodes33 here's how I fixed it - https://jsbin.com/baporewego/edit?js,console
Brian
@BrianCodes33
Jan 17 2017 06:36 UTC
ah i see
ok
Manish Giri
@Manish-Giri
Jan 17 2017 06:37 UTC
though I'd probably keep that as the very last case
Brian
@BrianCodes33
Jan 17 2017 06:37 UTC
i was so close
Manish Giri
@Manish-Giri
Jan 17 2017 06:37 UTC
yep
Rahul
@s0ulr3ap3r
Jan 17 2017 06:37 UTC
finally got the title case question right
Brian
@BrianCodes33
Jan 17 2017 06:39 UTC
function convertCF(num, scale = "c") {
  if (scale === "c") return (num - 32) / 9 * 5
  if (scale === "f") return num / 5 * 9 + 32
  throw new Error()
}
that looks cleaner
i like those default args in es6
Joseph
@revisualize
Jan 17 2017 06:39 UTC
@BrianCodes33
function convertCF(degree, scale) {
  if (scale == "f") {
    return degree * 9/5 + 32;
  }
  if (scale == "c") {
    return (degree - 32) * 5/9;
  }
  return undefined; 
}
it's from here
undefinedisn't an option, probably.
Sam MacHose
@Mac33d
Jan 17 2017 06:40 UTC
var myStr ="FirstLine\n\SecondLine\rThirdLine";
still not working
Manish Giri
@Manish-Giri
Jan 17 2017 06:40 UTC
@BrianCodes33 yeah default args is pretty neat, I used it in my Simon game
Hanqi Liu
@LicheeLiu
Jan 17 2017 06:41 UTC
What's wrong with this lookup table?

// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
val={
"alpha":result="Adams" ,
"bravo":result="Boston",
"charlie":result="Chicago",
"delta":result="Denver",
"echo":result="Easy",
"foxtrot":result="Frank"
};

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

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

Joseph
@revisualize
Jan 17 2017 06:42 UTC
@LicheeLiu Lots of things.
@LicheeLiu Your overwriting the parameter val with an object.
@LicheeLiu The object should be named lookup as per the instructions.
@LicheeLiu Objects are key value pairs.
@BrianCodes33 Passed: 43 Failed: 1 Errors: 1
@LicheeLiu Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
HEY! I got it!
Manish Giri
@Manish-Giri
Jan 17 2017 06:44 UTC
Time: 467ms Passed: 45 Failed: 0
Joseph
@revisualize
Jan 17 2017 06:44 UTC
@Manish-Giri @BrianCodes33 :muscle:
Time: 311ms Passed: 45 Failed: 0
Manish Giri
@Manish-Giri
Jan 17 2017 06:44 UTC
You have passed all tests! :)
lol
Hanqi Liu
@LicheeLiu
Jan 17 2017 06:45 UTC
@revisualize thanks!Letme try
CamperBot
@camperbot
Jan 17 2017 06:45 UTC
licheeliu sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3008 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jan 17 2017 06:46 UTC
I don't like that code.
Let's make it better!
Sam MacHose
@Mac33d
Jan 17 2017 06:46 UTC
var myStr ="FirstLine\n\SecondLine\rThirdLine";
I went word by word and this is what i got
Manish Giri
@Manish-Giri
Jan 17 2017 06:51 UTC
Time: 323ms Passed: 45 Failed: 0
Hanqi Liu
@LicheeLiu
Jan 17 2017 06:51 UTC

@revisualize still don't know what should I do with the "result"?

var lookup={
"alpha":"Adams" ,
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

Manish Giri
@Manish-Giri
Jan 17 2017 06:51 UTC
function convertCF(num, scale="c"){
//code here
  if (scale === "c") {
    return (num - 32) * 5 / 9;
  } else if (scale === "f") {
    return (num * 9/5) + 32
  }  else {
    //console.log("ERROR");
    throw Error;
  } 

}
Hanqi Liu
@LicheeLiu
Jan 17 2017 06:51 UTC
How to return "result"?
Manish Giri
@Manish-Giri
Jan 17 2017 06:51 UTC
@revisualize oh hey, gz on reaching 3K!
:tada:
Joseph
@revisualize
Jan 17 2017 06:52 UTC

@Mac33d If you went word by word and got this:

var myStr ="FirstLine\n\SecondLine\rThirdLine";

You didn't go word by word.

@LicheeLiu Your return statement is already written.
Manuel Rauda
@Gameruler1
Jan 17 2017 06:53 UTC
@LicheeLiu make it so that it equals the info in the table that you have named lookup
Joseph
@revisualize
Jan 17 2017 06:53 UTC
@Mac33d
FirstLine
newline
backslash
SecondLine
backslash
carriage-return
ThirdLine
@LicheeLiu You should assign result to be the value from your lookup object.
@Mac33d You're still not escaping backslashes correctly.
Manuel Rauda
@Gameruler1
Jan 17 2017 06:55 UTC

@LicheeLiu heres my completed 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",
"": undefined
};
result = lookup[val];
// Only change code above this line
return result;
}

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

Joseph
@revisualize
Jan 17 2017 06:55 UTC
@Mac33d
You have to assign 'FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine' to the variable myStr.
But, you have to replace the words with the proper escape sequences.
How do you escape a newline?
How do you escape a backslash?
How do you escape a carriage-return?
@Gameruler1 Giving people answers doesn't help them learn.
@Gameruler1 Studies have shown that giving people answers to problems instills an illusionary sense of learning. Because, it only puts information into short-term memory. Of which people think they are learning. Only through a little struggle and repetition that the human brain puts things into long-term memory. I don't know what your end goal. I don't know if you want to do this as a personal project, hobby, or if you want to move into industry. Because of this, I strongly feel that working with people to allow them to solve problems on their own is a far better outcome than giving away answers. But, others clearly don't agree with my methods for helping people learn.
John Nunns
@johnnunns
Jan 17 2017 06:57 UTC
Write a function called "transformEmployeeData" that transforms some employee data from one format to another.

The argument will look something like this:
[
    [
        ['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
    ],
    [
        ['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
    ]
]

Given that input, the return value should look like this:
[
    {firstName: 'Joe', lastName: 'Blow', age: 42, role: 'clerk'},
    {firstName: 'Mary', lastName: 'Jenkins', age: 36, role: 'manager'}
]

Note that the input may have a different number of rows or different keys than the given sample. 

For example, let's say the HR department adds a "tshirtSize" field to each employee record. Your code should flexibly accommodate that.

Starter Code :
function transformEmployeeData(array) {
  // your code here
}
anyone feel confident they could help me solve this one?
Joseph
@revisualize
Jan 17 2017 06:57 UTC
Look at the time!
John Nunns
@johnnunns
Jan 17 2017 06:57 UTC
so far my code is :
function transformEmployeeData(array){
    var x = {}
    for(var i =0; i<data.length; i++){
        x[i]=data[i];
        console.log(x)
    }
}

transformEmployeeData(data)
when I run it it's nothing close though
Never learned how to transform an array into an object so I'm a little irritated it's even asking me
Manish Giri
@Manish-Giri
Jan 17 2017 07:00 UTC
@johnnunns for(var i =0; i<data.length; i++)
what is data?
John Nunns
@johnnunns
Jan 17 2017 07:01 UTC
sorry, above my code I've declared data as the information above
[
[
['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
],
[
['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
]
]
Sam MacHose
@Mac33d
Jan 17 2017 07:02 UTC
@joseph Jesus. I need to read more carefully. Ty!
CamperBot
@camperbot
Jan 17 2017 07:02 UTC
mac33d sends brownie points to @joseph :sparkles: :thumbsup: :sparkles:
:cookie: 40 | @joseph |http://www.freecodecamp.com/joseph
John Nunns
@johnnunns
Jan 17 2017 07:02 UTC
I've come close to solving it using the reduce method, but as far as I know it's not wanting me to use reduce
Manuel Rauda
@Gameruler1
Jan 17 2017 07:03 UTC
@revisualize I'm showing her what i did because sometimes the wording of the explanation can be, as well as the fact that some people are more visual learns than they are reading an explanation which i think is a reason why each problem comes with an example to show the learner more or less what the end result should look like. Thats why I chose to tell her how its done and than give her my solution at it so she may see exactly what I was trying to explain. Whether she chooses to copy it and not learn it is up to her. Personally if I find a solution to a problem (whether handed to me or by researching it) I like to reverse engineer it and figure out how the end goal was achieved and how it all connects.
Muzaffar Hussain
@Muzaffarhssn5
Jan 17 2017 07:05 UTC

Hi.... I am not able to understand why this code does not push the input values 2,3 and 6,7 into the 2D array. Here's the code below:

function chunkArrayInGroups(arr, size) {
var arrGrouped = [];
for (var i = 0; i < arr.length; i+=2) {
arrGrouped.push(arr.slice(i,i+=size));
}
return arrGrouped;
}
chunkArrayInGroups([0,1,2,3,4,5,6,7,8], 2);

Markus Kiili
@Masd925
Jan 17 2017 07:07 UTC
@Muzaffarhssn5 I get incrementing i+=size but why i+=2 ?
Flying_Fish
@FlyingFish195
Jan 17 2017 07:09 UTC
、、、
Muhammad Hasham
@MohammadHasham
Jan 17 2017 07:10 UTC
can anyone tell me what does the 'strict' button has to do in simon says game?
Flying_Fish
@FlyingFish195
Jan 17 2017 07:10 UTC
、、、
var c=9;
、、、
Muzaffar Hussain
@Muzaffarhssn5
Jan 17 2017 07:11 UTC
@Masd925 @Vizij Thanks Bro.... Got it.....
CamperBot
@camperbot
Jan 17 2017 07:11 UTC
muzaffarhssn5 sends brownie points to @masd925 and @vizij :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @vizij |http://www.freecodecamp.com/vizij
Markus Kiili
@Masd925
Jan 17 2017 07:11 UTC
@Muzaffarhssn5 You should increment by i+=size in the for loop definition and use arguments (i,i+size) on the slice.
CamperBot
@camperbot
Jan 17 2017 07:11 UTC
:star2: 3175 | @masd925 |http://www.freecodecamp.com/masd925
Manish Giri
@Manish-Giri
Jan 17 2017 07:12 UTC
@johnnunns I'm done with the code for your challenge, I think
Muzaffar Hussain
@Muzaffarhssn5
Jan 17 2017 07:12 UTC
@Masd925 Yep... Got it....
Flying_Fish
@FlyingFish195
Jan 17 2017 07:12 UTC
var count=0;
'''
CamperBot
@camperbot
Jan 17 2017 07:12 UTC
:bulb: to format code use backticks! ``` more info
Flying_Fish
@FlyingFish195
Jan 17 2017 07:13 UTC
var count=0;
Carlo Felicione
@LowCountry
Jan 17 2017 07:14 UTC
How are people getting a conditional to detect a value of NaN? I've tried using the isNaN() method but it doesnt seem to work?
Kaier5
@Kaier5
Jan 17 2017 07:14 UTC
Hello all. how to code in"stand in line"? thanks!
Mayank Sharma
@mayank1101
Jan 17 2017 07:15 UTC
Can any one help me with task 216
Manish Giri
@Manish-Giri
Jan 17 2017 07:15 UTC
@LowCountry Number.isNaN()?
Mayank Sharma
@mayank1101
Jan 17 2017 07:15 UTC
Iteration over array of objects
Flying_Fish
@FlyingFish195
Jan 17 2017 07:15 UTC
Counting Cards
How to do this??Can someone teach me ,please
Manish Giri
@Manish-Giri
Jan 17 2017 07:16 UTC
@FlyingFish195 did you understand the instructions?
João Mhurilo Godoi da Silva
@ebak123
Jan 17 2017 07:16 UTC

Why is not pushing? :@@

function whatIsInAName(collection, source) {
var arr = [],b;

for (var i=0;i<collection.lenght;i++){
if(collection[i].last===source.last){
arr.push(collection[i]);
}
}

return arr;
}

whatIsInAName(
[{ first: "Romeo", last: "Montague" },
{ first: "Mercutio", last: null },
{ first: "Tybalt", last: "Capulet" }],

{ last: "Capulet" }

);

Mayank Sharma
@mayank1101
Jan 17 2017 07:17 UTC
Please help me with profile lookup task
Manish Giri
@Manish-Giri
Jan 17 2017 07:17 UTC
@mayank1101 your code?
Mayank Sharma
@mayank1101
Jan 17 2017 07:18 UTC
counting card solution @FlyingFish195

switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
break;
case 7:
case 8:
case 9:
count += 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
break;
}

if(count > 0){
return count + " Bet";
}
else if(count <= 0){
return count + " Hold";
}

Joseph
@revisualize
Jan 17 2017 07:18 UTC
Teaching someone isn't the same as giving them the answer.
Manish Giri
@Manish-Giri
Jan 17 2017 07:18 UTC
@mayank1101 pls, no direct answers.
Mayank Sharma
@mayank1101
Jan 17 2017 07:19 UTC