These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Feb 2016
Greg D
@mosaic-greg
Feb 24 2016 00:01
guess i could use a variable to keep track of things while the for loops complete
Dan Basinski
@d488b
Feb 24 2016 00:01
Anyone able to help with "Counting Cards"? All but one of my sequences come back as they should
haigashod
@haigashod
Feb 24 2016 00:04
Hey guys!
Anyone solve Caesars Cipher?
Ken Haduch
@khaduch
Feb 24 2016 00:04
@d488b - want to post your code, or a link to your code?
haigashod
@haigashod
Feb 24 2016 00:04
I'm so close.. Need some help with .fromCharCode()
Dan Basinski
@d488b
Feb 24 2016 00:04
if(card == "A" || card =="K" || card == "Q" || card == "J" || card == "10"){
count--;
return count + " Hold"
} else if (card == "2" || card =="3" || card == "4" || card == "5" || card == "6"){
count++;
return count + " Bet"
} else {
count;
return count + " Hold"
}
Ken Haduch
@khaduch
Feb 24 2016 00:05
@haigashod - yes, to Caesar's Cypher.
haigashod
@haigashod
Feb 24 2016 00:05
Here's the code:
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var arrTwo = [];
  var list;
  for(i = 0; i < str.length; i++) { 
    if(str.charCodeAt(i) == 32) {
      arr.push(str.charCodeAt(i));  
    } else {
      arr.push(str.charCodeAt(i)-13);  
    }
  }
  for(i = 0; i < arr.length; i++) {
    if(arr[i] < 65 && arr[i] !== 32) {
      arrTwo.push(arr[i] + 26);
    } else {
      arrTwo.push(arr[i]);
    }
  }
  list = arrTwo.join(", ");
  return String.fromCharCode(list);
 }
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Sebastian lhådö
@miniskurken
Feb 24 2016 00:05
@d488b are you not supposed to use switch case? .)
```
haigashod
@haigashod
Feb 24 2016 00:05
List returns the char code values correctly.
But String.fromCharCode(list) is returning a largish red dot lol
Dan Basinski
@d488b
Feb 24 2016 00:06
ah that would explain it, thanks
Moisés Man
@moigithub
Feb 24 2016 00:06
This message was deleted
Ken Haduch
@khaduch
Feb 24 2016 00:06
@haigashod - what kind of returns are you getting from that code?
haigashod
@haigashod
Feb 24 2016 00:07
@khaduch I literally get a red dot.
@khaduch That's stranger because String.fromCharCode(65, 66, 67) returns ABC
Sebastian lhådö
@miniskurken
Feb 24 2016 00:07
@d488b
case 2:
case 3:
case 4: 
count  ++; 
... and so forth
haigashod
@haigashod
Feb 24 2016 00:08
@khaduch So; i thought if I pass in a similar list, it ought to work. I've read the mozilla instructions several times.. Can't see where I've gone wrong.
Ken Haduch
@khaduch
Feb 24 2016 00:08
@haigashod - you can pass multiple values to fromCharCode, but I don't think that you can just pass a string...

they give the syntax as:

String.fromCharCode(num1[, ...[, numN]])

So it has to be distinct separate numbers as the arguments.

Moisés Man
@moigithub
Feb 24 2016 00:10
@haigashod when u doing join u making a string.. fromCharCode requires numbers as input
@haigashod u could work with the array itself arrtwo using apply method
haigashod
@haigashod
Feb 24 2016 00:10
@moigithub I've tried passing in arrTwo; it still returns the same red dot.
Moisés Man
@moigithub
Feb 24 2016 00:10
String.fromCharCode.apply(null,[65,66,67])
if still returning other type of characters.. probably ur CODE isnt correct
haigashod
@haigashod
Feb 24 2016 00:12
Hey! That works =)
@moigithub
Moisés Man
@moigithub
Feb 24 2016 00:12
:)
haigashod
@haigashod
Feb 24 2016 00:12
But why? I haven't needed the apply() method before; I'll look into that now.
Except now I see I need to account for some exclamation marks.
Thanks @moigithub @khaduch
CamperBot
@camperbot
Feb 24 2016 00:13
haigashod sends brownie points to @moigithub and @khaduch :sparkles: :thumbsup: :sparkles:
:star: 661 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 572 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Feb 24 2016 00:15
@haigashod - you need to convert each character separately, so the 'apply' method is applying that to each element of the array. That's why it is working there. Hope you get that last bit cleaned up!
William
@apswak
Feb 24 2016 00:15
function unite(arr1, arr2, arr3) {
  var arr = arr1.concat(arr2, arr3);
  var stored = [];
  for(var i in arr){
    if(arr.indexOf(i) < 0){
      stored.push(arr[i]);
    }
  }
  return stored;
}

unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Anyone know why it's pushing all numbers into array and not checking to see if they're already in with indexOf?
Moisés Man
@moigithub
Feb 24 2016 00:17
for(var result = "", i=0; i< arrTwo.length; result+=String.fromCharCode(arrTwo[i]), i++);
or
var result = "";
for( i=0; i< arrTwo.length;  i++) 
     result+=String.fromCharCode(arrTwo[i]);
var result = arrTwo.map(function(code){return String.fromCharCode(code)}).join("");
Ken Haduch
@khaduch
Feb 24 2016 00:18
@kreitzo - you are concatenating everything together with that .concat method?
IrishAlex
@IrishAlex
Feb 24 2016 00:19
evening gents and gentettes
can somebody explain the "return early pattern for functions" Challenge to me a bit better? My code aint working at all

function abTest(a, b) {
// Only change code below this line

if ((a, b < 0)) {
return ;}

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(-2,2);

Ken Haduch
@khaduch
Feb 24 2016 00:20
@kreitzo - wait, I'm thinking... :)
William
@apswak
Feb 24 2016 00:20
@khaduch Yes but then i'm trying to filter the excess numbers
Moisés Man
@moigithub
Feb 24 2016 00:20
@kreitzo are u sure i have the value u thinking it have ??
IrishAlex
@IrishAlex
Feb 24 2016 00:21
its challenge 206
Moisés Man
@moigithub
Feb 24 2016 00:21
@kreitzo u can console.log() to find out n make sure it have the right value
also there are other methods to iterate on an array.. for..in its more for enumerables types... (where order doesnt matter)
William
@apswak
Feb 24 2016 00:21
ok
Ken Haduch
@khaduch
Feb 24 2016 00:23
@moigithub - yes, you are right about @kreitzo 's 'for (var i in arr)' that does bizarre things! I think that it's iterating through properties, if I remember correctly...
Norman Dela Cruz
@dcnr
Feb 24 2016 00:24
@Tze14 you only need to check if all the values of arr[1] is in arr[0] right? So you could only iterate over one of the words, you don't need nested loops. Since you're working with strings, you can even use indexOf to check.
@IrishAlex hi, you can't "shortcut" your conditional like (a, b < 0) it should be (a < 0 || b < 0)
IrishAlex
@IrishAlex
Feb 24 2016 00:27
@dcnr sound mate!, I had && prior to that and it wasn't working.
Norman Dela Cruz
@dcnr
Feb 24 2016 00:29
@IrishAlex && means AND so a AND b must be both true for the expression to be true. IIRC you only need either a or b to be less than 0?
IrishAlex
@IrishAlex
Feb 24 2016 00:30
it was a or b but I couldnt figure out how to put both of those parameters into the function lol. || worked perfectly in the end
Norman Dela Cruz
@dcnr
Feb 24 2016 00:31
@IrishAlex Logical Operators :D
Ken Haduch
@khaduch
Feb 24 2016 00:31

@kreitzo - I haven't used the for( var in ...) too often. but here is what it does in the javascript console, with a simple array as the argument (from running this in the FireBug console):

for (var i in [1,3,5,7,9]) {   console.log(i); } 
0
1
2
3
4
$family
$constructor
each
clone
clean
invoke
associate
link
contains
append
getLast
getRandom
include
combine
erase
empty
flatten
pick
hexToRgb
rgbToHex
extend
min
max
average
sum
unique
shuffle
pluck

It has the array 'index' values, and all of the methods... so it's certainly messing with your expected results!

Ken Haduch
@khaduch
Feb 24 2016 00:37

@kreitzo - well, that's really kind of misleading, that was in the FireBug console. In the Chrome console, it just shows this:

for (var i in [1,3,5,7,9]) {   console.log(i); } 

0
1
2
3
4
undefined

So basically the array index values, not the array contents... sorry about that previous misleading post!

swynt
@swynt
Feb 24 2016 00:38

hi guys, i need some feedback on slasher flick challenge, so my code is here

function slasher(arr, howMany) {
  // it doesn't always pay to be first
    var store1= [];

    if (howMany === 0){
        return arr;    
    } else {
        store1 = arr.splice(howMany, 2);
        return store1;
    }  
}

it works, but what should i replace '2' with? any idea?

Ken Haduch
@khaduch
Feb 24 2016 00:41
@swynt - those methods have options to just copy from the start point that you specify until the end of the array. So you want to find and use one of those methods.
swynt
@swynt
Feb 24 2016 00:43
ok thanks @khaduch
CamperBot
@camperbot
Feb 24 2016 00:43
swynt sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 573 | @khaduch | http://www.freecodecamp.com/khaduch
matthew3454
@matthew3454
Feb 24 2016 00:43
I'm on the Check for Palindromes exercise. I will give my first born child to anyone who can help me turn this pseudocode into code! Here it is:
nkfunction palindrome(str) {
  if (var re = new RegExp(""))
  str.replace();
    str.toLowerCase();
  // Good luck!{
  return true}
}



palindrome("eye");
function palindrome(str)
if (var re = new RegExp(""))
  str.replace();
    str.toLowerCase();{
  // Good luck!
  return true;
}



palindrome("eye");
Norman Dela Cruz
@dcnr
Feb 24 2016 00:46

@khaduch for...in is terrible on arrays because it can return the indexes in any order, also it works even on non-integer indexes.

var a = [];
a[1] = 0;
a[0] = 1;
a["hello"] = "world";

for (var i in a) {
  console.log(i);
}

Output:

0
1
hello
I think it's ok if you just want to get the values, but there are other better methods for that, like forEach
Ken Haduch
@khaduch
Feb 24 2016 00:48
@dcnr - yes, you're right. Thanks for the detail! I have only seen it used on a program to access the keys of an object (which could be an array, but it was using string keys) and the order is not important in the situation where I saw it being used. I just haven't gotten familiar enough with it to know it. (Or I just plain forgot by now! :))
CamperBot
@camperbot
Feb 24 2016 00:48
khaduch sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 699 | @dcnr | http://www.freecodecamp.com/dcnr
Ken Haduch
@khaduch
Feb 24 2016 00:48
@matthew3454 - is that the base code that they put in the challenge?
bitgrower
@bitgrower
Feb 24 2016 00:49
wait ... dang ... that looks like an associative array ...
Norman Dela Cruz
@dcnr
Feb 24 2016 00:49
thanks too, I actually don't use for..in coz there's for..of! @khaduch
CamperBot
@camperbot
Feb 24 2016 00:49
dcnr sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 574 | @khaduch | http://www.freecodecamp.com/khaduch
bitgrower
@bitgrower
Feb 24 2016 00:49
uh oh ... soon I won't be sharing the same hundredths with @dcnr
Norman Dela Cruz
@dcnr
Feb 24 2016 00:49
@bitgrower heya! disgusting string keys on my js arrays!
@bitgrower I'll let you do the honors, c'mon it's just one point :smiling_imp: :smiling_imp: :smiling_imp:
bitgrower @bitgrower likes assoc. array ....she thinks they are super-cool ... anyway ... she is taking a break from working ... she has to get back ...
bitgrower
@bitgrower
Feb 24 2016 00:50
thanks @dcnr ... for your exposing me to another corner of js
CamperBot
@camperbot
Feb 24 2016 00:50
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 700 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 24 2016 00:50
@bitgrower have fun!
bitgrower
@bitgrower
Feb 24 2016 00:50
there ya go ...
Norman Dela Cruz
@dcnr
Feb 24 2016 00:50
lol thanks @bitgrower xD
CamperBot
@camperbot
Feb 24 2016 00:50
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 615 | @bitgrower | http://www.freecodecamp.com/bitgrower
matthew3454
@matthew3454
Feb 24 2016 00:50
@khaduch No This is:
Ken Haduch
@khaduch
Feb 24 2016 00:51
@matthew3454 - basically, you want to take the string that they give you as the argument, and transform it to something that is lowercase, has all of the spaces, special characters, etc. stripped out. A regular expression is ideal for doing that stripping because it can match characters according to the expression. And I see that you are replying....
matthew3454
@matthew3454
Feb 24 2016 00:51

```function palindrome(str) {
// Good luck!
return true;
}

palindrome("eye");

function palindrome(str) {
  // Good luck!
  return true;
}



palindrome("eye");
Ken Haduch
@khaduch
Feb 24 2016 00:52
I see that you are using regexp in your skeleton code.? How familiar are you with that?
matthew3454
@matthew3454
Feb 24 2016 00:52
@khaduch I'm as clueless as a blind mechanic.
but I do know some brail
Norman Dela Cruz
@dcnr
Feb 24 2016 00:53
@matthew3454 try this http://regexone.com/ :D it's regex fun!
matthew3454
@matthew3454
Feb 24 2016 00:53
Oh boy!
Ken Haduch
@khaduch
Feb 24 2016 00:54
@matthew3454 - where did you get that code, then? It is useful in this situation... @dcnr's suggestion is good, but you need to know the basic theory (which I'm not sure they give you at that site? Maybe they do... have a look, come back with more questions! :) )
matthew3454
@matthew3454
Feb 24 2016 00:54
yes sir
Ken Haduch
@khaduch
Feb 24 2016 00:55
@matthew3454 - I haven't looked at that site, since I've dealt with regular expressions a lot in the past - looks like a great intro - thanks again, @dcnr!
CamperBot
@camperbot
Feb 24 2016 00:55
khaduch sends brownie points to @matthew3454 and @dcnr :sparkles: :thumbsup: :sparkles:
:warning: khaduch already gave dcnr points
:star: 248 | @matthew3454 | http://www.freecodecamp.com/matthew3454
Ken Haduch
@khaduch
Feb 24 2016 00:56
@matthew3454 - you will find it worthwhile to spend the time getting familiar with them, so that site looks like a great place to spend some time! Good luck!
matthew3454
@matthew3454
Feb 24 2016 01:03
@khaduch Okay I'll make an effort to denude a bit of my incompetence. Thanks
CamperBot
@camperbot
Feb 24 2016 01:03
matthew3454 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 575 | @khaduch | http://www.freecodecamp.com/khaduch
Norman Dela Cruz
@dcnr
Feb 24 2016 01:03
thanks! I think it's a good intro to regex @khaduch
CamperBot
@camperbot
Feb 24 2016 01:03
dcnr sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave khaduch points
Ken Haduch
@khaduch
Feb 24 2016 01:04
@dcnr @matthew3454 - and it is definitely a skill to develop for the future challenges... I bookmarked it in case I need to refer anyone to it!
mohannexus
@mohannexus
Feb 24 2016 01:10

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

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

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

can someone help me with this
it says multiplyAll[i] is undefined
bitgrower
@bitgrower
Feb 24 2016 01:12
well, multiplyAll isn't an array ... it's the name of a function ...
that thing between the parentheses -- that's what you need to be using ...
mohannexus
@mohannexus
Feb 24 2016 01:13
Good lord
i am an idiot
thanks anyway
bitgrower
@bitgrower
Feb 24 2016 01:13
not to worry, we all have "those" moments ...
looks like you're well on your way to solving it otherwise ... :)
mohannexus
@mohannexus
Feb 24 2016 01:14
thats very kind of you , thanks
bitgrower
@bitgrower
Feb 24 2016 01:14
all true ... :)
Matt Leonard
@matty22
Feb 24 2016 01:14

No one around to help in HelpFrontEnd at the moment. Perhaps someone here can assist.

I am working on Wikipedia Viewer and my API call is returning an object of objects. I need to know how to target each of the inner objects when I won't always know one step of the dot/bracket notation. For example: returnedObj.query.pages[13590]

The number bit at the end is unique to every page on wikipedia and I won't know what they are
as they will change based on the user's input
bitgrower
@bitgrower
Feb 24 2016 01:15
have you tried Object.keys ?
Matt Leonard
@matty22
Feb 24 2016 01:16
I have not.
bitgrower
@bitgrower
Feb 24 2016 01:16
look it up ... probably will do exactly what you'd like to do ... :) ... have you done the Exact Change js challenge ?
Matt Leonard
@matty22
Feb 24 2016 01:17
I've done all of the JS challenges unless something new has been added in the last week or so.
bitgrower
@bitgrower
Feb 24 2016 01:17
and you did exact change without using Object.keys ? LOL, I'll have to check out your solution ...
Matt Leonard
@matty22
Feb 24 2016 01:18
I don't even see a challenge called Exact Change?
bitgrower
@bitgrower
Feb 24 2016 01:19
well, it's there ... it's in the advanced js algos
has been there for a while ...
Matt Leonard
@matty22
Feb 24 2016 01:20
Oh no, I haven't done that. Thought you were talking about waypoints. Stupid new naming structure.
Object.keys() doesn't seem to do what I want. It just gives me the keys. I want everything inside of each of those objects \as well.
bitgrower
@bitgrower
Feb 24 2016 01:21
with the keys, you get the values ...
you have the keys, then you iterate thru them to get the values ... .
Matt Leonard
@matty22
Feb 24 2016 01:22
No, the key has another entire nested object inside of it.
I could set this equal to an array variable and iterate through it I guess. Lemme try that
bitgrower
@bitgrower
Feb 24 2016 01:22
so ... it should give you that information as well ... :) all objects are key:value pairs ... at least that's what I've been told ... :)
playing with the Exact Change algo may also help you, as well ... :)
...the other thing you could do is google something like "how to access values within nested objects" ... :)
I'm guessing wikipedia probably has SOME definition of the data that it send back, to give you a start ... :)
Matt Leonard
@matty22
Feb 24 2016 01:27
That actually worked. Thanks @bitgrower
CamperBot
@camperbot
Feb 24 2016 01:27
matty22 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 616 | @bitgrower | http://www.freecodecamp.com/bitgrower
golfguy1984
@golfguy1984
Feb 24 2016 01:33
what editor do you guys prefer to write your code?
bitgrower
@bitgrower
Feb 24 2016 01:34
yw, @matty22
David
@dgussio
Feb 24 2016 01:47
can someone help me with this profile lookup problem?
heres my code:
for (i=0; i<contacts.length; i++) {
if (contacts[i].firstName !== firstName) {
return "No such contact";
}
if (contacts[i].hasOwnProperty(prop) === false) {
return "No such property";
}
if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
}
Jeff Shultz
@Shultzjk
Feb 24 2016 01:47
So I am having trouble with the most basic 'convert celsius to farenheit' problem. I am setting my variable then adding in the equation but it is saying 'farenheit not defined'.
David
@dgussio
Feb 24 2016 01:47
only the last part is not working
where i need it to return the value of the property
Jeff Shultz
@Shultzjk
Feb 24 2016 01:49
Here's my two entire lines of code:var farenheit = 1.8 * celsius;
farenheit += 32;
Ken Haduch
@khaduch
Feb 24 2016 01:52
@Shultzjk - Hello there - do you have other code - like is this enclosed in a function or something?
Norman Dela Cruz
@dcnr
Feb 24 2016 01:52
@Shultzjk it's spelled fahrenheit :P
Jeff Shultz
@Shultzjk
Feb 24 2016 01:52
:(
Oh boy. It's going to be a long night.
Ken Haduch
@khaduch
Feb 24 2016 01:53
@Shultzjk - I was going to say the same. I just went to look at the challenge... they are probably testing for that exact variable name.
Jeff Shultz
@Shultzjk
Feb 24 2016 01:53
Thank you @khaduch @dcnr
CamperBot
@camperbot
Feb 24 2016 01:53
shultzjk sends brownie points to @khaduch and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 576 | @khaduch | http://www.freecodecamp.com/khaduch
:star: 701 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 24 2016 01:53
@Shultzjk would have worked if you changed the other fahrenheit variables to your own spelling though
Jeff Shultz
@Shultzjk
Feb 24 2016 01:54
May or may not have spent 20 minutes trying to re-work the formula... sheesh.
Ken Haduch
@khaduch
Feb 24 2016 01:54

@dcnr

@Shultzjk would have worked if you changed the other fahrenheit variables to your own spelling though

Unless they were looking for that exact spelling, since they asked for that in the instructions: "Create a variable fahrenheit"...

Norman Dela Cruz
@dcnr
Feb 24 2016 01:54

@dgussio
This is one of the problems

if (contacts[i].firstName !== firstName) {
return "No such contact";
}

If your firstName isn't the first one in the array, it will always return No such contact

@khaduch ah yeah it would have but they aren't really!

function convert(c) {
  // Only change code below this line
  var f = c * 1.8 + 32;

  // Only change code above this line
  if ( typeof f !== 'undefined' ) {
    return f;
  } else {
    return 'fahrenheit not defined';
  }
}

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

works just fine too :D

Ken Haduch
@khaduch
Feb 24 2016 01:59

@dcnr

@khaduch ah yeah it would have but they aren't really!
```js
function convert(c) {
// Only change code below this line
var f = c * 1.8 + 32;

// Only change code above this line
if ( typeof f !== 'undefined' ) {
return f;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);
```
works just fine too :D

OK - there are times when they are specifically looking for what they ask you to create by name... Like in the return "fahrenheit not defined", if they were looking for that, spelling would have been important, or if they were actually checking your code for variable names... anyway. good work all!

David
@dgussio
Feb 24 2016 02:01
@dcnr No, because "Bob, number" works fine - returns "no such property"
i even changed variable name to make sure.
Norman Dela Cruz
@dcnr
Feb 24 2016 02:11
@dgussio Bob works because there's no such contact as Bob!
@khaduch ah yeah there are those exercises that expect a specific string with the proper capitalization and stuff
Ken Haduch
@khaduch
Feb 24 2016 02:26
@dgussio - there are a few things to consider with this challenge
  • there is a finite number of elements in the array, you want to make sure to use them all if necessary (don't return too early)
  • as soon as you find an element that matches the name, you can have one of two things happen -
    • you find a property that exists and return that property value
    • you don't find a property that exists and return "no such property"
  • if you don't find anything that matches in the array (no names that match), you run out of contacts to search, you return "no such contact".
    I don't know where you are at with this - I haven't looked at your code. But a lot of people get stumped by the things that you have to look at and check for - I hope that help you?
Monty
@webdev8183
Feb 24 2016 02:30
json object notation, I am stuck on this not sure what I have wrong but its not passing all the tests.
Richard Corbett
@reacorbett
Feb 24 2016 02:33
how do you post a pic in the chat?
Craig Banach
@CraigBanach
Feb 24 2016 02:36
@reacorbett link it
Steve Frost
@ffrostt
Feb 24 2016 02:37
Can someone please explain what the a & b arguments represent in the lesson about sorting arrays?
var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort(function(a,b) {
  return a - b;
});
and how return a - b sorts that array from largest to smallest
Monty
@webdev8183
Feb 24 2016 02:38
''' var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
// Add record here
[{
"artist": "Prince",
"title": "Purple Rain",
"release_year": 1999,
"formats": [
"CS",
"8T",
"LP"],
"gold":true}
]];
I guess I haven't got to that one yet ffrostt so I dunno
CamperBot
@camperbot
Feb 24 2016 02:38
:bulb: to format code use backticks! ``` more info
Monty
@webdev8183
Feb 24 2016 02:38
thats like single quotes right?
Steve Frost
@ffrostt
Feb 24 2016 02:39
sorry I meant to use backticks because it was code
rphares
@rphares
Feb 24 2016 02:39
@webdev8183 , close but you want the albums to be in the same var myMusic
So, they should share the same set of []
you have the second one in its own set, just remove those guys...
Monty
@webdev8183
Feb 24 2016 02:41
ah makes sense..
Sam Reeves
@smreeves
Feb 24 2016 02:43
Hey folks! Working on the Smallest Common Multiple algorithm and it is stumping me. I started writing elaborate code consisting of several helper functions and still getting stuck trying to "complete" then realized that I'm probably over complicating it. Any tips on how to derive the solution for this? Any hints would be greatly appreciated!
Norman Dela Cruz
@dcnr
Feb 24 2016 02:44
@ffrostt this is the document about sort and here is the relevant part about the return value:
  • If compareFunction(a, b) is less than 0, sort a to a lower index than b, i.e. a comes first.
  • If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.
  • If compareFunction(a, b) is greater than 0, sort b to a lower index than a.
  • compareFunction(a, b) must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned then the sort order is undefined.
Steve Frost
@ffrostt
Feb 24 2016 02:45
Hey great, thanks @dcnr
CamperBot
@camperbot
Feb 24 2016 02:45
ffrostt sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 702 | @dcnr | http://www.freecodecamp.com/dcnr
n9exorcist
@n9exorcist
Feb 24 2016 02:45
I have a problem with "Filter arrays with filter" challenge

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

newArray = oldArray.filter(function(val) {
return val <= 5 ;
});

var newArray = oldArray;

I cldnt fullfill, "You should have filtered out all values from the array that are greater than 5"
Norman Dela Cruz
@dcnr
Feb 24 2016 02:45
@n9exorcist var newArray = oldArray; you're overwriting the filtered array with the old one
remove that line :D
Craig Banach
@CraigBanach
Feb 24 2016 02:46
@n9exorcist Why do you override newArray after tyou have done the calculation?
Norman Dela Cruz
@dcnr
Feb 24 2016 02:46
@cragsify It's preset there, I think it's meant for us to append .filter function but people just make their own set and forget that the preset line is there
n9exorcist
@n9exorcist
Feb 24 2016 02:46
@dcnr @cragsify I thought we are going to store the results in the newArray
Craig Banach
@CraigBanach
Feb 24 2016 02:47
@n9exorcist Yes, so why do you then override it oncew you have done the calculation?
Norman Dela Cruz
@dcnr
Feb 24 2016 02:48
@n9exorcist you were meant to add the .filter part at the var newArray = oldArray; part, but since you made your own, just remove var newArray = oldArray; line
n9exorcist
@n9exorcist
Feb 24 2016 02:48
@cragsify yes, I kinda made a mistake with that line.

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

newArray = oldArray.filter(function(val) {
return val <= 5 ;
});

var neArray = oldArray;

This worked fine..
Craig Banach
@CraigBanach
Feb 24 2016 02:49
@n9exorcist That's because you've spelled newArray wrong...
n9exorcist
@n9exorcist
Feb 24 2016 02:50
@cragsify yes, I did it intentionally. so there will be a new variable name where are results are stored
Norman Dela Cruz
@dcnr
Feb 24 2016 02:50

@n9exorcist you just need this

var newArray = oldArray.filter(function(val) {
return val <= 5 ;
});

so discard

var newArray = oldArray;
n9exorcist
@n9exorcist
Feb 24 2016 02:52
@dcnr @cragsify Thanks for your suggestions.
CamperBot
@camperbot
Feb 24 2016 02:52
n9exorcist sends brownie points to @dcnr and @cragsify :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cragsify
:star: 703 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 24 2016 02:52
you're welcome, thanks too @n9exorcist
CamperBot
@camperbot
Feb 24 2016 02:52
dcnr sends brownie points to @n9exorcist :sparkles: :thumbsup: :sparkles:
:star: 241 | @n9exorcist | http://www.freecodecamp.com/n9exorcist
Mafalda
@otmeek
Feb 24 2016 02:54
@dcnr did you temporarily change your image or did I hallucinate it?
Norman Dela Cruz
@dcnr
Feb 24 2016 02:55
@otmeek yeah I temporarily changed it to the Hiigara emblem :P
@otmeek the peach castella is where it's at though, so I changed it back
Gorgy
@Dwiz6
Feb 24 2016 02:56

hello campers how do i solve this:
function queue(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(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

the instruction is: Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed
Mafalda
@otmeek
Feb 24 2016 02:56
@dcnr that cake is castella? Now I want it
castella best cake
Norman Dela Cruz
@dcnr
Feb 24 2016 02:57

@Dwiz6
Hi you need to
1) Insert item to the end of arr
2) Remove the first item of arr
3) Return that removed item

You should look at the functions Array.prototype.push and Array.prototype.shift:D

@otmeek YES! :cake:
@Dwiz6 Here's for push and here's for shift
Gorgy
@Dwiz6
Feb 24 2016 02:59
Array.prototype.shift and .push, where prototype is ?
Raghuram
@Raghuram1994
Feb 24 2016 03:01
can anyone help me with word blanks
i am unable to understand whats dis programme is about
Norman Dela Cruz
@dcnr
Feb 24 2016 03:02
@Raghuram1994 you're supposed to use the variables/arguments to make up your own sentence for example:
"The " + myNoun + etc...
Sam Reeves
@smreeves
Feb 24 2016 03:07
Hey folks! Working on the Smallest Common Multiple algorithm and it is stumping me. I started writing elaborate code consisting of several helper functions and still getting stuck trying to "complete" then realized that I'm probably over complicating it. Any tips on how to derive the solution for this? Currently I've got it so all of my potential numbers are in an array from the lowest number in my range to the largest. Any HINTS would be greatly appreciated!
Norman Dela Cruz
@dcnr
Feb 24 2016 03:10
@sreeves89 I just did it like how I would the pen and paper way, using the GCD reduction way to get the LCM. I also used this Euclidean Algorithm pseudocode to get the GCD.
Sam Reeves
@smreeves
Feb 24 2016 03:11
Thanks @dcnr! I will look into it and see if I can't figure this stupid thing out. Don't know why this one is giving me fits when all the other challenges haven't been too bad..
CamperBot
@camperbot
Feb 24 2016 03:11
sreeves89 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
Raghuram
@Raghuram1994
Feb 24 2016 03:11
@dcnr Cleared it thankyou.
CamperBot
@camperbot
Feb 24 2016 03:11
:star: 704 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 24 2016 03:11
awesome! thanks too @Raghuram1994 :D
CamperBot
@camperbot
Feb 24 2016 03:11
dcnr sends brownie points to @raghuram1994 :sparkles: :thumbsup: :sparkles:
:star: 98 | @raghuram1994 | http://www.freecodecamp.com/raghuram1994
manicpromod
@manicpromod
Feb 24 2016 03:14

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

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

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

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

var Bike = function() {

// Only change code below this line.

var gear;

this.getGear= function(){

return gear;

};

this.setGear= function(gear){

this.gear=gear;

};

};

var myCar = new Car();

var myBike = new Bike();

any issue in my code?
bitgrower
@bitgrower
Feb 24 2016 03:15
does it pass ?
manicpromod
@manicpromod
Feb 24 2016 03:15
no
bitgrower
@bitgrower
Feb 24 2016 03:15
which test doesn't pass ?
manicpromod
@manicpromod
Feb 24 2016 03:16
myBike.getGear() should return 4 after calling myBike.setGear(4).
bitgrower
@bitgrower
Feb 24 2016 03:17
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // Only change code below this line.

  var gear;

  this.getGear= function(){

    return gear;
  };

  this.setGear= function(gear){

   this.gear=gear;


  };

};

var myCar = new Car();

var myBike = new Bike();
^^^manicpromod's code
well ... what is the difference in the two functions you've written ?
...that is, in how they are referencing the gear variable ?
I'm assuming all the tests after that one don't pass, right ?
manicpromod
@manicpromod
Feb 24 2016 03:19
one is get method which returns the gear variable other one is set which sets the variable
Norman Dela Cruz
@dcnr
Feb 24 2016 03:19
@manicpromod return this.gear; should be like this
manicpromod
@manicpromod
Feb 24 2016 03:20
oh thanks @dcnr
CamperBot
@camperbot
Feb 24 2016 03:20
manicpromod sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 705 | @dcnr | http://www.freecodecamp.com/dcnr
manicpromod
@manicpromod
Feb 24 2016 03:20
ok i should use this keyword to return the variable, thanks!
Norman Dela Cruz
@dcnr
Feb 24 2016 03:22
@manicpromod yeah you're referring to your object's gear not the function's gear
bitgrower
@bitgrower
Feb 24 2016 03:23
actually, if you change the variable coming into the function to something like newGear, and use newGear to set the new value ... it doesn't seem to matter if you use this.gear or just gear ... curiously enough ... but this.gear would be safer.
Norman Dela Cruz
@dcnr
Feb 24 2016 03:27
@bitgrower I was pretty sure that it should have worked without this
bitgrower
@bitgrower
Feb 24 2016 03:27
yeah, considering Car works that way ... :)
eeflores
@eeflores
Feb 24 2016 03:31
wiki smallest common multiple
CamperBot
@camperbot
Feb 24 2016 03:31

:point_right: algorithm smallest common multiple [wiki]

Explanation:

The smallest common multiple between two numbers is the smallest number that
both numbers can divide into. This concept can be extended to more than two
numbers as well.

We can first start with just finding the smallest common multiple between two
numbers. Naively, you can start writing out multiple of each number until you
write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The
first smallest number we run into in both lists is 12 so this is the smallest
common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common
multiple of just the two numbers but forget the keyword range. However, this
means that if you are given [1,5], then you have to check for the smallest
common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by
all of them.

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

bitgrower
@bitgrower
Feb 24 2016 03:31
@eeflores -- the key is finding the right formula for LCM ...
philipsiu
@philipsiu
Feb 24 2016 03:32
help seek and destroy
CamperBot
@camperbot
Feb 24 2016 03:32

:point_right: algorithm seek and destroy [wiki]

Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

bitgrower
@bitgrower
Feb 24 2016 03:32
...and NOT the one which requires iterating thru numbers which go up to the max number possible if you multiply all the numbers together ... or creating crazy huge arrays ...
@philthyfill -- can you post your code ... ? there's a misunderstanding a lot of folks have with this problem, and would like to see if that's what is tripping you up ...
help no repeats
CamperBot
@camperbot
Feb 24 2016 03:33

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

eeflores
@eeflores
Feb 24 2016 03:39
@bitgrower would you have any links/references to how prime numbers are related to the smallest common multiple problem? I've brute forced the solution, but I'm trying to understand how primes come into play
Gorgy
@Dwiz6
Feb 24 2016 03:41

function queue(arr, item) {
// Your code here
arr = ([1,2,3,4,5], 6);
arr.push(6);
return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
N.B:
Am still having problem solving the above problem, the error message given is "arr.push()" is not a function. what do i do?

Nick Robson
@nickrobson
Feb 24 2016 03:44

@Dwiz6 This is not valid JavaScript for appending to an array:

arr = ([1,2,3,4,5], 6);

Thus your arr.push() call is on an invalid object.

philipsiu
@philipsiu
Feb 24 2016 03:45
@bitgrower Here's my code.
function destroyer(arr) {
    var args = Array.prototype.slice.call(arguments);
    args.splice(0, 1);
    return args.filter(function(value) {
        return args.indexOf(value === -1);
    });

}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Norman Dela Cruz
@dcnr
Feb 24 2016 03:48
@philthyfill you should be filtering arr :P
@philthyfill or args[0] if you didn't splice it
Gorgy
@Dwiz6
Feb 24 2016 03:49
thanks @nickrobson so how do i solve the problem, then move on?
CamperBot
@camperbot
Feb 24 2016 03:49
dwiz6 sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 396 | @nickrobson | http://www.freecodecamp.com/nickrobson
Nick Robson
@nickrobson
Feb 24 2016 03:50
@Dwiz6 First of all, you want to be adding item to the end of the array. Then you want to remove and return the first element of the array.
Have a look at Array#push and Array#shift if you don't understand what is asked of you.
philipsiu
@philipsiu
Feb 24 2016 03:51
Here's what I did before.
function destroyer(arr) {
    var args = Array.prototype.slice.call(arguments[0]);
    var newArr = [];
    for (var i = 0; i < args.length; i++) {
      if (arguments[1] !== args[i] && arguments[2] !== args[i] && arguments[3] !== args[i]) {
        newArr.push(args[i]);
      }
    }
  return newArr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
bitgrower
@bitgrower
Feb 24 2016 03:54
ah, sorry @eeflores ... stepped away for a bit ...
eeflores
@eeflores
Feb 24 2016 03:56
@bitgrower I found the link to the wiki entry for that challenge which also links to a wikipedia entry so I'll read up more into that
bitgrower
@bitgrower
Feb 24 2016 03:56
I just searched around the web until I found something which made sense to me ... BUT basically, the LCM is going to be, at the very minimum, all the primes multiplied together ... that's the SMALLEST possible value in any range ... but it may not be sufficient ... so then you have to find the maximum number of each prime number used, and multiply that in ...
Norman Dela Cruz
@dcnr
Feb 24 2016 03:56

@philthyfill
Your code:

function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  args.splice(0, 1);
  return args.filter(function (value) {
    return args.indexOf(value === -1);
  });
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Is very close, you should be filtering arr instead of args and you should double check your callback return expression.

bitgrower
@bitgrower
Feb 24 2016 03:56
I didn't recall the wikipedia page being very helpful ...
eeflores
@eeflores
Feb 24 2016 03:57
@bitgrower what was your search term?
bitgrower
@bitgrower
Feb 24 2016 03:57
eek ... I don't recall ... sorry ... I mean, "least common multiple" is the actual term, not smallest common multiple ...
eeflores
@eeflores
Feb 24 2016 03:58
cool excellent thanks @bitgrower
CamperBot
@camperbot
Feb 24 2016 03:58
eeflores sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 617 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 24 2016 03:58
but -- what I found is what I described above ...
@philthyfill -- you basically need to have 2 arrays ... the array to delete from, and the array of values to delete...
I used method #2 ...
bitgrower
@bitgrower
Feb 24 2016 04:04
@philthyfill -- what's cool about splice is you can use it to get both of the arrays in one statement!
eeflores
@eeflores
Feb 24 2016 04:04
cool thanks again @bitgrower
CamperBot
@camperbot
Feb 24 2016 04:04
eeflores sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: eeflores already gave bitgrower points
philipsiu
@philipsiu
Feb 24 2016 04:04
Thanks @dcnr @bitgrower
CamperBot
@camperbot
Feb 24 2016 04:04
philthyfill sends brownie points to @dcnr and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 706 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 618 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 24 2016 04:06
yw
Norman Dela Cruz
@dcnr
Feb 24 2016 04:06
@bitgrower what factoring algo did you use? or did you make your own?
you're welcome, thanks too @philthyfill
bitgrower
@bitgrower
Feb 24 2016 04:09
@dncr -- I had a handy isPrime function from a previous challenge, so I zipped thru the range to find all the primes ... stuck 'em in an array as I found them ...
...then after doing that, I looked at the non prime numbers and used my array of primes to build another array -- which was the # of instances a particular prime was used ...
Norman Dela Cruz
@dcnr
Feb 24 2016 04:10
hmmm interesting @bitgrower
bitgrower
@bitgrower
Feb 24 2016 04:10
so index k for both arrays represented the same prime ... in one case the prime number itself, and in the other the # of times it was used ...
Norman Dela Cruz
@dcnr
Feb 24 2016 04:11
@bitgrower yeah I'm looking at your solution now
bitgrower
@bitgrower
Feb 24 2016 04:11
I would keep a temporary number when examining a number in the range, and then checked to see if it was more than my count array, and replaced it if so ...
Norman Dela Cruz
@dcnr
Feb 24 2016 04:12
gonna profile it
bitgrower
@bitgrower
Feb 24 2016 04:12
:)
it's what made sense to me ... I dunno if it's the fastest ... but I'm sure it beats creating an array of numbers.length = range numbers multiplied
...which, to me, is very unpleasing ... seems like brute-forcing, where it's not necessary ...
Monty
@webdev8183
Feb 24 2016 04:15
totally lost on Profile Lookup, any suggestions
bitgrower
@bitgrower
Feb 24 2016 04:16
@webdev8183 -- post your code, please ...
eeflores
@eeflores
Feb 24 2016 04:17
@webdev8183 you can use a function hasOwnProperty()
Norman Dela Cruz
@dcnr
Feb 24 2016 04:17
@bitgrower
I have an old C2D 2.6Ghz and it's pretty fast.
This is 3 runs of smallestCommon([1,13]) at 10,000,000 iterations each:
run 1: 18532.176ms
run 2: 19544.702ms
run 3: 19001.062ms
bitgrower
@bitgrower
Feb 24 2016 04:17
what's the takeaway, @dcnr ?
Norman Dela Cruz
@dcnr
Feb 24 2016 04:21
@bitgrower a million iteration of my solution took 14371.657ms, that's just a million, yours took roughly 19s on average for 10 million
Karma Tsering
@ktseringchem
Feb 24 2016 04:21
@bitgrower how did you display your code?
Norman Dela Cruz
@dcnr
Feb 24 2016 04:22
that's awesome, thanks @bitgrower
CamperBot
@camperbot
Feb 24 2016 04:22
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 619 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 24 2016 04:24
explain format
CamperBot
@camperbot
Feb 24 2016 04:24

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

bitgrower
@bitgrower
Feb 24 2016 04:25
yw, @dcnr ...
@ktseringchem -- did you see ?
Karma Tsering
@ktseringchem
Feb 24 2016 04:26
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 lookUp(firstName, prop){
// Only change code below this line
  var i = 0;
  while(i < 4){
    if(firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
      return contacts[i][prop];
    }else if(firstName !== contacts[i].firstName){
      return "No such contact";
    }else {
      return "No such property";
    }
    i++;
  }
Mafalda
@otmeek
Feb 24 2016 04:26
This sync programming they introduce in the back end lessons really throws me for a loop @_@
Karma Tsering
@ktseringchem
Feb 24 2016 04:27
yup thanks @bitgrower
CamperBot
@camperbot
Feb 24 2016 04:27
ktseringchem sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 620 | @bitgrower | http://www.freecodecamp.com/bitgrower
Karma Tsering
@ktseringchem
Feb 24 2016 04:31
when I test lookUp("Kristian", "lastName"); the result is "no such contact" can some one tell me what's wrong with it?
V Arun Kumar
@arunvkumr
Feb 24 2016 04:35
@ktseringchem move no such contact out of loop.
Norman Dela Cruz
@dcnr
Feb 24 2016 04:35
@ktseringchem it's because of else if(firstName !== contacts[i].firstName) it will always start at the Akira object, and since Kristrian !== Akira your else if clause will enter and return No such contact
bitgrower
@bitgrower
Feb 24 2016 04:37
and, I suspect if @dcnr and I had to guess ... this is the #1 issue people have with Profile Lookup ... at least among those who come looking for help ...
Norman Dela Cruz
@dcnr
Feb 24 2016 04:37
@bitgrower it's become the new seek and destroy
bitgrower
@bitgrower
Feb 24 2016 04:38
yeah, I'm impressed ... people don't seem to be having as much trouble with the arguments object on that one...
help seek and destroy
CamperBot
@camperbot
Feb 24 2016 04:39
no wiki entry for: seek and destroy
bitgrower
@bitgrower
Feb 24 2016 04:39
bah!
Karma Tsering
@ktseringchem
Feb 24 2016 04:39
thanks @dcnr
CamperBot
@camperbot
Feb 24 2016 04:39
ktseringchem sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 707 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 24 2016 04:39
anyway .. when someone pulled up the wiki page I noticed it said something about arguments object ...
Norman Dela Cruz
@dcnr
Feb 24 2016 04:40
bf seek and destroy
CamperBot
@camperbot
Feb 24 2016 04:40

:fire:Bonfire: Seek and Destroy :link:

function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

Norman Dela Cruz
@dcnr
Feb 24 2016 04:40
keyword still lives!
you're welcome, thanks too @ktseringchem
CamperBot
@camperbot
Feb 24 2016 04:40
dcnr sends brownie points to @ktseringchem :sparkles: :thumbsup: :sparkles:
:star: 225 | @ktseringchem | http://www.freecodecamp.com/ktseringchem
bitgrower
@bitgrower
Feb 24 2016 04:41
yay!!!! Not sure what the other camper pulled up, but I recall seeing arguments object mentioned ...
@ktseringchem ... unfortunately, this kind of coding environment encourages people to code first before thinking a bit about the problem ... with something like Profile Lookup -- it helps to plan out what you want to do, and then also take each piece of the problem and solve it separately from the others ...
Norman Dela Cruz
@dcnr
Feb 24 2016 04:43
@ktseringchem at the very least, you should manually trace your own code. Read the flow and see how it goes.
bitgrower
@bitgrower
Feb 24 2016 04:44
yup ... that was really good advice, @dcnr -- just walking a few steps into the code provides the answer ...
...or, rather, illustrates the problem ...
NainaPS
@Navyya
Feb 24 2016 04:45
Heya guys
bitgrower
@bitgrower
Feb 24 2016 04:45
definitely think more folks are getting involved with the front end projects since they switched things around ....
NainaPS
@Navyya
Feb 24 2016 04:45
I need help for Mutation
bitgrower
@bitgrower
Feb 24 2016 04:45
@Hey girlfriend ... :)
bitgrower @bitgrower says, mischieviously
bitgrower
@bitgrower
Feb 24 2016 04:46
so ... let's see whatcha got, @Navyya
NainaPS
@Navyya
Feb 24 2016 04:46

function mutation(arr) {
var FirstArr=arr[0].toLowerCase();
var SecondArr=arr[1].toLowerCase();
// var splitedArr=arr.split();
for(i=0; i<FirstArr.length;i++){
if(SecondArr.indexof(FirstArr[i]<0)){
return false;
}
else {return true;}
}

//return arr;
}

mutation(["hello", "hey"]

i dont know why is it not getting formatted
plssssssssssss help
Norman Dela Cruz
@dcnr
Feb 24 2016 04:47

@Navyya
you can format your code by doing
```js

<paste code here>
```

Those are 3 backquotes, the key above tab, left of 1, and below esc.
You can create a new line by shift+enter so to format it'll be:
```js (shift+enter)(paste code)(shift+enter) ```

@Navyya remove the else clause it'll probably work :P
bitgrower
@bitgrower
Feb 24 2016 04:48
also ... you are using an unknown function indexof ... it's indexOf
NainaPS
@Navyya
Feb 24 2016 04:49
SecondArr.indexof is not a function
:(
bitgrower
@bitgrower
Feb 24 2016 04:49
yep -- it should be SecondArr.indexOf ... ya gotta cap the "O"
NainaPS
@Navyya
Feb 24 2016 04:50
thanks @dcnr
CamperBot
@camperbot
Feb 24 2016 04:50
navyya sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 708 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 24 2016 04:50
also your indexOf parameters are off, are you sure you should be comparing inside?
@Navyya
bitgrower
@bitgrower
Feb 24 2016 04:50
lol ... I guess @Navyya isn't gonna bless me with any brownie points ... sniff ...
Moisés Man
@moigithub
Feb 24 2016 04:51
AND returning "too soon"
Norman Dela Cruz
@dcnr
Feb 24 2016 04:51
I'm sorry :(
NainaPS
@Navyya
Feb 24 2016 04:51
wait wait have patience @bitgrower
lemme complete
bitgrower
@bitgrower
Feb 24 2016 04:51
hahahahaha ... yeah, it has been kinda poured on ya, right ... ? formatting indexof, parameters, returning too soon ...
NainaPS
@Navyya
Feb 24 2016 04:51
my only first and last conditions are getting correct
bitgrower
@bitgrower
Feb 24 2016 04:52
I'm assuming that's progress, eh ?
NainaPS
@Navyya
Feb 24 2016 04:52
yup
Norman Dela Cruz
@dcnr
Feb 24 2016 04:52
@Navyya since you want to check all of SecondArr if it's in FirsArr, maybe you could also switch them around :D
NainaPS
@Navyya
Feb 24 2016 04:52
so what about rest conditions its not getting
bitgrower
@bitgrower
Feb 24 2016 04:53
can you paste your updated code ?
NainaPS
@Navyya
Feb 24 2016 04:53
pls be a lil elaborative so that i can get my error n fir them
Norman Dela Cruz
@dcnr
Feb 24 2016 04:53
anyway have to go, thanks again @bitgrower
bye all!
CamperBot
@camperbot
Feb 24 2016 04:53
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave bitgrower points
bitgrower
@bitgrower
Feb 24 2016 04:53
cya @dcnr ...
Norman Dela Cruz
@dcnr
Feb 24 2016 04:53
darn cooldown
NainaPS
@Navyya
Feb 24 2016 04:53
@dcnr byee

``` jsfunction mutation(arr) {
var FirstArr=arr[0].toLowerCase();
var SecondArr=arr[1].toLowerCase();
// var splitedArr=arr.split();
for(i=0; i<FirstArr.length;i++){
if(SecondArr.indexOf(FirstArr[i]<0)){
return false;
}
// else {return true;}
}

// return arr;
}

mutation(["hello", "hey"]);

ohh shhyyt

function mutation(arr) {
var FirstArr=arr[0].toLowerCase();
var SecondArr=arr[1].toLowerCase();
// var splitedArr=arr.split();
for(i=0; i<FirstArr.length;i++){
if(SecondArr.indexOf(FirstArr[i]<0)){
return false;
}
// else {return true;}
}

// return arr;
}

mutation(["hello", "hey"]);

bitgrower
@bitgrower
Feb 24 2016 04:54
you're very close ...
you just need to shift-enter after ```js

copy and paste this .... starting with the backticks: ```js

<paste your code here>
```

NainaPS
@Navyya
Feb 24 2016 04:56
function mutation(arr) {
  var FirstArr=arr[0].toLowerCase();
  var SecondArr=arr[1].toLowerCase();
 // var splitedArr=arr.split();
  for(i=0; i<FirstArr.length;i++){
    if(SecondArr.indexOf(FirstArr[i]<0)){
      return false;
    }
   // else {return true;}
  }

 // return arr;
}

mutation(["hello", "hey"]);
bitgrower
@bitgrower
Feb 24 2016 04:56
YAY!!!!
NainaPS
@Navyya
Feb 24 2016 04:56
yes i did it :)
now next is what about
the rest conditions?
bitgrower
@bitgrower
Feb 24 2016 04:58
hang on ...
your if statement is not quite set up correctly ... you have the test within the call of the indexOf function ...
NainaPS
@Navyya
Feb 24 2016 05:03
function mutation(arr) {
  var FirstArr=arr[0].toLowerCase();
  var SecondArr=arr[1].toLowerCase();
 // var splitedArr=arr.split();
  for(i=0; i<FirstArr.length;i++){
    if(SecondArr.indexOf(FirstArr[i]<0))
      return false;

   // else {return true;}
  }

  return true;
}

mutation(["hello", "hey"]);
:worried:
ya wait i got it
Monty
@webdev8183
Feb 24 2016 05:07
ugh that profile lookup was awful, I finally got it passing but I am sure its not optimal
Navvya how do you get that paste to work, mine wouldnt let me do it I tried the '''js but it didnt work for me.
CamperBot
@camperbot
Feb 24 2016 05:08
:bulb: to format code use backticks! ``` more info
NainaPS
@Navyya
Feb 24 2016 05:09
js(shift+enter)(paste ur code)(shift+enter)
@webdev8183
function mutation(arr)
{ 
  var FirstArr=arr[0].toLowerCase();
  var SecondArr=arr[1].toLowerCase(); 
  // var splitedArr=arr.split();
  for(i=0; i<FirstArr.length;i++){ 
    if(SecondArr.indexOf(FirstArr[i])<0)
      return false; 
    // else {return true;} 
  } 
  return true; 
} 
mutation(["hello", "hey"]);
use the key left of 1 i.e above tab key
give space after ```
@bitgrower this is updated code
pls
help if some else can also
CamperBot
@camperbot
Feb 24 2016 05:12
no wiki entry for: if some else can also
Monty
@webdev8183
Feb 24 2016 05:12
//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 lookUp(firstName, prop){
// Only change code below this line

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

   }

  for (j=0;j<4;j++){
    if (firstName!==contacts[j].firstName) 
      return "No such contact";
    else
      return "No such property";
  }





// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "address");
NainaPS
@Navyya
Feb 24 2016 05:12
@webdev8183 yes u did it
Monty
@webdev8183
Feb 24 2016 05:12
I am not sure why it doesn't work with just one loop, which it should.
NainaPS
@Navyya
Feb 24 2016 05:14
i got my error
DJ
@qualitymanifest
Feb 24 2016 05:14
@webdev8183 you can do it with one loop, if you use the right if/else if/ else statements
NainaPS
@Navyya
Feb 24 2016 05:15
btw @bitgrower thanks
CamperBot
@camperbot
Feb 24 2016 05:15
navyya sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 623 | @bitgrower | http://www.freecodecamp.com/bitgrower
Monty
@webdev8183
Feb 24 2016 05:16
yeah this one really doesn't like me, it took me forever to get to this point
bitgrower
@bitgrower
Feb 24 2016 05:19
@webdev8183 -- it does work with one loop
L Yeh
@PhotoGeek1
Feb 24 2016 05:20
How do you copy and paste your code here in chat with the black box background?
Monty
@webdev8183
Feb 24 2016 05:24
use the key above tab 3 times, spacebar js shift-enter, paste-your-code shift+enter.. I am on FF and it sometimes makes me close and reopen chat to get back to normal
bitgrower
@bitgrower
Feb 24 2016 05:25
explain format
CamperBot
@camperbot
Feb 24 2016 05:25

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Praneeth
@praneethkumarpidugu
Feb 24 2016 05:25
Hey Guys could anyone escallate for "truncate a string" algorithm problem
so far I have tried like this
function truncate(str, num) {
  // Clear out that junk in your trunk
  //Truncate if str > max_length_num
  //else return simple str.
  var someLength = str.length;
  if(num < someLength){
    return str.slice(0, num)+"...";
  }
  else if(num <= 3){
    return str.slice(0,num-3)+"...";
  }
  else{
    return str;
  }
}

truncate("A-tisket a-tasket A green and yellow basket", 11);
bitgrower
@bitgrower
Feb 24 2016 05:25

copy and paste starting with the backticks here: ```js

<paste your code here>
```

<paste your code here>
Susan Fnu
@SusanFnu
Feb 24 2016 05:26
function convert(celsius) {
  // Only change code below this line


  // Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}

// Change the inputs below to test your code
convert(30);
can anyone help me to solve this?thanks
bitgrower
@bitgrower
Feb 24 2016 05:26
where are you having difficulty, @SusanFnu ?
L Yeh
@PhotoGeek1
Feb 24 2016 05:26
thanks @webdev8183 @bitgrower
CamperBot
@camperbot
Feb 24 2016 05:26
photogeek1 sends brownie points to @webdev8183 and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 221 | @webdev8183 | http://www.freecodecamp.com/webdev8183
:star: 624 | @bitgrower | http://www.freecodecamp.com/bitgrower
Edison Brito
@edisonbrito
Feb 24 2016 05:26
hi, guys!
bitgrower
@bitgrower
Feb 24 2016 05:27
@praneethkumarpidugu -- read the instructions REALLY carefully ...
hello @edisonbrito
Edison Brito
@edisonbrito
Feb 24 2016 05:28
someone help me... "Iterate Through an Array with a For Loop"...
bitgrower
@bitgrower
Feb 24 2016 05:28
@Navyya -- did you get it ?
Susan Fnu
@SusanFnu
Feb 24 2016 05:28
@bitgrower i need to convert it to fahrenheit, but the thing is i dunno how to do the instruction for it
NainaPS
@Navyya
Feb 24 2016 05:28
yup
Edison Brito
@edisonbrito
Feb 24 2016 05:29
I do not know how to access an array and get their values.

var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

for(var total = 0; i < myArr.length; i++)
{
console.log(myArr)
// total += myArr[i];
}

bitgrower
@bitgrower
Feb 24 2016 05:29
let's start very basic, @SusanFnu --
do you know how to set a variable to a value?
for folks asking questions, can you supply the name of the challenge, please ?
@edisonbrito @SusanFnu ... ?
L Yeh
@PhotoGeek1
Feb 24 2016 05:33
This message was deleted
TheKingIsHere
@TheKingIsHere
Feb 24 2016 05:33
Hello all, working on record collection not sure where errors occur but I receive 1/4 correct responses.
 // Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

  if(value !== "" && prop !== "tracks") {

    collection[id][prop] = value;

  } else if (prop === "tracks" && value === "") {

    collection[id].tracks.push(value);

  } else if (value === "") {

    delete collection.prop;
  }


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
L Yeh
@PhotoGeek1
Feb 24 2016 05:33
This message was deleted
Susan Fnu
@SusanFnu
Feb 24 2016 05:38
@bitgrower i just got it. thanks tho
CamperBot
@camperbot
Feb 24 2016 05:38
susanfnu sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 625 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 24 2016 05:38
yw ...
@theKingIsHere ... so ... not exactly sure what's going on with your code, but here's a few pieces of advice that may help ...
you have multiple things you have to check for ... try laying them out and simplifying them, so you can make the fewest checks on a variable as possible...
Just to give you an idea ... my first if statement is simply if (value !== "")
L Yeh
@PhotoGeek1
Feb 24 2016 05:43

Hey Guys, Have a question about the JavaScript "Stand in Line" module.

Directions is to write a function that takes an array (arr) and a number (item) as arguments. Add the number (item) to the end of the array (.push) and remove the first element of the array (.shift). The function should return the element that was removed.

I used push to add the item at the end of the arr, returned the value of arr[0] and used shift to drop arr[0].

The error message I'm getting is that addArr.shift is not a function.

function queue(arr, item) {
  // Your code here
  var addArr = arr.push(item);
  var removedItem = arr[0];
  var newArr = addArr.shift();

  return removedItem;  // Change this line
}

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

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

Can someone give me a hint?

bitgrower
@bitgrower
Feb 24 2016 05:43
@PhotoGeek1 -- I would go check out the MDN pages on shift & push and make sure you understand them ... look at the examples ... and, also, use console.log to see what your variables look like
L Yeh
@PhotoGeek1
Feb 24 2016 05:44
@bitgrower what is MDN? total n00b.
bitgrower
@bitgrower
Feb 24 2016 05:44
you will get addArr.shift() is not a function if addArr is not seen to be an array
MDN = Mozilla Developer Network -- your newest BFF ... although someone earlier said something about marrying it ... :)
L Yeh
@PhotoGeek1
Feb 24 2016 05:45
@bitgrower hahaha, thanks!
CamperBot
@camperbot
Feb 24 2016 05:45
photogeek1 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: photogeek1 already gave bitgrower points
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 05:46
@bitgrower :laughing:
bitgrower
@bitgrower
Feb 24 2016 05:47
important reading lessons ...
  1. falsy bouncer -- yeah, read those "helpful hints" pages ...
  2. truncate -- read the dang instructions already ... carefully ...
David Bruskin
@kidimi
Feb 24 2016 05:55
This message was deleted
bitgrower
@bitgrower
Feb 24 2016 05:56
@kidimi -- :point_up: February 23, 2016 9:43 PM
David Bruskin
@kidimi
Feb 24 2016 05:58
function queue(arr, item) {
  arr.push(item);
  arr.shift(arr[0]);// 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(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
bitgrower
@bitgrower
Feb 24 2016 05:59
@kidimi -- I would go check out the MDN pages on shift & push and make sure you understand them ... look at the examples ... and, also, use console.log to see what your variables look like
MDN == Mozilla Developer Network (I was asked earlier ... )
David Bruskin
@kidimi
Feb 24 2016 06:00

"Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed."

Y queue([], 1) should return 1
N queue([2], 1) should return 2
N queue([5,6,7,8,9], 1) should return 5
Y After queue(testArr, 10), myArr[4] should be 10

Thanks, I just looked up MDN.
:)
bitgrower
@bitgrower
Feb 24 2016 06:00
:)
David Bruskin
@kidimi
Feb 24 2016 06:00
Okay, I'll do that.
Thx!
bitgrower
@bitgrower
Feb 24 2016 06:01
you do that, I think you'll be able to solve the challenge easily !!!
yw
Clay
@cblackiston
Feb 24 2016 06:15
hey all! i'm kind of stuck with the "Profile Lookup" exercise was hoping someone could walk me through it
here's my function thus far:
function lookUp(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i].firstName && (prop == "firstName" || prop == "lastName" || prop == "number" || prop == "likes")) {
    return contacts[i].prop;
  } 

}
// Only change code above this line
}
Markus Kiili
@Masd925
Feb 24 2016 06:18
@cblackiston It is easiest if you make two nested if's inside the contact loop. The first checks if the firstname matches and the second if the property exists.
After that you can drop the returns on correct spots.
Don't hardcode the property names. Use .hasOwnProperty() method.
Clay
@cblackiston
Feb 24 2016 06:19
ahh ok let me try that. thanks @Masd925
CamperBot
@camperbot
Feb 24 2016 06:19
cblackiston sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1029 | @masd925 | http://www.freecodecamp.com/masd925
haigashod
@haigashod
Feb 24 2016 06:33
Hi guys! Anyone present work on the Caesars Cipher problem?

I just solved it; curious to see what routes you might have taken. What I could have done to shorten the solution. Please share. I'm pretty beat and will likely sleep soon, but I'll be online in the morning to check:

function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var arrTwo = [];
  var list;

  for(i = 0; i < str.length; i++) { 
    // First conditional covers punctuations... 
    if(str.charCodeAt(i) == 32 || str.charCodeAt(i) == 33 || str.charCodeAt(i) == 46 || str.charCodeAt(i) == 63) {
      arr.push(str.charCodeAt(i));  
    // This conditional covers case of "L" that–when 13 is subtracted–becomes 63 which is a problematic
    // charCode. 
    } else if(str.charCodeAt(i) == 76) {
      arr.push(str.charCodeAt(i) + 13);
    } else {
      arr.push(str.charCodeAt(i)-13);  
    }
  }
  for(i = 0; i < arr.length; i++) {
    if(arr[i] < 65 && arr[i] !== 32 && arr[i] !== 33 && arr[i] !== 46 && arr[i] !== 63) {
      arrTwo.push(arr[i] + 26);
    } else {
      arrTwo.push(arr[i]);
    }
  }
//  list = arrTwo.join(", ");
  return String.fromCharCode.apply(null, arrTwo);
 }
// Change the inputs below to test
rot13("L?");

Cheers!

Markus Kiili
@Masd925
Feb 24 2016 06:43
@haigashod CodeReview room is better place for working solutions. Post it there and I can show you a simpler way to solve it.
Josh Fisk
@JoshFisk
Feb 24 2016 06:44
What does this do exactly? /\s+|_+/g
Josh Fisk
@JoshFisk
Feb 24 2016 06:44
Mainly what is the |_ part doing
DJ
@qualitymanifest
Feb 24 2016 06:47
@JoshFisk https://regex101.com/r/vP0bO2/1 there's an explanation on the right
good place for testing regex
Josh Fisk
@JoshFisk
Feb 24 2016 06:49
@qualitymanifest Thanks...so it makes something called an alternative? which is like an or...
CamperBot
@camperbot
Feb 24 2016 06:49
joshfisk sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 999 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Feb 24 2016 06:50
@JoshFisk yes, in regex the "or" pipeline is | whereas in JS it's ||
Josh Fisk
@JoshFisk
Feb 24 2016 06:57
I feel like if I study regex too much, nobody will be able to understand me anymore...
This message was deleted
Orv Bongat
@orvb
Feb 24 2016 07:00
Question: from what I understand, you can access object properties by using either the dot notation or bracket notation. If so, then why doesn't the following function work when I swap the way I access object properties.
'''
function lookUp(firstName, prop){
for (var i = 0; i < contacts.length; i++) {
// using contacts[i].[firstName] doesn't work
if (contacts[i].firstName === firstName) {
if (contacts[i].hasOwnProperty(prop)) {
// using contacts[i].prop doesn't work
return contacts[i][prop];
}
return "No such property";
}
}
return "No such contact";
}
'''
CamperBot
@camperbot
Feb 24 2016 07:00
:bulb: to format code use backticks! ``` more info
Orv Bongat
@orvb
Feb 24 2016 07:00
ah crap
function lookUp(firstName, prop){
  for (var i = 0; i < contacts.length; i++) {
    // using contacts[i].[firstName] doesn't work
    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
          // using contacts[i].prop doesn't work
          return contacts[i][prop];
      }
      return "No such property";
    }
  }
  return "No such contact";
}
Clay
@cblackiston
Feb 24 2016 07:02
@Masd925 i went down the path you recommended but am still having trouble. this is my code right now and it only works for the test with "Akira", "address"
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i].firstName) {
    if (contacts.hasOwnProperty(prop)) {
       return contacts[i].prop;
    } 

  }  

}
 if (contacts.hasOwnProperty(prop) === false) {
      return "No such property";
    } 
  return "No such contact";
Orv Bongat
@orvb
Feb 24 2016 07:02
reading through mozilla dev network reference to see if i can find out why
Markus Kiili
@Masd925
Feb 24 2016 07:03
@orvb The dot notation only works if the property key is a valid JS identifier and you write the key string after the dot. Bracket notation works with keys that can be arbitrary strings, variables, or expressions.
@cblackiston Don't put any extra code except the for loop and the two nested if's and the returns (figure out the correct places for them).
Clay
@cblackiston
Feb 24 2016 07:05
ok i'll keep messing with it ;) thanks @Masd925
CamperBot
@camperbot
Feb 24 2016 07:05
cblackiston sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: cblackiston already gave masd925 points
Orv Bongat
@orvb
Feb 24 2016 07:09
@Masd925 - ah i see why now, i wasn't taking into account the test cases which purposely makes it fail
thanks @Masd925
CamperBot
@camperbot
Feb 24 2016 07:09
orvb sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1030 | @masd925 | http://www.freecodecamp.com/masd925
Ankit Panwar
@coderNoob
Feb 24 2016 07:15
In my validate US number bonfire, I got the following expression but I can't filter the () portion. How do I check whether the opening and closing tags are present?
/[^-][1?][\s-]?\(?(\d{3})\)?[\s-]?\d{3}[\s-]?\d{4}/g
L Yeh
@PhotoGeek1
Feb 24 2016 07:16
This message was deleted

Question about the module "Adding a default option in Switch statements"
It would seem this is an easy one, but I can't figure out why this is not working:

Instructions
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"

function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val.length == 1) {
    case val === "a":
      answer = "apple";
      break;
    case val === "b":
      answer = "bird";
      break;
    case val === "c":
      answer = "cat";
      break;
    default:
      answer = "stuff";
  }

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

// Change this value to test
myTest(3);

When a number is passed through the switch statement it returns "apple." Why??

Ankit Panwar
@coderNoob
Feb 24 2016 07:20
This message was deleted
Soumitra Varindra Chakravarti
@soumitrachakravarti
Feb 24 2016 07:20
This message was deleted
Ankit Panwar
@coderNoob
Feb 24 2016 07:21
This message was deleted
Soumitra Varindra Chakravarti
@soumitrachakravarti
Feb 24 2016 07:22
@PhotoGeek1 Try
case a:
answer = "apple";
break;
Ankit Panwar
@coderNoob
Feb 24 2016 07:22
@PhotoGeek1 switch statement only works for an integer or a character value
You need to do
switch(val){
 // do something here
}
Ramins01
@Ramins01
Feb 24 2016 07:22
@PhotoGeek1 I think it's because you have "switch(val.length == 1)" switch it to just "switch(val)" and each case should be just case 'a' case
Markus Kiili
@Masd925
Feb 24 2016 07:22
@PhotoGeek1 Because val.length == 1 is false and val === "a" is false. You should do switch(val) {...
Ramins01
@Ramins01
Feb 24 2016 07:22
@PhotoGeek1 case 'a', case 'b' etc
L Yeh
@PhotoGeek1
Feb 24 2016 07:24
thanks @Ramins01 & @Masd925
CamperBot
@camperbot
Feb 24 2016 07:24
photogeek1 sends brownie points to @ramins01 and @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1031 | @masd925 | http://www.freecodecamp.com/masd925
:star: 306 | @ramins01 | http://www.freecodecamp.com/ramins01
anthonygallina1
@anthonygallina1
Feb 24 2016 07:30
Been messing with this for 2 days have seen some great psuedo code. But have not been able to manage to get over the bump in the way of my progress on this one Symmetric Difference.
function sym() {
    var sets = [], result = [];
    var args = Array.prototype.slice.call(arguments, 0);
    args.forEach(function(arr) {
        sets.push(new Set(arr));
    });
    args.forEach(function(array, arrayIndex) {
        array.forEach(function(item) {
            var found = false;
            for (var setIndex = 0; setIndex < sets.length; setIndex++) {
                if (setIndex !== arrayIndex) {
                    if (sets[setIndex].has(item)) {
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                result.push(item);
            }
        });
    });
  return result;
}

sym([1, 2, 5], [2, 3, 5], [3, 4, 5]);
Markus Kiili
@Masd925
Feb 24 2016 07:36
@anthonygallina1 Not sure what your logic of solving it is, but I found it easy using the following logic. You can do symmDiff of two arrays by first removing multiple elements from individual arrays (leaving only one of each element) and then concating the arrays and removing doubled elements (removing elements that are more than one there).
I wrote two helper functions for removing doubles and multiples from an array and used reduce for solving the problem: return args.reduce(...,[ ]);
Yury
@imbroyury
Feb 24 2016 07:52

Hey guys, need help. Works perfectly fine when app recieves GPS coordinates, but fail to give any kind of error when it doesn't (when I decline to give geolocation info or on my Android device)

http://codepen.io/imbroyury/pen/obrEbJ

Soumitra Varindra Chakravarti
@soumitrachakravarti
Feb 24 2016 07:59
Screen Shot 2016-02-24 at 1.25.06 PM.png
Can anyone tell me if ES6 is supported in the FCC editor?
anthonygallina1
@anthonygallina1
Feb 24 2016 08:02
The slice() method returns the selected elements in an array, as a new array object. Then the The forEach() method executes a provided function once per array .Then it pushes into Set array.Then the for each function is ran on the array and a variable of false is set for found. And a set index var is set and the length is set to 0 if the sets length is less than set index it loops and adds. If set index is not not equal value or not equal type of array index it runs and sets found to true then @Masd925 working on the logic
L Yeh
@PhotoGeek1
Feb 24 2016 08:02

Need a bit of help (again!) on switch statements (Counting Cards/Blackjack module)

Need to create a function that will count cards and tell a player if they should bet, or hold.

Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"

var count = 0;

function cc(card) {
  // Only change code below this line

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

  }

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


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

These are returning an error:
Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"

So it seems something is wrong with the positive numbers? I can't figure out why. Can take a look-see please?

anthonygallina1
@anthonygallina1
Feb 24 2016 08:04

@Masd925

            }
            if (!found) {
                result.push(item);
            }
        });
    });
  return result;
}

sym([1, 2, 5], [2, 3, 5], [3, 4, 5]);
`

Well this part is easy should I explain that logic?

Still stuck
L Yeh
@PhotoGeek1
Feb 24 2016 08:06
Is there a coding platform I can plug JS into and see the results? The console provided here doesn't let me "play" with code. Any recommendations?
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 08:09
@PhotoGeek1 remove the line return "Change Me";
dltaylor
@dltaylor
Feb 24 2016 08:09
I am not understanding the queue could someone clue me in?
They just don't explain it enough for me?
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 08:12
@PhotoGeek1 your code is working on my console
L Yeh
@PhotoGeek1
Feb 24 2016 08:13
@abhishekKumar1 I removed the line and it's still giving me the same error
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 08:13

try changing the last line to

cc(2); cc(3); cc(4); cc(5); cc(6);

and tell what output u get

L Yeh
@PhotoGeek1
Feb 24 2016 08:13
@abhishekKumar1 how weird
Hmmm... @abhishekKumar1 Thanks! I guess this is a bug??
CamperBot
@camperbot
Feb 24 2016 08:14
photogeek1 sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 353 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 08:14
omg you have given a space after Bet try " Bet" not " Bet "
@PhotoGeek1 :smile:
L Yeh
@PhotoGeek1
Feb 24 2016 08:17
@abhishekKumar1 OH!!! smacks forehead Thank you!
CamperBot
@camperbot
Feb 24 2016 08:17
photogeek1 sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:warning: photogeek1 already gave abhishekkumar1 points
thomas-duval
@thomas-duval
Feb 24 2016 08:19

Hey guys,
I have a problem with the steamroller challenge.
Here is my code :

var result = [];
function steamroller(arr) {
    recursion(arr);
    return result;
}
function recursion(array) {
    for (var k = 0; k < array.length; k++) {
        if (Array.isArray(array[k])) {
            recursion(array[k]);
        } else {
            result.push(array[k]);
        }
    }
}

The problem is that instead of having [1, 2, 3, 4], I get [1, 2, 3, 4] (there is a space after each comma).
How can I fix it ?

Markus Kiili
@Masd925
Feb 24 2016 08:19
@thomas-duval You must declare variables inside the function. FCC can't test it otherwise.
thomas-duval
@thomas-duval
Feb 24 2016 08:20
@Masd925 But if I do that, the other function won't know what is the variable (result in my case) ?!
Markus Kiili
@Masd925
Feb 24 2016 08:21
@thomas-duval Put the helper function inside steamroller function.
@thomas-duval If you slightly alter your code, you can avoid the helper function altogether. You can use steamroller to flatten the array elements that are arrays.
thomas-duval
@thomas-duval
Feb 24 2016 08:26

@Masd925 Something like that ?

function steamroller(arr) {
    var result = [];
    function recursion() {
        for (var k = 0; k < arr.length; k++) {
            if (Array.isArray(arr[k])) {
                recursion(arr[k]);
            } else {
                result.push(arr[k]);
            }
        }
    }
    return result;
}

But it's not working :(

Markus Kiili
@Masd925
Feb 24 2016 08:28
@thomas-duval I meant this:
function steamroller(arr) {
    var result = [];
    recursion(arr);
    return result;
    function recursion(array) {
        for (var k = 0; k < array.length; k++) {
            if (Array.isArray(array[k])) {
                recursion(array[k]);
            } else {
                result.push(array[k]);
            }
       }
    }
}
thomas-duval
@thomas-duval
Feb 24 2016 08:28
@Masd925 oh, didn't know we could do that ...
Markus Kiili
@Masd925
Feb 24 2016 08:29
@thomas-duval You can quite easily turn it to pure recursion without the inner function and result variable.
thomas-duval
@thomas-duval
Feb 24 2016 08:30
@Masd925 How ? If there is a way to make it cleaner, I want to know :p
@Masd925 Thanks for the help ;)
CamperBot
@camperbot
Feb 24 2016 08:35
thomas-duval sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1032 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Feb 24 2016 08:41
@thomas-duval Here is a solution that shows the logic of recursive solution:
function steamroller(arr) {
  return arr.reduce(function(previousValue, currentValue) {
    return previousValue.concat(Array.isArray(currentValue) ? steamroller(currentValue) : currentValue);
    }, []);  
}
Hemedi
@Hemedi
Feb 24 2016 08:45
help Map the Debris
CamperBot
@camperbot
Feb 24 2016 08:45

:point_right: algorithm map the debris [wiki]

Problem Explanation:

The first thing to do is to get familiar with what the program is for, for this I would suggest you check the Wikipedia link as that is very important and from where you can also get the formula for the conversion. The hardest part are finding the formula, implementing it and for some modifying objects by the key. However, something that is not very clear is the fact that your program has to be able to check for any number of objects in the array which is what is tested on the second part.

:pencil: read more about algorithm map the debris on the FCC Wiki

thomas-duval
@thomas-duval
Feb 24 2016 08:48
@Masd925 I don't understand it but I will look into it :D
Gaurav Singh
@the07
Feb 24 2016 08:53
help Falsy Bouncer
CamperBot
@camperbot
Feb 24 2016 08:53

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

thomas-duval
@thomas-duval
Feb 24 2016 08:56
@Wangach Use markdown to copy your code in the chat ;)
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 08:56
@Wangach use this
help format
CamperBot
@camperbot
Feb 24 2016 08:56

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

cannelflow
@cannelflow
Feb 24 2016 08:57
@Wangach var myData = myArray[1][2]; is accessing 3
and you need to access 8
@Wangach
var arr = [
    [1,2,3],
    [4,5,6],
    [7,8,9],
    [[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
Andrew Dutton
@andrew-dutton
Feb 24 2016 08:58
This message was deleted
Wangach
@Wangach
Feb 24 2016 08:58
@cannelflow Yap i need to access 8,Any solutions to that? @thomas-duval markdown? please elaborate. THanks in advance
CamperBot
@camperbot
Feb 24 2016 08:58
wangach sends brownie points to @cannelflow and @thomas-duval :sparkles: :thumbsup: :sparkles:
:star: 308 | @thomas-duval | http://www.freecodecamp.com/thomas-duval
:star: 825 | @cannelflow | http://www.freecodecamp.com/cannelflow
cannelflow
@cannelflow
Feb 24 2016 08:59
@Wangach
var myArray = [[1,2,3], <===myArray[0] and if you need value 3 here then do like myArray[0][2]
[4,5,6], <===myArray[1]
[7,8,9], <===myArray[2]
[[10,11,12], 13, 14]];<===myArray[3]
Wangach
@Wangach
Feb 24 2016 09:00
@cannelflow I just don't get it. How do arr[3][0][1]; access 11?
fluffystub
@RakshithNM
Feb 24 2016 09:01
@bovas85 its not working!!!
Markus Kiili
@Masd925
Feb 24 2016 09:02
@thomas-duval This is slightly simpler version of the same:
function steamroller(arr) {
    if (!Array.isArray(arr)) return arr;

    result = [];

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

    return result;
}
cannelflow
@cannelflow
Feb 24 2016 09:03
[
    [1,2,3],<==arr0
    [4,5,6],<==arr1
    [7,8,9],<==arr2
    [[10,11,12], 13, 14]<==arr3<====again this is multidimensional array so arr[0] then arr[1] to get 11
];
so arr[3][0][1] @Wangach
sudheerswamy
@sudheerswamy
Feb 24 2016 09:04
Build myStr over several lines by concatenating these two strings:
"This is the first sentence. " and "This is the second sentence." using the += operator.
help!
CamperBot
@camperbot
Feb 24 2016 09:04

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

sudheerswamy
@sudheerswamy
Feb 24 2016 09:05
find js
sudheerswamy
@sudheerswamy
Feb 24 2016 09:05
find js
CamperBot
@camperbot
Feb 24 2016 09:05

find js

more enteries:

:two::zero: js array prototype reduce
:two::one: js array prototype reverse
:two::two: js array prototype shift
:two::three: js array prototype slice
:two::four: js array prototype some
:two::five: js array prototype sort
:two::six: js array prototype splice
:two::seven: js array prototype tostring
:two::eight: js boolean
:two::nine: js string prototype charat
:three::zero: js string prototype charcodeat
:three::one: js string prototype concat
:three::two: js string prototype indexof
:three::three: js string prototype lastindexof
:three::four: js string prototype match
:three::five: js string prototype replace
:three::six: js string prototype slice
:three::seven: js string prototype split
:three::eight: js string prototype substr
:three::nine: js string prototype substring
:four::zero: js string prototype tolowercase
:four::one: js string prototype touppercase
:four::two: js arguments
:four::three: js closures
:four::four: js falsy
:four::five: js for in loop
:four::six: js for loop
:four::seven: js for of loop
:four::eight: js functions
:four::nine: js immutable
:five::zero: js loops
:five::one: js scope
:five::two: js ternary
:five::three: js truthy
:five::four: js undefined
:five::five: jsonp
:five::six: wiki js template

cannelflow
@cannelflow
Feb 24 2016 09:05
in this [[10,11,12], 13, 14]
[10,11,12] is arr[0] so arr[0][1] is 11 
13 is arr[1]
14 is arr[2]
@Wangach
sudheerswamy
@sudheerswamy
Feb 24 2016 09:05
find js
Denis
@DenisDov
Feb 24 2016 09:05
find js
CamperBot
@camperbot
Feb 24 2016 09:05

find js

more enteries:

:two::zero: js array prototype reduce
:two::one: js array prototype reverse
:two::two: js array prototype shift
:two::three: js array prototype slice
:two::four: js array prototype some
:two::five: js array prototype sort
:two::six: js array prototype splice
:two::seven: js array prototype tostring
:two::eight: js boolean
:two::nine: js string prototype charat
:three::zero: js string prototype charcodeat
:three::one: js string prototype concat
:three::two: js string prototype indexof
:three::three: js string prototype lastindexof
:three::four: js string prototype match
:three::five: js string prototype replace
:three::six: js string prototype slice
:three::seven: js string prototype split
:three::eight: js string prototype substr
:three::nine: js string prototype substring
:four::zero: js string prototype tolowercase
:four::one: js string prototype touppercase
:four::two: js arguments
:four::three: js closures
:four::four: js falsy
:four::five: js for in loop
:four::six: js for loop
:four::seven: js for of loop
:four::eight: js functions
:four::nine: js immutable
:five::zero: js loops
:five::one: js scope
:five::two: js ternary
:five::three: js truthy
:five::four: js undefined
:five::five: jsonp
:five::six: wiki js template

Denis
@DenisDov
Feb 24 2016 09:06
Word Blanks
Wangach
@Wangach
Feb 24 2016 09:06
@cannelflow Oh I get it now...
@cannelflow Thanks for the help!
CamperBot
@camperbot
Feb 24 2016 09:06
wangach sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:warning: wangach already gave cannelflow points
cannelflow
@cannelflow
Feb 24 2016 09:06
@Wangach :+1:
Denis
@DenisDov
Feb 24 2016 09:08
find TOPIC
CamperBot
@camperbot
Feb 24 2016 09:08

find topic

:zero: topic

Marina
@chandra90
Feb 24 2016 09:08
What's wrong?
Denis
@DenisDov
Feb 24 2016 09:08
find topic
CamperBot
@camperbot
Feb 24 2016 09:08

find topic

:zero: topic

Marina
@chandra90
Feb 24 2016 09:08
var myStr="I am a \"double quoted"\string inside\"double quotes"\"; // Change this line
Bartosz
@CataciD
Feb 24 2016 09:08
Mates, is the orbital period task "Map the Debirs" so easy or am I doing something wrong?
Denis
@DenisDov
Feb 24 2016 09:08
36 topic
find 36
CamperBot
@camperbot
Feb 24 2016 09:09
find 36
nothing found
Denis
@DenisDov
Feb 24 2016 09:09
find word blanks
CamperBot
@camperbot
Feb 24 2016 09:09

find word blanks

:zero: checkpoint word blanks

Marina
@chandra90
Feb 24 2016 09:09
please help!
Bartosz
@CataciD
Feb 24 2016 09:09
find Map The Debirs
CamperBot
@camperbot
Feb 24 2016 09:09
find map the debirs
nothing found
Bartosz
@CataciD
Feb 24 2016 09:09
lel doesnt work
cannelflow
@cannelflow
Feb 24 2016 09:09
@chandra90 which exercise is that
Marina
@chandra90
Feb 24 2016 09:10
@cannelflow Escaping Literal Quotes in Strings
Bartosz
@CataciD
Feb 24 2016 09:10
@chandra90 what do you want to do with that?
Marina
@chandra90
Feb 24 2016 09:10

@CataciD Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes"

Bartosz
@CataciD
Feb 24 2016 09:10
i need to check how i did it
you just need to fix the quotes lol
at least from what I can see
you need to check if the pairs are in order and in place
Marina
@chandra90
Feb 24 2016 09:12
@CataciD how??
Bartosz
@CataciD
Feb 24 2016 09:12
look at the sentence
if you want to USE the " as code
then its just "
if in a string
it needs to be \"
so lets say
\"string\" will be printed as "string"
but "\string\" will be printed out as \string\
because "\ isnt \"
you need to check the sentence and decide which parts you need to be IN CODE and which are strings
Marina
@chandra90
Feb 24 2016 09:14
@CataciD thanks
CamperBot
@camperbot
Feb 24 2016 09:14
chandra90 sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:star: 317 | @catacid | http://www.freecodecamp.com/catacid
Bartosz
@CataciD
Feb 24 2016 09:14
you understand now?
in simpler words in this excercise every quote except the first and the last
should be \" afaik
because its one string
Alessandro Giordo
@bovas85
Feb 24 2016 09:15
@RakshithNM
$("#butt2").on("click",function(){
    var presQuote = 'http://twitter.com/intent/tweet?text='+ randomQuote + ' by ' + randomAuth;
   $("a").attr('href', presQuote);
 });
Bartosz
@CataciD
Feb 24 2016 09:15
so string = " things inside string like \" \" \" how many times you want "
Marina
@chandra90
Feb 24 2016 09:15
@CataciD I hope so. Thank for your help! You are very kind!
CamperBot
@camperbot
Feb 24 2016 09:15
chandra90 sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:warning: chandra90 already gave catacid points
Bartosz
@CataciD
Feb 24 2016 09:15
no probs ;p
Alessandro Giordo
@bovas85
Feb 24 2016 09:15
@RakshithNM you forgot to add # to target the id and also by needs spaces on both sides.
Bartosz
@CataciD
Feb 24 2016 09:15
@bovas85 try ``` and shift enter, then code then ctrl enter
var myStr = "I am a \"double quoted\" string inside \"double quotes\"";
like this
Alessandro Giordo
@bovas85
Feb 24 2016 09:16
ye sorry I know I didn't bother as it's a small line
Bartosz
@CataciD
Feb 24 2016 09:17
still ;P makes it more readable :P
Alessandro Giordo
@bovas85
Feb 24 2016 09:17
indeed :p
Marina
@chandra90
Feb 24 2016 09:18
@CataciD thanks! You are genius!:*
CamperBot
@camperbot
Feb 24 2016 09:18
chandra90 sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:warning: chandra90 already gave catacid points
Bartosz
@CataciD
Feb 24 2016 09:19
No I'm not :P just take it slow
but thank you
fluffystub
@RakshithNM
Feb 24 2016 09:20
@bovas85 i am able to open the twitter page...the random is not put on the page
Stanley
@stanleyyylau
Feb 24 2016 09:20
function smallestCommons(arr) {
  var allFirstMultiple=[];
  var allSecondMultiple=[];
  var smallestCommon=0;
  var allBewteen;

  for(var i=1;i<=1000;i++){
    var toBePush=arr[0]*i;
    allFirstMultiple.push(toBePush);
  }

  for(var u=1;u<=1000;u++){
    var toBePush2=arr[1]*u;
    allSecondMultiple.push(toBePush2);
  }

  for(var t=0;t<1000;t++){
    for(var p=0;p<1000;p++){
      if(allSecondMultiple.indexOf(allFirstMultiple[p])>0){
        smallestCommon=allFirstMultiple[p];
        p=p+10000;
      }
    }
  }


  for(var h=arr[0]+1;h<arr[1];h++){
    if(smallestCommon%h!==0){
      smallestCommon=smallestCommon*h;
    }
  }

  return smallestCommon;

}


smallestCommons([1,5]);
fluffystub
@RakshithNM
Feb 24 2016 09:20
i mean the tweet field
Alessandro Giordo
@bovas85
Feb 24 2016 09:21
@RakshithNM did you add the # to the id?
Stanley
@stanleyyylau
Feb 24 2016 09:21
can anyone please hel
my code dont work
i'm on "Smallest Common Multiple" chalenge
sudheerswamy
@sudheerswamy
Feb 24 2016 09:21

Build myStr over several lines by concatenating these two strings:
"This is the first sentence. " and "This is the second sentence." using the += operator.

Run tests (ctrl + enter)

stuck here!
Bartosz
@CataciD
Feb 24 2016 09:22
@RakshithNM from what i know if its the one with twitter random quotes, you can INSERT the tweet into the URL in a way
@stanleyyylau interpretting someone's code might be crazy
@stanleyyylau try explaining what you're trying to do first or what part you dont understand
Stanley
@stanleyyylau
Feb 24 2016 09:24
@CataciD sure, let me add comments
fluffystub
@RakshithNM
Feb 24 2016 09:24
@bovas85 yes i did
Alessandro Giordo
@bovas85
Feb 24 2016 09:24
@RakshithNM send me the code again
Bartosz
@CataciD
Feb 24 2016 09:27
url under the tweet button is https://twitter.com/intent/tweet?text= @RakshithNM
Marina
@chandra90
Feb 24 2016 09:27
This message was deleted
This message was deleted
Bartosz
@CataciD
Feb 24 2016 09:29
var myStr = '<a href=\"http//:www.example.com/\" target=\"_blank\">Link</a>';
Alessandro Giordo
@bovas85
Feb 24 2016 09:29
@RakshithNM that's why you have to initialise the function on page load first once
The first time you click on the twitter icon it won't pickup anything as the function is not initialised
if you click on generate quote once and then tweet it will return it
so instead of having a default quote on page load
leave that as loading...
and then on page load call the function once
and then call it each click of the .butt1
(btw really bad/funny name for a class lol)
Wangach
@Wangach
Feb 24 2016 09:32
This message was deleted
Stanley
@stanleyyylau
Feb 24 2016 09:33
function smallestCommons(arr) {
  var allFirstMultiple=[];
  var allSecondMultiple=[];
  var smallestCommon=0;
  var allBewteen;
  //allFirstMultiple will be an array having all multiple of arr[0]//
  for(var i=1;i<=1000;i++){
    var toBePush=arr[0]*i;
    allFirstMultiple.push(toBePush);
  }

    //allSecondMultiple will be an array having all multiple of arr[1]
  for(var u=1;u<=1000;u++){
    var toBePush2=arr[1]*u;
    allSecondMultiple.push(toBePush2);
  }


  //use indexOf to check the smallest commond Multiple of arr[0] and arr[1]
  for(var t=0;t<1000;t++){
    for(var p=0;p<1000;p++){
      if(allSecondMultiple.indexOf(allFirstMultiple[p])>0){
        smallestCommon=allFirstMultiple[p];
        p=p+10000;
      }
    }
  }

 //now check if the smallest commond can also be divided by all numbers in the arr[1] arr[2] range 
  for(var h=arr[0]+1;h<arr[1];h++){
    if(smallestCommon%h!==0){
      smallestCommon=smallestCommon*h;
    }
  }

  return smallestCommon;

}


smallestCommons([1,5]);
@CataciD pls help me check again tks
CamperBot
@camperbot
Feb 24 2016 09:33
stanleyyylau sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:star: 319 | @catacid | http://www.freecodecamp.com/catacid
Wangach
@Wangach
Feb 24 2016 09:34
This message was deleted
JackeL
@jackel27
Feb 24 2016 09:35
woah
Wangach
@Wangach
Feb 24 2016 09:35
This message was deleted
@sudheerswamy share a link please.
Stanley
@stanleyyylau
Feb 24 2016 09:37
now the weird thing is when i use the console.log to put the smallestcommon
it gives me these ```
small is10
VM1188:37 small is10
VM1186:37 small is10
VM1186:37 small is10
VM1186:37 small is5
VM1186:37 small is26
Wangach
@Wangach
Feb 24 2016 09:39
This message was deleted
Olawale Akinseye
@brainyfarm
Feb 24 2016 09:43
Good morning from here @jackel27 :D
Bartosz
@CataciD
Feb 24 2016 09:44
@stanleyyylau
t<1000
this is a VERY bad habbit
Olawale Akinseye
@brainyfarm
Feb 24 2016 09:44
@stanleyyylau long code you have got there man.
Bartosz
@CataciD
Feb 24 2016 09:45
also the problem is mostly math so
use equations
Stanley
@stanleyyylau
Feb 24 2016 09:45
@CataciD yes, i change it a little bit now
function smallestCommons(arr) {
  var prime=arr[0]*arr[1];
  var allFirstMultiple=[];
  var allSecondMultiple=[];
  var smallestCommon=0;
  var allBewteen;
  //allFirstMultiple will be an array having all multiple of arr[0]//
  for(var i=1;i<=prime;i++){
    var toBePush=arr[0]*i;
    allFirstMultiple.push(toBePush);
  }

    //allSecondMultiple will be an array having all multiple of arr[1]
  for(var u=1;u<=prime;u++){
    var toBePush2=arr[1]*u;
    allSecondMultiple.push(toBePush2);
  }


  //use indexOf to check the smallest commond Multiple of arr[0] and arr[1]
  for(var t=0;t<prime;t++){
    for(var p=0;p<prime;p++){
      if(allSecondMultiple.indexOf(allFirstMultiple[p])>0){
        smallestCommon=allFirstMultiple[p];
        p=p+prime*2;
      }
    }
  }

  console.log("small is"+ smallestCommon);
 //now check if the smallest commond can also be divided by all numbers in the arr[1] arr[2] range 
  for(var h=arr[0]+1;h<arr[1];h++){
    if(smallestCommon%h!==0){
      smallestCommon=smallestCommon*h;
    }
  }

  return smallestCommon;

}


smallestCommons([4,5]);
still dont work
Bartosz
@CataciD
Feb 24 2016 09:46
you're probably over doing it
check this out
function nwd(a,b){
  while (a!==b){
    if(a>b){a-=b;} 
    if(b>a){b-=a;}
  }
  return a;
}

function smallestCommons(arr) {
  arr.sort(function(a,b){return a-b;});
  var r=arr[1];
  var h=arr[1]-1;

  while(h>arr[0]){
    r=(r*h)/nwd(r,h);
    h--;
  }
  return r;
}


smallestCommons([5,1]);
all the code you ever need
smallest common multiple youses the biggest common divider
uses*
Olawale Akinseye
@brainyfarm
Feb 24 2016 09:46
@CataciD, please don't post solutions.
Bartosz
@CataciD
Feb 24 2016 09:46
@brainyfarm sure mate but there's no reason i can go through his code
Wangach
@Wangach
Feb 24 2016 09:47
One question.... How do you display the code as it is in fcc. I mean; having a black bg-color etc?
Olawale Akinseye
@brainyfarm
Feb 24 2016 09:47
Still posting your own solution could be discouraging and won't help in the long run.
Bartosz
@CataciD
Feb 24 2016 09:47
``` shift+enter ctrl+enter
Olawale Akinseye
@brainyfarm
Feb 24 2016 09:47
Explain format
CamperBot
@camperbot
Feb 24 2016 09:47

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Olawale Akinseye
@brainyfarm
Feb 24 2016 09:48
@Wangach :point_up:
Thijs Karens
@thijskarens
Feb 24 2016 09:48
Hey guys, how can i share my challenge here so you gusy can help me?
Bartosz
@CataciD
Feb 24 2016 09:48
@stanleyyylau basically read this http://www.purplemath.com/modules/lcm_gcf.htm
@stanleyyylau and use equations instead of loops etc
Thijs Karens
@thijskarens
Feb 24 2016 09:49
'''
CamperBot
@camperbot
Feb 24 2016 09:49
:bulb: to format code use backticks! ``` more info
Thijs Karens
@thijskarens
Feb 24 2016 09:49

```// Setup
function abTest(a, b) {
// Only change code below this line

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(1,2);
```

Wangach
@Wangach
Feb 24 2016 09:49
@brainyfarm @CataciD Thanks
CamperBot
@camperbot
Feb 24 2016 09:49
wangach sends brownie points to @brainyfarm and @catacid :sparkles: :thumbsup: :sparkles:
:star: 1544 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
:star: 320 | @catacid | http://www.freecodecamp.com/catacid
Stanley
@stanleyyylau
Feb 24 2016 09:49
@CataciD thanks, I'll look into it
CamperBot
@camperbot
Feb 24 2016 09:49
stanleyyylau sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
Bartosz
@CataciD
Feb 24 2016 09:49
no probs
CamperBot
@camperbot
Feb 24 2016 09:49
:warning: stanleyyylau already gave catacid points
Bartosz
@CataciD
Feb 24 2016 09:50
@stanleyyylau its reaaaly easy once you undertsnad lcm and gcf
basically you need to find gcfs all the time and use them to get lcm
Wangach
@Wangach
Feb 24 2016 09:52
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[1][2];
Olawale Akinseye
@brainyfarm
Feb 24 2016 10:01
What is the issue @Wangach?
Erik Hooijer
@hooijerik
Feb 24 2016 10:06
help truncate a string
CamperBot
@camperbot
Feb 24 2016 10:06

:point_right: algorithm truncate a string [wiki]

Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

:pencil: read more about algorithm truncate a string on the FCC Wiki

Bartosz
@CataciD
Feb 24 2016 10:09
you need help @hooijerik or did bot explain? :D
Erik Hooijer
@hooijerik
Feb 24 2016 10:10
thanks @CataciD, bot helped me enough
CamperBot
@camperbot
Feb 24 2016 10:10
hooijerik sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:star: 322 | @catacid | http://www.freecodecamp.com/catacid
Bartosz
@CataciD
Feb 24 2016 10:40
anyone here done the No repeats please?
fluffystub
@RakshithNM
Feb 24 2016 10:40
@bovas85 thanks.... :smile:
Alessandro Giordo
@bovas85
Feb 24 2016 10:43
@RakshithNM I mean
$(document).ready(function(){
  $(".quote").removeClass("loading");
  nextOne();
Markus Kiili
@Masd925
Feb 24 2016 10:43
@CataciD Yes.
Alessandro Giordo
@bovas85
Feb 24 2016 10:43
add that on top so it triggers a quote straight away AND on click
Ankit Panwar
@coderNoob
Feb 24 2016 10:44
What does the : mean in a regex?
Blauelf
@Blauelf
Feb 24 2016 10:48
As in (?:foo)? There it has some meaning as part of the ?: starting the group, there is also ?= and ?!
Bartosz
@CataciD
Feb 24 2016 10:48
@Masd925 did you use the heaps algorithm or what? I was stuck for a few days but my heaps seems to go in a crazy loop. It's the last task I've got left in this chapter
Ankit Panwar
@coderNoob
Feb 24 2016 10:50
@Blauelf I didn't get it.
Blauelf
@Blauelf
Feb 24 2016 10:51
@coderNoob Where is the : you encountered? Maybe it has no special meaning at all, being just taken literally.
Ankit Panwar
@coderNoob
Feb 24 2016 10:52
@Blauelf
var re = /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$/;
Markus Kiili
@Masd925
Feb 24 2016 10:52
@CataciD I have a recursive helper function that generates the permutations.
VosOditDeus
@VosOditDeus
Feb 24 2016 10:52
hello, can someine explain why this doesn't work
var Marr=[];
test =["",NaN,0,null,undefined,false];
function bouncer(arr) {
  for(var i=0;i<arr.length;i++){
    if(!(arr[i] in test)){
      Marr.push(arr[i]);
      console.log(Marr);
    }
  }
  return Marr;
}
Bartosz
@CataciD
Feb 24 2016 10:52
@Masd925 yeah... i have the same approach, and I'm trying to use the heaps algorithm in that helper
Markus Kiili
@Masd925
Feb 24 2016 10:53
@VosOditDeus NaN is special because NaN===NaN is false.
Bartosz
@CataciD
Feb 24 2016 10:53
which is recursive but im not sure if im doing it properly
VosOditDeus
@VosOditDeus
Feb 24 2016 10:53
@Masd925 it doesn't work even on "".
Bartosz
@CataciD
Feb 24 2016 10:53
because NaN is a number explaining the value is not a number
kappa
Markus Kiili
@Masd925
Feb 24 2016 10:54
@VosOditDeus Variables must be declared inside the function in order for FCC to test it.
VosOditDeus
@VosOditDeus
Feb 24 2016 10:55
@Masd925 okay, but still it doesn't.
mohannadsawalhi
@mohannadsawalhi
Feb 24 2016 10:56

// Example
var firstName = "Ada";
var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];

// Setup
var lastName = "Lovelace";

// Only change code below this line
var secondToLastLetterOfLastName = [lastName.length -3];

secondToLastLetterOfLastName should be "c".
help me please
CamperBot
@camperbot
Feb 24 2016 10:56
no wiki entry for: me please
Markus Kiili
@Masd925
Feb 24 2016 10:57
@VosOditDeus in operator tests property keys, in this case if the array index exists.
You can use indexOf on test to test if arr[i] is one of test elements.
Blauelf
@Blauelf
Feb 24 2016 11:00
@coderNoob There it is part of a ?: where it is marking a "non-capturing group", one that matches but does not create a numbered match.
Alessandro Giordo
@bovas85
Feb 24 2016 11:01
@RakshithNM you could do this to keep the loading as well since you added it
$(".butt1").on("click", function(){
   $(".quote").html("Loading...").addClass("loading");
   setTimeout(function(){
   nextOne();
   $(".quote").removeClass("loading"); 
   }, 500);
 });
Ankit Panwar
@coderNoob
Feb 24 2016 11:03
@Blauelf Thanks
CamperBot
@camperbot
Feb 24 2016 11:03
codernoob sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1288 | @blauelf | http://www.freecodecamp.com/blauelf
VosOditDeus
@VosOditDeus
Feb 24 2016 11:04
@Masd925 help a little, but now it get only "".
Alessandro Giordo
@bovas85
Feb 24 2016 11:05
@mohannadsawalhi -2 starts counting from the end starting from -1. If you want the second to last letter it should be different than the one with third to last no?
Bartosz
@CataciD
Feb 24 2016 11:09
@Masd925 last question, did you do this or is it a propper way of doing, generating all possible permutations and then using regexp to filter through them and count them down for result? Or is there a more mathematical way to do it?
sudheerswamy
@sudheerswamy
Feb 24 2016 11:11

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

// Your code above this line
return result;
}

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

help
CamperBot
@camperbot
Feb 24 2016 11:11

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

sudheerswamy
@sudheerswamy
Feb 24 2016 11:11
find word Blanks
CamperBot
@camperbot
Feb 24 2016 11:11

find word blanks

:zero: checkpoint word blanks

Bartosz
@CataciD
Feb 24 2016 11:11

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

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
try this @sudheerswamy
as in formatting
easier to read
sudheerswamy
@sudheerswamy
Feb 24 2016 11:13
@CataciD how to take snapshot of my dashboard/console??
Bartosz
@CataciD
Feb 24 2016 11:13
``` then shift+enter
paste code between
between ```s
and ctrl+enter
formatting
formatting help
William
@apswak
Feb 24 2016 11:15
This message was deleted
Bartosz
@CataciD
Feb 24 2016 11:15
explain format
CamperBot
@camperbot
Feb 24 2016 11:15

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Bartosz
@CataciD
Feb 24 2016 11:16
@kreitzo in the case of 3 arrays there are 3 numbers, in first loop 2 are eliminated but then the third one exists no?
sudheerswamy
@sudheerswamy
Feb 24 2016 11:18

```

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

// Your code above this line
return result;
}

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

Markus Kiili
@Masd925
Feb 24 2016 11:18
@CataciD I generated all possible permutations but checked the validity on the fly.
Bartosz
@CataciD
Feb 24 2016 11:19
validity as if anything repeats in the currently generated one?
sudheerswamy
@sudheerswamy
Feb 24 2016 11:19

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

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Bartosz
@CataciD
Feb 24 2016 11:19
and you pushed them into an outside array?
bravo @sudheerswamy
you got it :p
sudheerswamy
@sudheerswamy
Feb 24 2016 11:20
Thankyou @CataciD helping juniors like us!!!
thanks @CataciD
CamperBot
@camperbot
Feb 24 2016 11:20
sudheerswamy sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:star: 323 | @catacid | http://www.freecodecamp.com/catacid
Bartosz
@CataciD
Feb 24 2016 11:20
i was a junior 2 months ago mate :P
almost finished front end chapter :P
keep going
sudheerswamy
@sudheerswamy
Feb 24 2016 11:21
good going you too..
@CataciD well, any idea about the code i sent ?
William
@apswak
Feb 24 2016 11:22
function unite(arr1, arr2, arr3) {
  var arr = arr1.concat(arr2, arr3);
  var stored = [];
  for(var i in arr){
    if(stored.indexOf(i) >= 0){
      stored.push(arr[i]);
    }
  }
  return stored;
}
unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Anyone know why my if isn't properly checking if they're already in arr before pushing them into stored?
Bartosz
@CataciD
Feb 24 2016 11:23
@kreitzo tell us which task it is or at least what you're trying to do :P
William
@apswak
Feb 24 2016 11:23
@CataciD Sorted Union, in the Intermediate scripting
Markus Kiili
@Masd925
Feb 24 2016 11:23
@CataciD Valid as in no repeating consecutive letters.
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 11:24
@sudheerswamy think of it this way in english grammar what comes after what and just return that way and boom correct answer :smile:
Bartosz
@CataciD
Feb 24 2016 11:24
currently what you're doing is checking if a value exists in "sorted" and if it does you add it to sorted
stored*
Markus Kiili
@Masd925
Feb 24 2016 11:25
@kreitzo for...in should not be used for iterating over array indices.
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 11:25
@kreitzo think what i is and what arr[i] is
Bartosz
@CataciD
Feb 24 2016 11:26
@kreitzo well firstly, from what I understand you DONT KNOW how many arrays are going to be given
so you cant just say there are going to be three
every object has an arguments array of arguments
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 11:27
help arguments
CamperBot
@camperbot
Feb 24 2016 11:27

:point_right: algorithm arguments optional [wiki]

Explanation:

It can be quite complicated to understand what needs to be done. There are always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:

  • It has to add two numbers passed as parameters and return the sum.
  • It has to check if any of the numbers are actual numbers, otherwise return undefined and stop the program right there.
  • It has to check if it has one or two arguments passed. More are ignored.
  • If it has only one argument then it has to return a function that uses that number and expects another one, to then add it.

:pencil: read more about algorithm arguments optional on the FCC Wiki

Bartosz
@CataciD
Feb 24 2016 11:27
thanks @abhishekKumar1
CamperBot
@camperbot
Feb 24 2016 11:27
catacid sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 354 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 11:27
@kreitzo for you what @CataciD is saying
Bartosz
@CataciD
Feb 24 2016 11:27
I'm not versed in the commands :D
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 11:27
@CataciD haha
Bartosz
@CataciD
Feb 24 2016 11:28
any way, when you get those you need to check every first two and make a new one out of them that has the result
then compare the result with every next one and doing the same
so 1+2 result
result compare with 3rd
then you get the result becomes oldresult and 3rd
new result compare with 4th
and so on
William
@apswak
Feb 24 2016 11:28
@CataciD So am I sort of ont he wrong track? Should i restart?
Bartosz
@CataciD
Feb 24 2016 11:29
there's not much you've written there so there wont be any harm
note your steps on a piece of paper
its easier that way
Abhishek Kumar
@abhishekKumar1
Feb 24 2016 11:30
nice @CataciD
Bartosz
@CataciD
Feb 24 2016 11:30
write down things like,
"dont know how many arguments"
"take 1st and 2nd argument(arrays)"
"make result from 1st and 2nd"
"if there's more arguments"
"make new result from result and 3rd"
and so on
it's easier to grasp than trying to remember all of this
William
@apswak
Feb 24 2016 11:31
Ok, thanks @CataciD @abhishekKumar1
CamperBot
@camperbot
Feb 24 2016 11:31
kreitzo sends brownie points to @catacid and @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 324 | @catacid | http://www.freecodecamp.com/catacid
:star: 355 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Bartosz
@CataciD
Feb 24 2016 11:31
also a tip
you can use arguments.length
to check how many arguments you have given :P
so you can make a for loop for how many arguments you have
for(var i=0; i<arguments.length;i++){}
this way it will execute as many times as you have arguments given
so you dont have to worry if someone will give you 2 or 100 arrays
it will still work the same
Andrew Web Dev
@AndrewWebDev
Feb 24 2016 11:32
hi campers
Bartosz
@CataciD
Feb 24 2016 11:33
hi there @AndrewWebDev
Andrew Web Dev
@AndrewWebDev
Feb 24 2016 11:33
how to paste whit gray background my scripts in the chat
Bartosz
@CataciD
Feb 24 2016 11:33
explain format
CamperBot
@camperbot
Feb 24 2016 11:33

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Abhishek Kumar
@abhishekKumar1
Feb 24 2016 11:33
help format
CamperBot
@camperbot
Feb 24 2016 11:33

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Bartosz
@CataciD
Feb 24 2016 11:33
basically shift enter enter(or ctrl+enter)
``` shiftenter
*
Markus Kiili
@Masd925
Feb 24 2016 11:34
@kreitzo If you figure out how to do it with two arrays, using .reduce() method is a good option to solve it on variable number of arrays.
William
@apswak
Feb 24 2016 11:36
@Masd925 I don't see how you can test if there's already something in the array using reduce
Markus Kiili
@Masd925
Feb 24 2016 11:37
@kreitzo Reduce has a starting running value, which is updated when each array element is iterated.
marioserty
@marioserty
Feb 24 2016 11:37

what's wrong in this lookup? " var val= {
"alpha": "Adams",

"bravo": "Boston",

"charlie": "Chicago",

"delta": "Denver",

"echo": "Easy",

"foxtrot": "Frank"

};"

im in "Using Objects for Lookups challange
Markus Kiili
@Masd925
Feb 24 2016 11:38
@kreitzo In this problem it is better not to have a starting value, so reduce starts with the first two arrays.
Bartosz
@CataciD
Feb 24 2016 11:38
reduce checks current value and previous value (you can also use index and array) and executes a function when the condition is met
Markus Kiili
@Masd925
Feb 24 2016 11:39
@kreitzo And the running value is the sorted union of the previous arrays.
@kreitzo The function that is passed into reduce tells reduce how to cook up the next running value from the previous running value and the current array element being iterated.
Ankit Panwar
@coderNoob
Feb 24 2016 11:44
I'm exhausted. This is the closest I've got to validate a US number but still no good
^1?[\s-]?\(?(\d{3})\)?[\s-]?(\d{3})[\s-]?\d{4}$
Help me please.
I need to eliminate the occurrence of a single ( or ) in the string.
Aleksander Gębicki
@Takumar
Feb 24 2016 11:44
@marioserty you overwrite val parameter with your object, you should return value from your object depending on val property. Most often people call this object lookup instead of "val".
Bartosz
@CataciD
Feb 24 2016 11:45
hah @coderNoob i did that like a total caveman
just stacked a bunch of ifs on one another
Ankit Panwar
@coderNoob
Feb 24 2016 11:45
@CataciD that would make it quite easy and lengthy
Bartosz
@CataciD
Feb 24 2016 11:46
@coderNoob "easy" is the part i like
but it's not terrible, works :P
also you could probably do the same with a regexp just by looking at the ifs
though i've added checking length
@coderNoob i divided the number into three subgroups starting from the end, and made 5 ifs
one of them had 2 nested
probably coudl've reduced it :P
Ankit Panwar
@coderNoob
Feb 24 2016 11:53
Maybe I can break it into two regex
try and reduce it and then apply an If and reduce it further
Bartosz
@CataciD
Feb 24 2016 11:54
you probably could
like firstly you could check if it has brackets etc etc etc
Monty
@webdev8183
Feb 24 2016 11:55
ugh this maxvalue challenge is killing me
Bartosz
@CataciD
Feb 24 2016 11:55
post challange ling etc @webdev8183
Aleksander Gębicki
@Takumar
Feb 24 2016 11:56
@marioserty how is your code?
Denis
@DenisDov
Feb 24 2016 11:56
help
CamperBot
@camperbot
Feb 24 2016 11:56

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Denis
@DenisDov
Feb 24 2016 11:57
find stand in line
CamperBot
@camperbot
Feb 24 2016 11:57

find stand in line

:zero: checkpoint stand in line

Bartosz
@CataciD
Feb 24 2016 11:59
Algorithm No repeats please
does this work?
guess not
fml, i cant directly modify the array/string given as a function argument right?
sigursiguros
@sigursiguros
Feb 24 2016 12:01
Hi guys, I'm trying to break my pomodoro clock session into two wells left and right but my CSS doesnt seem to be doing it http://codepen.io/Sigursiguros/pen/QyJaLQ?editors=0010 any clues?
Bartosz
@CataciD
Feb 24 2016 12:04
jesus f christ i was trying to replace values under indexes i a string before splitting it into an array
and it took me a day to figure out why it didnt work
im retarded ; |
Markus Kiili
@Masd925
Feb 24 2016 12:05
@CataciD Because array is an object, a reference to the object is passed into the function and you can mutate it inside the function. Strings are immutable, so you cannot mutate it and also because it is a primitive value, a copy of the string in stored in the function parameter.
Blauelf
@Blauelf
Feb 24 2016 12:07
@sigursiguros I see the code and it works like you told it to. But what do you want?
Bartosz
@CataciD
Feb 24 2016 12:09
@Masd925 yeah I realised tha :P I KNEW IT, but I just read the error and it didn't come to me that's the thing it's yelling about
Pedro Abel Díaz Sánchez
@coderHook
Feb 24 2016 12:10

Is there any problem with the intermediate algorithm scripting "Sorted Union",

It requires 3 entries, but some checks are done with 2, bue when I try them it tells me that arr3 is undefined.

Bartosz
@CataciD
Feb 24 2016 12:10
@Abel1987 read the text again
there's nothing there saying 3 entries
Blauelf
@Blauelf
Feb 24 2016 12:10
@Abel1987 Sounds like you might want to use the arguments object.
sigursiguros
@sigursiguros
Feb 24 2016 12:11
@Blauelf I'm trying to divide the page into left and right
have the clock on the left and the control buttons on the right
but it's not working
Bartosz
@CataciD
Feb 24 2016 12:11
the whole task is built around the idea you don;t know how many arrays there are going to be @Abel1987
Pedro Abel Díaz Sánchez
@coderHook
Feb 24 2016 12:11
@CataciD The function ask for three arguments
Bartosz
@CataciD
Feb 24 2016 12:11
@Abel1987 yours can ask for none, and still work
it has 3 arguments because the example needs 3
and codecamp rather not tell you HOW to do that from the get go
as I said
read the text
sigursiguros
@sigursiguros
Feb 24 2016 12:12
Wblau
@Blauelf and I want the buttons to be on top of each other
Bartosz
@CataciD
Feb 24 2016 12:12
"Write a function that takes two or more arrays and returns a new array"
Pedro Abel Díaz Sánchez
@coderHook
Feb 24 2016 12:12
ummm, when I try to check this:

````function unite(arr1, arr2, arr3) {
//First, we take the first number, check if it is in the diferent arrays, if it is, we delete that position, if not we leave it there and check the next.
var newArr = [];

for (var i = 0; i < arr1.length; i++) {
for (var j = 0; j < arr2.length; j++){
if (arr1[i] == arr2[j]) { arr2.splice(j, 1);}
if (arr1[i] == arr3[j]) { arr3.splice(j, 1);}
}
}

if (arr3 === undefined){ arr1.concat(arr2);}
else if(arr2 === undefined) {arr1.concat(arr3);}
else {arr1.concat(arr2).concat(arr3);}

return arr1;
}

unite([1, 2, 3], [5, 2, 1]);

````
Bartosz
@CataciD
Feb 24 2016 12:12
"takes two or more arrays" @Abel1987
Pedro Abel Díaz Sánchez
@coderHook
Feb 24 2016 12:13
I get arr3 is undefined, it is because the mention to arr3 I have in the for loop?
Bartosz
@CataciD
Feb 24 2016 12:13
yes
partialy
that's why you cant do it this way because you dont know how many arrays you will have
I explained it earlier here
help arguments
CamperBot
@camperbot
Feb 24 2016 12:13

:point_right: algorithm arguments optional [wiki]

Explanation:

It can be quite complicated to understand what needs to be done. There are always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:

  • It has to add two numbers passed as parameters and return the sum.
  • It has to check if any of the numbers are actual numbers, otherwise return undefined and stop the program right there.
  • It has to check if it has one or two arguments passed. More are ignored.
  • If it has only one argument then it has to return a function that uses that number and expects another one, to then add it.

:pencil: read more about algorithm arguments optional on the FCC Wiki

Bartosz
@CataciD
Feb 24 2016 12:13
read this
then try to apply it
Pedro Abel Díaz Sánchez
@coderHook
Feb 24 2016 12:14
ok, Thanks @CataciD
CamperBot
@camperbot
Feb 24 2016 12:14
abel1987 sends brownie points to @catacid :sparkles: :thumbsup: :sparkles:
:star: 325 | @catacid | http://www.freecodecamp.com/catacid
Bartosz
@CataciD
Feb 24 2016 12:15
@Abel1987 you can literally do this in 15 lines code or less
Pedro Abel Díaz Sánchez
@coderHook
Feb 24 2016 12:16
let's see how many pages I get :)
dgjinaj
@dgjinaj
Feb 24 2016 12:16
how can i do this ?? Variable myStr should equal to ("I am a "double quoted" string inside "double quotes"").
Bartosz
@CataciD
Feb 24 2016 12:16
@dgjinaj I explained it earlier, the rule is, if you want to display a " <---
you use \"
to say "this isnt a code " "
so string = "stringvalue"
and if it contains "
string = " stringvalue \" some more \" stringvalue"
the 2nd one will output literally
stringvalue " somemore" stringvalue
dgjinaj
@dgjinaj
Feb 24 2016 12:18
var myStr = "I am a \"double quoted\"string inside \"double quotes\" " ;
Bartosz
@CataciD
Feb 24 2016 12:18
exactly
bravo @dgjinaj
Ankit Panwar
@coderNoob
Feb 24 2016 12:19
@CataciD I did it after 2 days ! I got so excited I had to tell you ! Here it is-
if(str.match(/(\({1})\d{3}(\){1})/g)){
    if(str.match(/^1?[\s-]?\(?(\d{3})\)?[\s-]?(\d{3})[\s-]?\d{4}$/g)){
       return true;
    }
    else
      return false;
  }
  else if(str.match(/^1?[\s-]?\d{3}[\s-]?\d{3}[\s-]?\d{4}$/g))
    return true;
  else
    return false;
Bartosz
@CataciD
Feb 24 2016 12:19
GJ!
but i says an error
it*
Ankit Panwar
@coderNoob
Feb 24 2016 12:19
@CataciD had to use the if :smile:
Bartosz
@CataciD
Feb 24 2016 12:20
do you have "mySTR= " together with the quote?
shouldnt mystr be a variable? @dgjinaj
Blauelf
@Blauelf
Feb 24 2016 12:21
@coderNoob One can easily do that in one regex using the | operator (inside regex, matches either side of it, chainable, works well inside groups) :P
Ankit Panwar
@coderNoob
Feb 24 2016 12:22
@Blauelf It wouldn't eliminate the single occurrence of ( and check for both the () at the same time?
Soumitra Varindra Chakravarti
@soumitrachakravarti
Feb 24 2016 12:23
@coderNoob Which challenge is this?
Blauelf
@Blauelf
Feb 24 2016 12:24
/^(\d{3}|\(\d{3}\))$/ matches "(555)", "555", but not "(555", "555)". (the group in the regex as it will be needed when integrated into the larger regex)
Ankit Panwar
@coderNoob
Feb 24 2016 12:24
@soumitrachakravarti Validate US number
Vantrav
@vantrav
Feb 24 2016 12:25

@Takumar

@vantrav you have to do two things. Create reversed version of your str string and compare it with str.
But first you have to remove unnecessary characters from your string.
@vantrav for sure you reversed strings earlier, because there was such challenge earlier.
The whole difficulty is with removing unnecessary characters.
@vantrav read about regular expressions first to complete this challenge.
explain regexp

function palindrome(str) {
  // Good luck!
  str = str.toLowerCase().replace(/[\W_]/g, '')
  ; var strN = str.toLowerCase().replace(/[\W_]/g,
  '').split('').reverse().join('')
  ; if (str === strN) {
    console.log("Palindrome ");
  } else{
    console.log(“Not Palindrome");
    return false;
  }
return true;
}
palindrome(“do geese see god");

The link to REGEXONE was helpful! Thanks

CamperBot
@camperbot
Feb 24 2016 12:25
vantrav sends brownie points to @takumar and @ and @ and @ :sparkles: :thumbsup: :sparkles:
:star: 2407 | @takumar | http://www.freecodecamp.com/takumar
Blauelf
@Blauelf
Feb 24 2016 12:26
@vantrav Your strN is str.split('').reverse().join(''), no need to repeat the replace.
Aleksander Gębicki
@Takumar
Feb 24 2016 12:26
@vantrav nice to hear :-)
I will give you one more hint. Because you removed characters from str and later you are working on str to create strN you don't have to remove unnecessary characters again.
Oh @Blauelf was faster :-)
Hi @Blauelf
Vantrav
@vantrav
Feb 24 2016 12:27
:smile:
Sure got the idea behind, the replace is a novice repeat :smile:
@Blauelf Thanks :smile:
CamperBot
@camperbot
Feb 24 2016 12:30
vantrav sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1289 | @blauelf | http://www.freecodecamp.com/blauelf
marioserty
@marioserty
Feb 24 2016 12:32
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
how do i access maps?
with bracket notation?
Markus Kiili
@Masd925
Feb 24 2016 12:32
@marioserty Use syntax for accessing property keys: obj[key]
Blauelf
@Blauelf
Feb 24 2016 12:33
You'll need at least some bracket notation, for the keys that have spaces in them.
marioserty
@marioserty
Feb 24 2016 12:35
ium tyin this
var gloveBoxContents = myStorage.car["inside"].glove box
but no success
im trying*
Blauelf
@Blauelf
Feb 24 2016 12:36
You'll need bracket notation for "glove box". You may but do not need to use it for the others.
Markus Kiili
@Masd925
Feb 24 2016 12:37
@marioserty The dot notation only works if the property key string is a valid JS identifier and you write the key after the dot. Bracket notation works with keys that can be arbitrary strings, variables, or expressions.
Theodore P.
@Ierofantis
Feb 24 2016 12:38
hi!Can you tell me where I am wrong here or to guide me somehow?
sigursiguros
@sigursiguros
Feb 24 2016 12:38
@Blauelf how do I get the three buttons to vertical align to the centre of the clock? http://codepen.io/Sigursiguros/pen/QyJaLQ?editors=0100
Theodore P.
@Ierofantis
Feb 24 2016 12:39
function largestOfFour(arr) {
  // You can do this!
  var maximum = -Infinity; 
  for (var i=0; i<arr.length; i++){
    for(var j=0; j,arr.length;i++){

      if (arr[i][j]>maximum)
        maximum=arr[i][j];
    }

  }
  return array;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Bartosz
@CataciD
Feb 24 2016 12:39
@sigursiguros i dunno if this is a java script problem : }