These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Mar 2016
Brendan Kinahan
@BKinahan
Mar 29 2016 00:00
@DavidWeedmark gosh, no. 2 is arr[0].toString()[1] :P
@DavidWeedmark maybe if arr were [[1,2,3],[7,8,9]]
David Weedmark
@DavidWeedmark
Mar 29 2016 00:01
@BKinahan yeah you caught me before I could edit that
Chris Dalton
@manwithgills
Mar 29 2016 00:01
@moigithub Sorry I am so lost. I am not sure if I dont get the arguments, the filter, or both.
I almost think I need to break this down into smaller parts.
Brendan Kinahan
@BKinahan
Mar 29 2016 00:02
@DavidWeedmark not talking about your edit, the number 123 is not an array or string, so its digits can't be accessed by bracket notation
Joseph
@revisualize
Mar 29 2016 00:02
@paulluscastro BOOM! I just solved Boo Who.
Brendan Kinahan
@BKinahan
Mar 29 2016 00:02
boom whom
Moisés Man
@moigithub
Mar 29 2016 00:03
@manwithgills filter accept a function (callback)
and the function/callback can accept 3 arguments (value, index, array) (the last 2 are optional)
http://www.w3schools.com/jsref/jsref_filter.asp
Joseph
@revisualize
Mar 29 2016 00:04
Or, I think I did.
hmm
David Weedmark
@DavidWeedmark
Mar 29 2016 00:05
@BKinahan you're probably better suited to answering her question How did they get arr[1][2]; to equal 6?
Paullus Nava
@paulluscastro
Mar 29 2016 00:06
@revisualize can we chat privately?
anthonyjl92
@anthonyjl92
Mar 29 2016 00:08
function chunkArrayInGroups(arr, size) {
  var finalarr=[]; //final array
  var temp=[]; //temp array to gather elements and push to final array

  for(var i in arr){ //iterate through arr 

    if(i === arr.length-1){ //check if we are at the end
      if(temp.length === size){ //if temp is full
        finalarr.push(temp); //push to final arr
        temp=[]; //reset
        temp.push(arr[i]); //push to temp
        finalarr.push(temp); //push temp to final arr
      }
      else{ //temp is not full
        temp.push(arr[i]); //push to temp
        finalarr.push(temp); //push temp to final arr
      }    
    }

    else if(temp.length!==size){ //if temp is not full
      temp.push(arr[i]); //push on
    }

    else{ //temp is full
      finalarr.push(temp); //push temp to finalarr
      temp=[];//reset temp
      temp.push(arr[i]); //add to temp
    }


  }
  return finalarr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
I'm not sure what I'm doing wrong
Chris Dalton
@manwithgills
Mar 29 2016 00:08
@moigithub Would you mind if we chat privately about this. All the examples I have read make sense but they do not make sense in the context of this problem.
Brendan Kinahan
@BKinahan
Mar 29 2016 00:12
@DavidWeedmark @BritishPandaChick 6 is the 2nd element of the 1st subarray, 0-indexed :D (counting starts at 0, so the 1st thing is at index 0, 2nd is at index 1, etc)
Matt Green
@mattxgreen
Mar 29 2016 00:13
@anthonyjl92 wow, that's a lotta code
@anthonyjl92 you could try a nested for loop
Paullus Nava
@paulluscastro
Mar 29 2016 00:16
@revisualize thank you for your support!
CamperBot
@camperbot
Mar 29 2016 00:16
paulluscastro sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 799 | @revisualize | http://www.freecodecamp.com/revisualize
Matias Vazquez
@matiasv93
Mar 29 2016 00:16
hi, when can help me with js problem?
function lookUp(firstName, prop){
// Only change code below this line
  var i = 0;
  var j = 0;
  while (i < contacts.length){

    if (contacts[i].firstName === firstName){
      if (contacts[i].prop !== ""){
        return contacts[i][prop];
      }else if(contacts[i].indexOf(prop) === -1){
        return "No such property";
      }

    }else {
      i++;
    }

  }

  return "No such contact";

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Exercise missing me, ask the following: "Akira", "address" should return "No such property"
Matt Green
@mattxgreen
Mar 29 2016 00:18
@anthonyjl92
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var answer=[];
  while(arr.length>0){
    answer.push(arr.splice(0,size));
  }
  return answer;
}
kalmont3
@kalmont3
Mar 29 2016 00:19
can someone help me please
???
Sarah Bartley
@BritishPandaChick
Mar 29 2016 00:19
@manwithgills I was just looking at the example code that is given in the section. I think I figured it out though.
Matt Green
@mattxgreen
Mar 29 2016 00:19
@kalmont3 post away
Ramana Venkata
@vramana
Mar 29 2016 00:19
@kalmont3 Post your question so that we can help you.
kalmont3
@kalmont3
Mar 29 2016 00:19
thank you
Moisés Man
@moigithub
Mar 29 2016 00:19
@matiasv93 instead of indexOf probably u wanna use hasOwnProperty method
kalmont3
@kalmont3
Mar 29 2016 00:19
I have a problem with my buttons
forsome reason is not working
Sarah Bartley
@BritishPandaChick
Mar 29 2016 00:20
@DavidWeedmark @BKinahan Thanks for answering my question. I read both of your answers and I understand it better now.
CamperBot
@camperbot
Mar 29 2016 00:20
britishpandachick sends brownie points to @davidweedmark and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 438 | @davidweedmark | http://www.freecodecamp.com/davidweedmark
:star: 1178 | @bkinahan | http://www.freecodecamp.com/bkinahan
kalmont3
@kalmont3
Mar 29 2016 00:20
I have two hours... I am not ashamed to say.
I have two hours working on it
Brendan Kinahan
@BKinahan
Mar 29 2016 00:21
Just to say, "I have a problem with my buttons" is a pretty funny phrase out of context.
Ramana Venkata
@vramana
Mar 29 2016 00:21
@kalmont3 I would have taken more than two hours. Easily. Don't worry about time.
Also you should indent your code. It makes it easier to read it.
kalmont3
@kalmont3
Mar 29 2016 00:22
@vramana thank you
CamperBot
@camperbot
Mar 29 2016 00:22
kalmont3 sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 236 | @vramana | http://www.freecodecamp.com/vramana
kalmont3
@kalmont3
Mar 29 2016 00:22
lol!
Matias Vazquez
@matiasv93
Mar 29 2016 00:23
@moigithub I have already tried and have failed
Kevin Mulligan
@kmulligan
Mar 29 2016 00:23
Anyone in here completed Sorted Union?
Moisés Man
@moigithub
Mar 29 2016 00:24
@matiasv93 also if (contacts[i].prop !== ""){
prop is a variable.. so u CAN NOT use dot notation.. but brackets
Ramana Venkata
@vramana
Mar 29 2016 00:25
@kalmont3 Where are the logic for hiding offline streamers ??
kalmont3
@kalmont3
Mar 29 2016 00:25
I was going to use addclass and replaseClass
Ramana Venkata
@vramana
Mar 29 2016 00:26
I think you have to write a bit more css.
kalmont3
@kalmont3
Mar 29 2016 00:26
I think so too.. but my buttons
lol
Cosimo Bressi
@cbressijr
Mar 29 2016 00:27
Hello all
kalmont3
@kalmont3
Mar 29 2016 00:27
I will work on my css and later on my buttons
Cosimo Bressi
@cbressijr
Mar 29 2016 00:27
Working on Accessing Objects Properties with Variables and have a question to pop at the community.
```
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj [16];   // Change this Line
This message was deleted
Ramana Venkata
@vramana
Mar 29 2016 00:28
@kalmont3 They are working. It changing the class on #trying What is your exact question??
Cosimo Bressi
@cbressijr
Mar 29 2016 00:28
It still does not pass yet also gives me no error message, any thoughts?
kalmont3
@kalmont3
Mar 29 2016 00:29
so why I dont see it?
Ramana Venkata
@vramana
Mar 29 2016 00:29
What are you expecting to see ??
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:29
@cbressijr you set 16 to a variable
kalmont3
@kalmont3
Mar 29 2016 00:29
I dont know how to frame my question.... lol
that I dont see it sort ti
Bill
@W8sconsin
Mar 29 2016 00:30
@cbressijr I think you have a space between testObj and the [
Ramana Venkata
@vramana
Mar 29 2016 00:30
Do you want to see the class on / off on #trying ??
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:30
@cbressijr so it's not really 16 anymore, it's the variable name
kalmont3
@kalmont3
Mar 29 2016 00:30
filtered.... yes
thats what I want
the switch
Ramana Venkata
@vramana
Mar 29 2016 00:30
@kalmont3 Filtering requires more logic. Either you can add more css. or do it via JS
Cosimo Bressi
@cbressijr
Mar 29 2016 00:31
I see. It says the string when I run and I thought I used the bracket notation I just removed the space and still it does not pass. I will clear and see where I went wrong maybe.
kalmont3
@kalmont3
Mar 29 2016 00:31
I am thinking
Bill
@W8sconsin
Mar 29 2016 00:31
@cbressijr pass the variable into array rather than the number 16
João Alves
@JADSN
Mar 29 2016 00:31
var count = 0;

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

  var answer = "";

  if(card >= 2 && card <= 6){
    answer = " Bet";
    count++;
  }
  else if(card >= 7 && card <= 9){
    answer = " Hold";
    count += 0;
  }
  else if (card == 10 || card === "J" || card === "Q" || card === "K" || card === "A"){
    answer = " Hold";
    count--;
  }
  else{
    count += 0;
  }


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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(1);
What's wrong ? - Doubt in Counting Card !!!
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:32
@cbressijr you set 16, the property to a variable.
Ramana Venkata
@vramana
Mar 29 2016 00:32
@kalmont3 Using CSS you have to do something like display: none on the offline streamers.
Cosimo Bressi
@cbressijr
Mar 29 2016 00:32
@Nyarlat-hotep Thanks now though it tells me I failed the part where I have to make sure playerNumber is a number.
CamperBot
@camperbot
Mar 29 2016 00:32
cbressijr sends brownie points to @nyarlat-hotep :sparkles: :thumbsup: :sparkles:
:star: 217 | @nyarlat-hotep | http://www.freecodecamp.com/nyarlat-hotep
kalmont3
@kalmont3
Mar 29 2016 00:33
@vramana thank you
CamperBot
@camperbot
Mar 29 2016 00:33
kalmont3 sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:warning: kalmont3 already gave vramana points
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:33
what's your code look like @cbressijr
Ramana Venkata
@vramana
Mar 29 2016 00:33
@kalmont3 It is just a hint. But you can try to think around it to find a solution.
kalmont3
@kalmont3
Mar 29 2016 00:34
I will
Cosimo Bressi
@cbressijr
Mar 29 2016 00:34
```
Ramana Venkata
@vramana
Mar 29 2016 00:34
Good
Cosimo Bressi
@cbressijr
Mar 29 2016 00:34
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber;       // Change this Line
var player = testObj[16];   // Change this Line
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:34
@cbressijr , you gotta set that property 16 to the variable playerNumber. Then use that variable name in place of 16 in your last line
var playerNumber = 16
Cosimo Bressi
@cbressijr
Mar 29 2016 00:35
Oh! I get it now. Sorry been a long day. Thanks @Nyarlat-hotep @W8sconsin .
CamperBot
@camperbot
Mar 29 2016 00:35
cbressijr sends brownie points to @nyarlat-hotep and @w8sconsin :sparkles: :thumbsup: :sparkles:
:warning: cbressijr already gave nyarlat-hotep points
:star: 228 | @w8sconsin | http://www.freecodecamp.com/w8sconsin
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:36
all good
Matias Vazquez
@matiasv93
Mar 29 2016 00:39
@moigithub also I have already tried, I do not know what to do.
I need only the last point.
Tyler Jones
@tj111710
Mar 29 2016 00:40
requesting help on "return-early-pattern-for-functions"
Brendan Kinahan
@BKinahan
Mar 29 2016 00:41
responding to request. requesting more information about original request.
Tyler Jones
@tj111710
Mar 29 2016 00:42
responding: challenge requires utilizing returns to return different things based on two inputs
Brendan Kinahan
@BKinahan
Mar 29 2016 00:42
yup
Tyler Jones
@tj111710
Mar 29 2016 00:42
I can get one condition satisfied but not the
other
Brendan Kinahan
@BKinahan
Mar 29 2016 00:42
@tj111710 can you post your code so I can take a look?
Tyler Jones
@tj111710
Mar 29 2016 00:43
c+v cause i dont know what im doing

// Setup
function abTest(a, b) {
// Only change code below this line
if(a||b<=0){
return undefined;
}

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

Cosimo Bressi
@cbressijr
Mar 29 2016 00:44
@tj111710 Look at the if(a||b<=0) do you see what's missing?
Tyler Jones
@tj111710
Mar 29 2016 00:44
...not yet. lol
Brendan Kinahan
@BKinahan
Mar 29 2016 00:44
@tj111710 if(a||b<=0) is incorrect. that's equivalent to writing "if a, or if b<=0"
@tj111710 it's not the same as writing "if a<=0, or b<=0" See the difference?
Cosimo Bressi
@cbressijr
Mar 29 2016 00:45
^^^
Tyler Jones
@tj111710
Mar 29 2016 00:45
no. sorry.
Brendan Kinahan
@BKinahan
Mar 29 2016 00:46
@tj111710 things before the || are evaluated separately from things after it, so there's no connection between a and b<=0, so the code doesn't see that as a<=0 at all, but just as a
Tyler Jones
@tj111710
Mar 29 2016 00:46
so. * if ((a||b)<=0) ?
oh.
Brendan Kinahan
@BKinahan
Mar 29 2016 00:47
@tj111710 also, it's fine if a or b are equal to 0, but you should test if they are less than 0, ie negative.
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:47
@tj111710 hint* you are going to repeat yourself
Tyler Jones
@tj111710
Mar 29 2016 00:48
if(a<0 ||b<0)* got it. :)
Brendan Kinahan
@BKinahan
Mar 29 2016 00:48
@tj111710 great :)
Nyarlat-hotep
@Nyarlat-hotep
Mar 29 2016 00:48
total boss move
Tyler Jones
@tj111710
Mar 29 2016 00:48
thanks. :)
Cosimo Bressi
@cbressijr
Mar 29 2016 00:48
^^ Well played
Jeff
@meankraken
Mar 29 2016 00:50
Can anyone please tell me why this is executing the animations out of order?
var firstFunc;
  var secondFunc;
  var thirdFunc;
  firstFunc = $("#firstf").animate({
    left: "+=700px"
  }, 1500);
  $.when(firstFunc).then(function() {
    $("#firstf").fadeOut(function() {
    secondFunc = $("#secondf").animate({
    left: "+=700px"
  }, 1500);
    $("#secondf").fadeOut();
    });

  });
  $.when(secondFunc).then(function() {
  $("#thirdf").animate({left:"+=700px"},1500);
  });
lizzieshipton
@lizzieshipton
Mar 29 2016 00:51
help Mutations
CamperBot
@camperbot
Mar 29 2016 00:51

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
ManBearPigg
@ManBearPigg
Mar 29 2016 00:55
Why won’t my reduce function produce a summation of my array?
function sumFibs(num) {
var myArray = [1,1];
var oddNums = [];
var number;

// Create fibonacci sequence
// Stop creating fibonacci numbers at num
for (var i = 0; i <= num; i++) {
myArray.push(myArray[i+1] + myArray[i]);

// Push odd numbers to oddNums array
if (myArray[i] % 2 !== 0) {
  oddNums.push(myArray[i]);
}
} // End loop.

// Summation of oddNums array.
oddNums.reduce(function(a,b) {
  return a + b;
});
console.log(oddNums); // Should return oddNums sum.
} // End function.

sumFibs(4);
Jacob Hanawalt
@JacobHanawalt
Mar 29 2016 00:57
Hi, could I ask someone a quick question about a specific javascript function?
Brendan Kinahan
@BKinahan
Mar 29 2016 00:58
DO IT
ManBearPigg
@ManBearPigg
Mar 29 2016 00:58
yes ask away @JacobHanawalt
Bill
@W8sconsin
Mar 29 2016 00:58
@JacobHanawalt shoot. I might be able to help
Brendan Kinahan
@BKinahan
Mar 29 2016 00:59
@ManBearPigg you aren't assigning the result of the reduce to any variable or returning it. try one of those :D
ManBearPigg
@ManBearPigg
Mar 29 2016 01:00
@BKinahan I tried assigning to a variable but I got NAN so I wasn’t sure I could do that
function sumFibs(num) {
var myArray = [1,1];
var oddNums = [];
var number;

// Create fibonacci sequence
// Stop creating fibonacci numbers at num
for (var i = 0; i <= num; i++) {
myArray.push(myArray[i+1] + myArray[i]);

// Push odd numbers to oddNums array
if (myArray[i] % 2 !== 0) {
  oddNums.push(myArray[i]);
}
} // End loop.

// Summation of oddNums array.
oddNums.reduce(function(a,b) {
 number = (a + b);
});
 console.log(number);
} // End function.

sumFibs(4);
Jacob Hanawalt
@JacobHanawalt
Mar 29 2016 01:01
Alright! So, if .filter iterates through an array, it must store the index of the value that it's testing somewhere, right? Is there anyway to access the index it is currently on?
*any way
Brendan Kinahan
@BKinahan
Mar 29 2016 01:02
@ManBearPigg no, your reduce function is fine, but oddNums.reduce(... doesn't alter oddNums. Use something like var total = oddNums.reduce(... or just return oddNums.reduce(...
ManBearPigg
@ManBearPigg
Mar 29 2016 01:02
@JacobHanawalt
if (situation in which you want to return value) {
myVar = arr[i]
Brendan Kinahan
@BKinahan
Mar 29 2016 01:02
@JacobHanawalt filter() can take three arguments: the current element, the index of the current element, and the array through which it is iterating.
@JacobHanawalt so your filter's callback can be in the form function (element,index,array){... and you can use each of those parameters as variables within the function.
(of course you can change the names if you wish)
Jacob Hanawalt
@JacobHanawalt
Mar 29 2016 01:05
@BKinahan Oh okay! So those three are automatically passed to the function I create, correct?
Brendan Kinahan
@BKinahan
Mar 29 2016 01:06
@JacobHanawalt Yes, if you declare the function with three named parameters, you can use those parameters within the function. You could alternatively omit the parameters and access them using the arguments object within the function, but that's quite a bit messier and harder to keep track of what you're doing.
Jacob Hanawalt
@JacobHanawalt
Mar 29 2016 01:08
@BKinahan Alright, thanks! That's exactly what I was wondering.
CamperBot
@camperbot
Mar 29 2016 01:08
jacobhanawalt sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1179 | @bkinahan | http://www.freecodecamp.com/bkinahan
Jacob Hanawalt
@JacobHanawalt
Mar 29 2016 01:08
@ManBearPigg Thanks for responding, I think I figured it out! :)
CamperBot
@camperbot
Mar 29 2016 01:08
jacobhanawalt sends brownie points to @manbearpigg :sparkles: :thumbsup: :sparkles:
:star: 296 | @manbearpigg | http://www.freecodecamp.com/manbearpigg
bitgrower
@bitgrower
Mar 29 2016 01:09

@bitgrower I added a loop that goes through all contacts at the start of the function. still no dice

LOL @pgjones72 -- I didn't say it would solve all your code's problems ... just that it was needed ... (which was the question you asked, right?)

qeurago
@qeurago
Mar 29 2016 01:22
hey guys, i just started the algorithms, so i'm doing the 'Reverse a String' exercise, and i have code that reverses the strings and meets the parameters of the exercise, but it's not letting me pass? here's my code https://www.freecodecamp.com/challenges/reverse-a-string#?solution=function%20reverseString(str)%20%7B%0A%20%20return%20str%3B%0A%7D%0A%0Avar%20reverseString%20%3D%20(%22Greetings%20from%20Earth%22)%3B%0Avar%20array%3D%20%5B%5D%3B%0A%0Aarray%20%3D%20reverseString.split('')%3B%0Aarray.reverse()%3B%0Aarray.join('')%3B
jcraan
@jcraan
Mar 29 2016 01:28
hey can I get help with Access Multidimensional Arrays With Indexes
Cosimo Bressi
@cbressijr
Mar 29 2016 01:29
@qeurago For us to view your code you need to use the backtickes 3 times and then paste that link you sent only shows the challenge not your work.
jcraan
@jcraan
Mar 29 2016 01:30
This message was deleted
Cosimo Bressi
@cbressijr
Mar 29 2016 01:30
function reverseString(str) {
  return str;
}

var reverseString = ("Greetings from Earth");
var array= [];

array = reverseString.split('');
array.reverse();
array.join('');
qeurago
@qeurago
Mar 29 2016 01:31
the backtickes? whats that
Shaun Moore
@noirnight
Mar 29 2016 01:31
Having some trouble with Profile Lookup challenge
I feel like I"m really close
Any advice is welcome
//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
  for (var i=0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i][prop]) {
      return contacts[i][prop];
    } else {
      return "No such contact";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "lastName");
Brendan Kinahan
@BKinahan
Mar 29 2016 01:31
@cbressijr the link includes his code
Matt Green
@mattxgreen
Mar 29 2016 01:32
@qeurago the key to the left of the 1, it has the tilde too
Brendan Kinahan
@BKinahan
Mar 29 2016 01:32
@cbressijr it auto-loads it into the editor based on the URL. of course pasting in formatted code is always preferable :)
qeurago
@qeurago
Mar 29 2016 01:32
so i just copy paste the whole code here?

function reverseString(str) {
return str;
}

var reverseString = ("Greetings from Earth");
var array= [];

array = reverseString.split('');
array.reverse();
array.join('');

Brendan Kinahan
@BKinahan
Mar 29 2016 01:32
@noirnight hint: don't decide there's no such contact before you have checked each and every contact ;)
@qeurago your code should go inside the function :)
Cosimo Bressi
@cbressijr
Mar 29 2016 01:33
That works too.
qeurago
@qeurago
Mar 29 2016 01:33
oh right
Matt Green
@mattxgreen
Mar 29 2016 01:33
@cbressijr did you need something with that reverse function?
Cosimo Bressi
@cbressijr
Mar 29 2016 01:34
No but ty @mattxgreen I was trying to show someone how we paste code into the screen here for help.
Shaun Moore
@noirnight
Mar 29 2016 01:34
Thanks, @BKinahan , that gives me an idea, I'll try it now
CamperBot
@camperbot
Mar 29 2016 01:34
noirnight sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1180 | @bkinahan | http://www.freecodecamp.com/bkinahan
qeurago
@qeurago
Mar 29 2016 01:34
i must be missing something very simple because i still don't understand
Brandon Lee
@brandonlee781
Mar 29 2016 01:38
I'm having a little trouble with the Where Art Thou Intermediate Algorithm. So far I have:
function where(collection, source) {
  var arr = [];
  var sKeys = Object.keys(source);
  for (var i = 0;i < collection.length;i++) {
    for (var prop in collection[i]) {
      if (collection[i][prop] === source[prop]) {
        arr.push(collection[i]);
      }
    }
  }
  // What's in a name?
  return arr;
}

where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
SUSHANTH PATWARI
@suzello
Mar 29 2016 01:39
///
function chunkArrayInGroups(arr, size) {
  // Break it up.

  { var x = [];
var z = arr;

  arr = arr.slice(0,size);
 var y = x.push(arr);    
  z = z.slice(size);
  var q = x.push(z);

   return x ;
  }

}


chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
Brandon Lee
@brandonlee781
Mar 29 2016 01:39
But It only checks the first key and pushes the entire object. How do I get it to check every key
SUSHANTH PATWARI
@suzello
Mar 29 2016 01:40
can some one help me with the chunky monkey algorithm
qeurago
@qeurago
Mar 29 2016 01:40
if the output meets all the parameters of the exercise i don't understand why it won't let me pass
SUSHANTH PATWARI
@suzello
Mar 29 2016 01:41
@qeurago your code must be dynamic, it must work for all cases
qeurago
@qeurago
Mar 29 2016 01:41
it does, i put in all of the strings and it reverses all of them exactly like the exercise wants me to
Shaun Moore
@noirnight
Mar 29 2016 01:43
I've got it almost all the way there
4/5 green checks
Just missing something that I can't seem tos ee
This should return No such property
It returns No such contact
//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 found = 0;
  var error = "";
  for (var i=0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i][prop]) {
        found = contacts[i][prop];
      } else {
        error = "No such property";
      }
    } else {
      error = "No such contact";
    }
  }
  if (found === 0) {
    return error;
  } else {
    return found;
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "address");
Marouane
@GacMarouan
Mar 29 2016 01:44
@qeurago you did not put your split reverse an join in the right place
your function should do the job not outside the func
qeurago
@qeurago
Mar 29 2016 01:45
i put it in the function and it doesn't even return a string
Marouane
@GacMarouan
Mar 29 2016 01:47
because first thing you need to store your split in a variable then return it and see what happen
try to understand each action first
Shaun Moore
@noirnight
Mar 29 2016 01:52
Any ideas where I'm going wrong?
I think the second else is triggering after the first one does\
In my for loop
Arjun Narayanan
@anarayanan86
Mar 29 2016 01:54
Hello World, I'm working through FCC and just discovered the FCC chatrooms
CamperBot
@camperbot
Mar 29 2016 01:54

welcome to FreeCodeCamp @anarayanan86!

Shaun Moore
@noirnight
Mar 29 2016 01:57
Do you think I need to do a different loop type, like a while loop?
I'm unsure what to try next
@BKinahan got me near the solution, but I'm still one step away
Cosimo Bressi
@cbressijr
Mar 29 2016 01:59
@anarayanan86 Welcome
Marouane
@GacMarouan
Mar 29 2016 02:00
@noirnight I think you will need to remove the last if else statement and just return found
Shaun Moore
@noirnight
Mar 29 2016 02:00
But it needs me to return a message for the errors too, @GacMarouan
If I removed that last statement, it wouldn't return any error messages
Marouane
@GacMarouan
Mar 29 2016 02:01
send me the link that i can test
Shaun Moore
@noirnight
Mar 29 2016 02:01
I'm unsure what you mean
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUp(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20var%20found%20%3D%200%3B%0A%20%20var%20error%20%3D%20%22%22%3B%0A%20%20for%20(var%20i%3D0%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%20firstName)%20%7B%0A%20%20%20%20%20%20if%20(contacts%5Bi%5D%5Bprop%5D)%20%7B%0A%20%20%20%20%20%20%20%20found%20%3D%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20error%20%3D%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20error%20%3D%20%22No%20such%20contact%22%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20if%20(found%20%3D%3D%3D%200)%20%7B%0A%20%20%20%20return%20error%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20return%20found%3B%0A%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUp(%22Akira%22%2C%20%22address%22)%3B%0A
This link?
Marouane
@GacMarouan
Mar 29 2016 02:02
yes
ManBearPigg
@ManBearPigg
Mar 29 2016 02:05
nice link
kwal0203
@kwal0203
Mar 29 2016 02:06
Anybody know how to pass the "Local Scope and Functions" test?
I declared a local variable in the function and removed the console.log line but it does not pass
ManBearPigg
@ManBearPigg
Mar 29 2016 02:06
This message was deleted
Not sure why half that is looking like comments
Ramana Venkata
@vramana
Mar 29 2016 02:08
@ManBearPigg Delete it and repaste.
Shaun Moore
@noirnight
Mar 29 2016 02:08
Looks like you're missing a second ) after (a,b)
ManBearPigg
@ManBearPigg
Mar 29 2016 02:09
function sumFibs(num) {
var myArray = [1,1];
// Create fibonacci sequence
// Stop creating fibonacci numbers at num
// Push odd numbers to oddNums array
for (var i = 0; i <= myArray.length; i++) {

if (myArray[i+1] + myArray[i] % 2 !== 0 && myArray[i+1] + myArray[i] <= num) {
myArray.push(myArray[i+1] + myArray[i]);
}
} // End loop.
console.log(myArray);
// Summation of oddNums array.
return myArray.reduce(function(a,b) {
  return a + b;
});
} // End function.

sumFibs(1000);
Shaun Moore
@noirnight
Mar 29 2016 02:09
You have - reduce(function(a,b) - shouldn't it be reduce(function(a,b))
ManBearPigg
@ManBearPigg
Mar 29 2016 02:10
});
Ramana Venkata
@vramana
Mar 29 2016 02:10
@noirnight His reduce is okay.
ManBearPigg
@ManBearPigg
Mar 29 2016 02:10
I close that out below the return a + b. Is that wrong?
I followed the documentation
Shaun Moore
@noirnight
Mar 29 2016 02:10
Ah I see it now
ManBearPigg
@ManBearPigg
Mar 29 2016 02:11
I wonder why % 2 !==0 isn’t catching even numbers?
Looks perfect to me
Marouane
@GacMarouan
Mar 29 2016 02:12
@noirnight your variable error in line 39 is been erased by the next lines try to just return "No such property"; and you'll see
Palakurthi Durga Kiran Kumar
@durgakiran
Mar 29 2016 02:12
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
ia ma not getting this
Ramana Venkata
@vramana
Mar 29 2016 02:13
@ManBearPigg Try adding a few paranthesis like this ((myArray[i+1] + myArray[i]) % 2 !== 0)
Shaun Moore
@noirnight
Mar 29 2016 02:13
I figure that is the case @GacMarouan , I'm just unsure how to fix it
I deleted it and see it says no such property, but then the no such contact case does not work
ManBearPigg
@ManBearPigg
Mar 29 2016 02:13
@vramana tried that,will try again
Ramana Venkata
@vramana
Mar 29 2016 02:14
@ManBearPigg Why are you using myArray.length in for-loop?? That is not the right way to go.
ManBearPigg
@ManBearPigg
Mar 29 2016 02:14
@vraman well it’s capped at 1000 anyways
Ramana Venkata
@vramana
Mar 29 2016 02:15
And you are using <= which again is like a code smell.
ManBearPigg
@ManBearPigg
Mar 29 2016 02:15
@vramana so myArray.length is like infinity, but its capped at 1000. The cap at 1000 actually works. Whats a code smell
Marouane
@GacMarouan
Mar 29 2016 02:15
@noirnight for me it did work, best practice just return the answers dont store them in variables
ManBearPigg
@ManBearPigg
Mar 29 2016 02:16
@vramana The =< num part actually works. Its the first half that doesn’t work, for some reason
Ramana Venkata
@vramana
Mar 29 2016 02:16
@ManBearPigg An Indication that program isn't written correctly or may do some unexpected things.
Shaun Moore
@noirnight
Mar 29 2016 02:17
@GacMarouan that is where I went wrong in the first place, just returning the answers overwrote them
Ramana Venkata
@vramana
Mar 29 2016 02:17
@ManBearPigg Many solutions work but only some solutions are easy to reason about and elegant. Your approach is not easy to reason.
It is very easy to run into an infinte loop when you use things like this.
Travis
@skoolboi434
Mar 29 2016 02:18

working on the returning Boolean Values from functions and I have one check mark to complete, not sure what I am missing.

function isLess(a, b) {
// Fix this code
return a === b;

}

// Change these values to test
isLess(15,10);

Brandon Lee
@brandonlee781
Mar 29 2016 02:21
@skoolboi434 Your code right now is only returning true or false based on whether A is exactly the same as B. You want to use < and > to compare them and if statements to determine what to do based on how they compare.
Shaun Moore
@noirnight
Mar 29 2016 02:21
For instance, @GacMarouan , I had this before:
  for (var i=0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i][prop]) {
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    } else {
      return "No such contact";
    }
  }
I think once it hits the first return, it seems to stop there
This works for the first record only in other words
Nickolas Gettel
@nickolaskg
Mar 29 2016 02:23
anyone know where the learnyounode documentation is located? the file:// link to documentation within the learnyounode sections go no where for me. do i need to install learnyounode on my pc just for the docs?
Travis
@skoolboi434
Mar 29 2016 02:23

@brandonlee781 the instructions were to remove the if/else statement so would it be

function isLess(a,b) {}

@brandonlee781 the instructions were to remove the if/else statement so would it be

function isLess(a,b) {
return a > b;
}

Brandon Lee
@brandonlee781
Mar 29 2016 02:24
@brandonlee781 Actually, I'm very sorry, I just read that challenge. You want to do something similar to using === but you still want to compare them, not check if they're the same.
Ramana Venkata
@vramana
Mar 29 2016 02:24
@nickolaskg What part documentation are you looking for ??
Brandon Lee
@brandonlee781
Mar 29 2016 02:24
@skoolboi434 You're very close, but you're checking if a is less than b.
Nickolas Gettel
@nickolaskg
Mar 29 2016 02:25
any of it
i've been through most of learnyounode with no access to any documentation
keep getting link like this file:///home/ubuntu/.nvm/versions/node/v4.4.0/lib/node_modules/learnyounod
e/docs/through2-map.html
local links that dont work
Shaun Moore
@noirnight
Mar 29 2016 02:26
I got it by adding a third variable
Ramana Venkata
@vramana
Mar 29 2016 02:28
@nickolaskg Why not checkout them here https://github.com/workshopper/learnyounode ?? Or do you want offline only??
Travis
@skoolboi434
Mar 29 2016 02:28

@brandonlee781 i got it

function isLess(a,b) {
return a < b && b > a;

}

Brandon Lee
@brandonlee781
Mar 29 2016 02:28
a < b is the same as b > a, but hey at least you're correct
Nickolas Gettel
@nickolaskg
Mar 29 2016 02:29
@vramana there isnt any documentation in there that i've seen
Ramana Venkata
@vramana
Mar 29 2016 02:31
Do you want documentation about node or learnyounode ??
Nickolas Gettel
@nickolaskg
Mar 29 2016 02:33
ah , i didnt go through every folder I guess
learnyounode. i can't understand why they don't just put direct links to the documentation instead of local links, especially when the course is suggested to use c9
looks like there is only 3 items in the docs too. man this wasnt put together very well.
Ramana Venkata
@vramana
Mar 29 2016 02:35
@nickolaskg What exactly are you looking for? I still didn't understand.
Nickolas Gettel
@nickolaskg
Mar 29 2016 02:37
@vramana when you go through the learnyounode course, each section has different topics, like fs, bl, http, net etc... those topics have local links to documentation on each subject. i'm trying to find a repository for all the docs that the course links to
Ramana Venkata
@vramana
Mar 29 2016 02:38
Then you are searching for documentation of node rather than learnyounode.
Nickolas Gettel
@nickolaskg
Mar 29 2016 02:39
@vramana thanks, sorry for not communicating it very well
CamperBot
@camperbot
Mar 29 2016 02:39
nickolaskg sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 237 | @vramana | http://www.freecodecamp.com/vramana
Ramana Venkata
@vramana
Mar 29 2016 02:39
@nickolaskg No problem
Brandon
@Daxo
Mar 29 2016 02:41

Hey everyone! Working on the Check for Palindromes and I can't figure out why my replace function isn't working...

function palindrome(str) {
  // convert to lowercase

  var lowerCaseStr = "";

  lowerCaseStr = str.toLowerCase; 

  // use .replace to remove non-alalphanumerics

  var cleanedStr = lowerCaseStr.replace(/([^\w]*)/, "");

Any reason it would return "TypeError: lowerCaseStr.replace is not a function" ?

Brandon Lee
@brandonlee781
Mar 29 2016 02:43
@bleafman I don't know if it will solve the issue but you're missing () after .toLowerCase
devonwilson1
@devonwilson1
Mar 29 2016 02:47
can someone help me with the counting cards assignemnt
please
L
@lprufer
Mar 29 2016 02:51
@devonwilson1 what are you stuck on?
Brandon Lee
@brandonlee781
Mar 29 2016 02:55
So I'm getting stuck on the Where Art Thou Intermediate Algorithm, so far I have:
function where(collection, source) {
  var arr = [];
  var sKeys = Object.keys(source);
  for (var i = 0;i<collection.length;i++) {
    for (var j = 0;j<sKeys.length;j++) {
      if (collection[i].hasOwnProperty(sKeys[j]) && collection[i][sKeys[j]] === source[sKeys[j]]) {
        arr.push(collection[i]);
      }
    }
  }
  return arr;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
But it returns any object that matches even a single key in the second argument. How do I go about only passing an object if it matches all the arguments
?
Sorry, if it matches all of the keys in the second argument.
devonwilson1
@devonwilson1
Mar 29 2016 03:01
i have just begun and i was using an if and confused really on how to start this what i got so far
Coy Sanders
@coymeetsworld
Mar 29 2016 03:13
@brandonlee781 you're just checking to see if the property is there, not if the property is equal to the source property
you need another conditional statement
devonwilson1
@devonwilson1
Mar 29 2016 03:14

var count = 0;

function cc(card) {
// Only change code below this line
if(card>=2 || card<=6)
return "+1";

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

anyone know how to direct me I'm lost at beginning of the counting cards challenge
Brandon Lee
@brandonlee781
Mar 29 2016 03:15
@coymeetsworld That's what "&& collection[i][sKeys[j]] === source[sKeys[j]]" is checking. Which it does fine. The issue is on other tests where the second argument might have 2 properties. If any one of them pass, the object is pushed. But I need all arguments to be the same, other wise it shouldn't pass. And I can't figure out how to do that.
Coy Sanders
@coymeetsworld
Mar 29 2016 03:16
oh i didn't scroll i didn't see that part hold on
Brandon Lee
@brandonlee781
Mar 29 2016 03:16
Not a problem
Coy Sanders
@coymeetsworld
Mar 29 2016 03:17
@devonwilson1 you don't want to return "+1", also remember when you run a return statement nothing below will run
you want to incremenet the count variable
L
@lprufer
Mar 29 2016 03:19
@devonwilson1 || means "or" so the first if statement is saying: if card is >= 2 "or" <=6 , ad one to the count.
Coy Sanders
@coymeetsworld
Mar 29 2016 03:19
yeah also that if statement needs reworking
L
@lprufer
Mar 29 2016 03:19
@devonwilson1 You want both of those conditions to be met to +1
Coy Sanders
@coymeetsworld
Mar 29 2016 03:24
yeah so @brandonlee781 the problem is you're pushing the value too soon
like you said if your source has more than one thing to check you need to iterate through it first
devonwilson1
@devonwilson1
Mar 29 2016 03:25
I'm sorry i feel dumb but i am very confused i am not sure if it is because i know nothing about cards or understanding of the assignment is extremely limited but lost
Travis
@skoolboi434
Mar 29 2016 03:25

Can someone help with the accessing objects properties with variables

I have the player variable working but playerNumber I can't figure out
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj2;
var player = testObj[16];

devonwilson1
@devonwilson1
Mar 29 2016 03:25
not sure exactly where to start so am i going to form an if ..else if statement for each possible output?
Travis
@skoolboi434
Mar 29 2016 03:25
var playerNumber = testObj2
devonwilson1
@devonwilson1
Mar 29 2016 03:26
like do i have to specify all card values or just the three ranges?
Islam Ibakaev
@dagman
Mar 29 2016 03:26
Im trying to make my quote app using angular .js . But it seems someyhing works wrong.
the api response doesnt wont to get into view. http://codepen.io/dagman/pen/qZXWeR?editors=1010
Coy Sanders
@coymeetsworld
Mar 29 2016 03:27
the problem with the if/else statement @devonwilson1 is that you can be given either a string (letter) or a number
so you can't really do a range
try using a case/switch statement
Brandon Lee
@brandonlee781
Mar 29 2016 03:28
@coymeetsworld Thank you so much. I added a variable with a boolean value. Changed the second for loop to change boolean to false if it ever hit an unmatching key and would only push the object if the variable was true.
CamperBot
@camperbot
Mar 29 2016 03:28
brandonlee781 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 412 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Mar 29 2016 03:28
thats exactly what I did @brandonlee781 :thumbsup:
not sure if a better way or not but that worked for me
Brandon Lee
@brandonlee781
Mar 29 2016 03:29
@coymeetsworld It's not pretty, but it works.
devonwilson1
@devonwilson1
Mar 29 2016 03:31
okay so a switch statement works?
Travis
@skoolboi434
Mar 29 2016 03:31
for the accessing objects properties i used var playerNumber = testObj.Montana; using the bracket notation for the player variable works just not the dot notation
devonwilson1
@devonwilson1
Mar 29 2016 03:31
so what would my variable i target be count? or function name?
Travis
@skoolboi434
Mar 29 2016 03:32
@devonwilson1 here's a hint use a switch and each case would represent a card in the deck
devonwilson1
@devonwilson1
Mar 29 2016 03:34
thank you @skoolboi434
CamperBot
@camperbot
Mar 29 2016 03:34
devonwilson1 sends brownie points to @skoolboi434 :sparkles: :thumbsup: :sparkles:
:star: 209 | @skoolboi434 | http://www.freecodecamp.com/skoolboi434
devonwilson1
@devonwilson1
Mar 29 2016 03:35
thank you @brandonlee781
CamperBot
@camperbot
Mar 29 2016 03:35
devonwilson1 sends brownie points to @brandonlee781 :sparkles: :thumbsup: :sparkles:
:star: 291 | @brandonlee781 | http://www.freecodecamp.com/brandonlee781
devonwilson1
@devonwilson1
Mar 29 2016 03:35
thank you @coymeetsworld
CamperBot
@camperbot
Mar 29 2016 03:35
devonwilson1 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 413 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Mar 29 2016 03:35
yeah case/switch should work out better @devonwilson1
devonwilson1
@devonwilson1
Mar 29 2016 03:35
so at @skoolboi434 does that mean i would break in between three different ranges?
with a +1 a 0 and a -1
those three ranges? break in between them three
Will
@wroetzheim
Mar 29 2016 03:36
@skoolboi434 is "Montana" the testObj property?
Travis
@skoolboi434
Mar 29 2016 03:38

@devonwilson1 you're gonna have a break between 6 cases example:

switch (val) {
case:1
case:2
}

devonwilson1
@devonwilson1
Mar 29 2016 03:38
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
break;
case 7:
case 8:
case 9:
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
break
got that so far
now i need to know what to put for my "answer"
Travis
@skoolboi434
Mar 29 2016 03:38
@devonwilson1 very very close
@wroetzheim yup
@devonwilson1 theres going to be a count property for each one that has a break
@wroetzheim it says playerNumber should use dot notation so I tried var playerNumber = testObj.Montana
Will
@wroetzheim
Mar 29 2016 03:42
shouldn't it be something like testObj.playerName?
oh
devonwilson1
@devonwilson1
Mar 29 2016 03:44
check this out

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

}

return "Change Me";

the answer is remaining white and not glowing blue as usual idk why
Will
@wroetzheim
Mar 29 2016 03:45
@skoolboi434 is the lesson "accessing object properties with variables?
Travis
@skoolboi434
Mar 29 2016 03:47
@wroetzheim yup
wroetzheim think if you were playing blackjack, if you got a 2 card you'd prolly say hit me, so instead of answer, try count +=
@wroetzheim also your cards need to be in order from low to high
Will
@wroetzheim
Mar 29 2016 03:48
they want you to use a variable, playerNumber, and use that variable to access the name value paired with the number 16
devonwilson1
@devonwilson1
Mar 29 2016 03:50
anyone gotta any pointers?
Travis
@skoolboi434
Mar 29 2016 03:51
that's where I'm getting lost because they have playerNumber = testObj
Brandon
@Daxo
Mar 29 2016 03:51
@brandonlee781 that actually looks like it helped! Thanks +1:
CamperBot
@camperbot
Mar 29 2016 03:51
bleafman sends brownie points to @brandonlee781 :sparkles: :thumbsup: :sparkles:
:star: 292 | @brandonlee781 | http://www.freecodecamp.com/brandonlee781
Will
@wroetzheim
Mar 29 2016 03:52
you can access it with something like myObj[variable]
Travis
@skoolboi434
Mar 29 2016 03:52

@devonwilson1

switch () {
case2:
case3:
case4:
case5:
case6:
count += 1,
}

@wroetzheim testObj[Montana] doesn't work
Will
@wroetzheim
Mar 29 2016 03:55
I'm just learning, but it looks like you can access objects in JS either by dot notation ( myObj.hereIsAProperty ) or array syntax ( myObj["hereIsAProperty"] ) - it seems like you can't use dot notation to pass numbers and you don't quote variables in the array syntax
@skoolboi434 Montana is the value you are trying to get back - you need to pass it the playerNumber associated with that player so it can return the player name
Matt Green
@mattxgreen
Mar 29 2016 03:56
Anyone care to offer feedback for this solution on "Where art thou"?
function where(collection, source) {
  return collection.reduce(function(p,c){
    var keyMatch=0;
    for(var key in source){
      if( c[key] === source[key] ){keyMatch++;}
      if( keyMatch === Object.keys(source).length ){p.push(c);}
    }
    return p;
  },[]);
}
Travis
@skoolboi434
Mar 29 2016 03:57
i found a solution @wroetzheim thanks for all your help having figured out how to give brownie points
CamperBot
@camperbot
Mar 29 2016 03:57
skoolboi434 sends brownie points to @wroetzheim :sparkles: :thumbsup: :sparkles:
:star: 117 | @wroetzheim | http://www.freecodecamp.com/wroetzheim
Will
@wroetzheim
Mar 29 2016 04:00
np, I did that one just earlier :)
Islam Ibakaev
@dagman
Mar 29 2016 04:19
finally made random quote machine using Angular js. What do you think guys? http://codepen.io/dagman/pen/qZXWeR?editors=1010
Matt Green
@mattxgreen
Mar 29 2016 04:24
@dagman Looks nice. You could add a bit of flare with some transitions/animations. Not that mine is great, but you can take a look.
http://codepen.io/mattgreen/pen/XdKgar?editors=0010
@dagman And angular does have jquery lite built-in(fyi)
Islam Ibakaev
@dagman
Mar 29 2016 04:27
@mattxgreen very nice transitions
Matt Green
@mattxgreen
Mar 29 2016 04:28
Thanks @dagman
CamperBot
@camperbot
Mar 29 2016 04:28
mattxgreen sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:star: 366 | @dagman | http://www.freecodecamp.com/dagman
Matt Green
@mattxgreen
Mar 29 2016 04:30
@dagman I limited the ranges on the background colors to avoid too dark, and too bright (and ugly)
Jiimms
@jiimms
Mar 29 2016 04:40
@mattxgreen wonderful page. I had a similar idea for Indian ChucK Norris but wasnt too sure, now i am inspired :smile:
Matt Green
@mattxgreen
Mar 29 2016 04:44
@jiimms thanks
CamperBot
@camperbot
Mar 29 2016 04:44
mattxgreen sends brownie points to @jiimms :sparkles: :thumbsup: :sparkles:
:star: 291 | @jiimms | http://www.freecodecamp.com/jiimms
Markus Kiili
@Masd925
Mar 29 2016 04:45
@mattxgreen You could avoid all the variables and loop by using .filter() and .every() methods.
Matt Green
@mattxgreen
Mar 29 2016 04:48
This message was deleted
CamperBot
@camperbot
Mar 29 2016 04:48
mattxgreen sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1249 | @masd925 | http://www.freecodecamp.com/masd925
Matt Green
@mattxgreen
Mar 29 2016 04:50
@Masd925 or are you referring to my where art thou?
Markus Kiili
@Masd925
Mar 29 2016 04:50
@mattxgreen Yes.
Matt Green
@mattxgreen
Mar 29 2016 04:51
@Masd925 yeah, I was trying to figure out how to get rid of keyMatch
@Masd925 you got an example for me?
Markus Kiili
@Masd925
Mar 29 2016 04:53
@mattxgreen I can post the filter/every solution?
Matt Green
@mattxgreen
Mar 29 2016 04:54
great.
Markus Kiili
@Masd925
Mar 29 2016 04:54
function where(collection, source) {
  var keyList = Object.keys(source);
  return collection.filter(function(obj){
    return keyList.every(function(key){
      return obj[key]===source[key];
    });
  });
}
Matt Green
@mattxgreen
Mar 29 2016 04:55
Thanks I'll have to figure out how that works. I don't see it immediately
Blair Yacishyn
@YacYac
Mar 29 2016 04:57
I'm working on Arguments Optional. I'm getting the results I'm looking for from console.log, but the tests are failing. Not sure what I'm doing wrong.
function add() {
    var args = (arguments.length === 1?[arguments[0]]:Array.apply(null, arguments));

    for (var i = 0; i < args.length; i++) {
    if (Number.isInteger(args[i]) === false) {
        console.log(undefined);
        return undefined;
    }
    }

    if (args.length !== 2) {
    return function(newArgs){
        args.push(newArgs);
        add(args[0],args[1]);
    };
    }

    var num = args.reduce(function(previousValue, currentValue, currentIndex, array) {
      return previousValue + currentValue;
    });

    console.log(num);
    return num;
}
Cam
@CamMakoJ
Mar 29 2016 05:01
help Diff Two Arrays
CamperBot
@camperbot
Mar 29 2016 05:01

:point_right: algorithm diff two arrays [wiki]

Explanation:

Check two arrays and return a new array that contains only the items that are not in either of the original arrays.

:pencil: read more about algorithm diff two arrays on the FCC Wiki

Cam
@CamMakoJ
Mar 29 2016 05:02
wondering if i could get some help on the 'Diff Two Arrays'
algorithm
Matt Green
@mattxgreen
Mar 29 2016 05:03
@CamMakoJ What did you have in mind?
@CamMakoJ (an example answer || help w your code || etc)
Cam
@CamMakoJ
Mar 29 2016 05:04
@mattxgreen help with code
im stuck here
Matt Green
@mattxgreen
Mar 29 2016 05:04
@CamMakoJ post it
Cam
@CamMakoJ
Mar 29 2016 05:04

function diff(arr1, arr2) {
var newArr = [];
var totalArray = arr1.concat(arr2);
// Same, same; but different.

function filterCB(element, index, array) {
var test = array.slice(index, index + 1)
test = test.toString();
console.log(arr1)
if (array.indexOf(test) === -1) {
console.log(true)
return true;
} else {
console.log(false)
return false;
}
return;
}
newArr = totalArray.filter(filterCB)
console.log(newArr)
}

my indexOf keeps returing -1
Markus Kiili
@Masd925
Mar 29 2016 05:05
@YacYac add(2)(3) returns undefined, and should be returning 5.
Cam
@CamMakoJ
Mar 29 2016 05:06

'''
function diff(arr1, arr2) {
var newArr = [];
var totalArray = arr1.concat(arr2);
// Same, same; but different.

function filterCB(element, index, array) {
var test = array.slice(index, index + 1)
test = test.toString();
console.log(arr1)
if (array.indexOf(test) === -1) {
console.log(true)
return true;
} else {
console.log(false)
return false;
}
return;
}
newArr = totalArray.filter(filterCB)
console.log(newArr)
}
'''

CamperBot
@camperbot
Mar 29 2016 05:06
:bulb: to format code use backticks! ``` more info
Cam
@CamMakoJ
Mar 29 2016 05:07
@mattxgreen
function diff(arr1, arr2) {
  var newArr = [];
  var totalArray = arr1.concat(arr2);
  // Same, same; but different.


  function filterCB(element, index, array) {
    var test = array.slice(index, index + 1)
    test = test.toString();
    console.log(arr1)
    if (array.indexOf(test) === -1) {
      console.log(true)
      return true;
    } else {
      console.log(false)
      return false;
    }
    return;
  }
  newArr = totalArray.filter(filterCB)
  console.log(newArr)
}
Matt Green
@mattxgreen
Mar 29 2016 05:14
@CamMakoJ So, this is very confusing... you are slicing array for the test var, then you are checking array for the indexOf() test. Why would that ever be false?
Cam
@CamMakoJ
Mar 29 2016 05:16
@mattxgreen i agree... but it still is returning -1 every time which has me confused
it should return a value @mattxgreen
Matt Green
@mattxgreen
Mar 29 2016 05:17
and an aside, these are the same:
var test = array.slice(index, index + 1).toString();
///
var test = array.slice(index, index + 1);
        test = test.toString();
Cam
@CamMakoJ
Mar 29 2016 05:17
@mattxgreen ahh kk thanks
CamperBot
@camperbot
Mar 29 2016 05:17
cammakoj sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 401 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Matt Green
@mattxgreen
Mar 29 2016 05:18
@CamMakoJ Why are you combining the arrays, then trying to find differences? explain your approach please
Cam
@CamMakoJ
Mar 29 2016 05:18
@mattxgreen i see what you mean, with the 'test' being queried in the array, as it is of course in the array, so i ahve fixed that... but am still only getting -1 from the indexOf()
@mattxgreen so combining the arrays then looking for duplicates. if the indexOf(test) returns a value other then -1 then the value should return false and be filtered out of the newArr
Matt Green
@mattxgreen
Mar 29 2016 05:20
Seems viable as long as you can also omit the value you are iterating on
Cam
@CamMakoJ
Mar 29 2016 05:21
@mattxgreen yeah thats what i think i have set up now... but for some reason my indexOf() is always returning -1
Matt Green
@mattxgreen
Mar 29 2016 05:22
you got revised code?
Cam
@CamMakoJ
Mar 29 2016 05:22
@mattxgreen
function diff(arr1, arr2) {
  var newArr = [];
  var totalArray = arr1.concat(arr2);


  function filterCB(element, index, array) {
    var test = array.slice(index, index + 1);
    if (arr1.indexOf(test) == -1) {
      console.log("arr1 = no match");
      return true;
    } else if (arr2.indexOf(test) == -1) {
      console.log("arr2 = no match");
      return true;
    } else {
      return false;
    }
  }
  newArr = totalArray.filter(filterCB)
  console.log(newArr)
}
diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Matt Green
@mattxgreen
Mar 29 2016 05:23
@CamMakoJ so, I think you would look for indexOf(element) and then make sure it is not index, nor -1
@CamMakoJ soud correct?
Cam
@CamMakoJ
Mar 29 2016 05:24
@mattxgreen thats a good point i think since now i am looking at the two arrays seperately here, i dont need to slice out the piece i am after
Matt Green
@mattxgreen
Mar 29 2016 05:27
I think you can abandon your test var, and refactor
Let me know what you come up w
Cam
@CamMakoJ
Mar 29 2016 05:28
@mattxgreen
function diff(arr1, arr2) {
  var newArr = [];
  var totalArray = arr1.concat(arr2);


  function filterCB(element, index, array) {
    if (arr1.indexOf(element) == -1) {
      console.log("arr1 = no match");
      return true;
    } else if (arr2.indexOf(element) == -1) {
      console.log("arr2 = no match");
      return true;
    } else {
      return false;
    }
  }
  newArr = totalArray.filter(filterCB);
  console.log(newArr);
  return newArr;
}
diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
@mattxgreen and that does it :) thanks!
CamperBot
@camperbot
Mar 29 2016 05:28
cammakoj sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:warning: cammakoj already gave mattxgreen points
Matt Green
@mattxgreen
Mar 29 2016 05:29
@CamMakoJ you can refactor further
Cam
@CamMakoJ
Mar 29 2016 05:31
@mattxgreen what you mean?
Matt Green
@mattxgreen
Mar 29 2016 05:32
@CamMakoJ I think this is the same:
function diff(arr1, arr2) {
  var newArr = [];
  var totalArray = arr1.concat(arr2);

  function filterCB(element, index, array) {
    return (arr1.indexOf(element) == -1) || (arr2.indexOf(element) == -1);
  }
  newArr = totalArray.filter(filterCB);
  return newArr;
}
I just refactored your callback
@CamMakoJ comprender?
Cam
@CamMakoJ
Mar 29 2016 05:37
@mattxgreen yeah that makes sense
@mattxgreen is their an advantage? speed?
Matt Green
@mattxgreen
Mar 29 2016 05:38
probably slightly... you could test at jsperf.com
Readability IMO
clean/lean code
download time
It nearly halved your code length (although I guess part of it was console.logs)
Matt Green
@mattxgreen
Mar 29 2016 05:43
@CamMakoJ your code refactored:
function diff(arr1, arr2) {
    return arr1.concat(arr2).filter(filterCB);
    function filterCB(element, index, array) {
        return (arr1.indexOf(element) == -1) || (arr2.indexOf(element) == -1);
    }
}
Cam
@CamMakoJ
Mar 29 2016 05:45
@mattxgreen yeah that makes sense, way shorter
Matt Green
@mattxgreen
Mar 29 2016 05:46
You prob get some minor performance improvements, and less memory usage. For such a small amount of code it's likely insignificant, but the bigger your apps get, the more it adds up.
Abdullah Hoosen
@abdullahhoosen
Mar 29 2016 06:25
Hello, can someone explain golf scoring ?
par and stroke
whew
Mark Dickinson
@monoposon
Mar 29 2016 06:26
how do i turn a string of numbers into numbers? such as turning "12345" into 12345?
Matt Green
@mattxgreen
Mar 29 2016 06:27
@monoposon parseInt()
@abdullahhoosen Par is how many strokes it'll take to retain a score of 0 for that hole
Zach
@Moose1551
Mar 29 2016 06:29
This code returns "Adams". Can anyone give me a pointer on how to return the rest of the names?
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

 var lookup  = {
     "alpha": "Adams",
     "bravo": "Boston",
     "charlie" : "Chicago",
     "delta": "Denver",
     "echo": "Easy",
     "foxtrot": "Frank",
  };
result = "Adams";
 lookup = ["alpha"];
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
Matt Green
@mattxgreen
Mar 29 2016 06:29
@abdullahhoosen If it is par 4, and you make it in 3 strokes, youwould subtract 1 from your score
@Moose1551 result=lookup[val]
and remove the lookup=alpha
Zach
@Moose1551
Mar 29 2016 06:32
@mattxgreen , thank you. How does it know which is the val? Is it because of this line of code?: phoneticLookup("charlie");
CamperBot
@camperbot
Mar 29 2016 06:32
moose1551 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 403 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Abdullah Hoosen
@abdullahhoosen
Mar 29 2016 06:33
@mattxgreen thanks
CamperBot
@camperbot
Mar 29 2016 06:33
abdullahhoosen sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 404 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Matt Green
@mattxgreen
Mar 29 2016 06:33
@Moose1551 val is the argument the function accepts:
function phoneticLookup(val) {
Zach
@Moose1551
Mar 29 2016 06:34
So val can be any of those 12 strings?
Matt Green
@mattxgreen
Mar 29 2016 06:35
val could be anything... but it'll return something if it is one of the 6 keys
@Moose1551 The elements on the left are keys, and to the right of the : are the values. You lookup the values with the key
Kyle Morton
@kmorton1988
Mar 29 2016 06:38
I don't know why I'm having such a hard time with this project.
Matt Green
@mattxgreen
Mar 29 2016 06:38
They are object key/value pairs, if you want to research it further
Cosimo Bressi
@cbressijr
Mar 29 2016 06:38
Hey all, I am at the Introducing JS Object Notation JSON and my code is:
```
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
  {
    "artist": "Boy George",
    "title": "Karm Chameleon",
    "release_year": 1985,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
];
What did I miss here? I have tried several different options and still it tells me I need a semicolon
Matt Green
@mattxgreen
Mar 29 2016 06:39
missing , on line 11
@cbressijr
Kyle Morton
@kmorton1988
Mar 29 2016 06:40
you need a comma after the first json entry.
Matt Green
@mattxgreen
Mar 29 2016 06:40
it's an array of objects
Cosimo Bressi
@cbressijr
Mar 29 2016 06:40
OMG, lol. Thanks @mattxgreen @kmorton1988
CamperBot
@camperbot
Mar 29 2016 06:40
cbressijr sends brownie points to @mattxgreen and @kmorton1988 :sparkles: :thumbsup: :sparkles:
:star: 297 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
:star: 405 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Kyle Morton
@kmorton1988
Mar 29 2016 06:41
yup :)
Cosimo Bressi
@cbressijr
Mar 29 2016 06:41
Stared at that code for the last 20 mins trying to decipher that and it was a simple ","
Kyle Morton
@kmorton1988
Mar 29 2016 06:41
I think I need to go back to some of the basic.s
I made it pretty far, but now I'm completely stuck at the weather display project.
running around in circles.
Matt Green
@mattxgreen
Mar 29 2016 06:42
get an ide to paste your code into. It'll help you out with dumb stuff like that. Brackets, and Sublime are free. Webstorm is (arguably) the best
Kyle Morton
@kmorton1988
Mar 29 2016 06:42
I have brackets.
Matt Green
@mattxgreen
Mar 29 2016 06:42
@cbressijr
Kyle Morton
@kmorton1988
Mar 29 2016 06:42
ahh. right.
my bad
Cosimo Bressi
@cbressijr
Mar 29 2016 06:44
Yeh, I have Webstorm just forget to load up and use it when I am on FCC.
kirbyedy
@kirbyedy
Mar 29 2016 06:44
@kmorton1988 link ?
Matt Green
@mattxgreen
Mar 29 2016 06:44
@cbressijr woulda saved ya 20min of your life today :)
Kyle Morton
@kmorton1988
Mar 29 2016 06:45
to? @kirbyedy
oh, my weather codepen? heh. It's so pitiful right now.
it's in shambles.
kirbyedy
@kirbyedy
Mar 29 2016 06:45
ok :)
whenever you are ready
Kyle Morton
@kmorton1988
Mar 29 2016 06:46
and now for some reason it's...
crashing?
not sure what's going on here.
some kind of permissions issue with an API? idk, this is weird.
kirbyedy
@kirbyedy
Mar 29 2016 06:50
hmm
console says it is some font problem !?
Kyle Morton
@kmorton1988
Mar 29 2016 06:50
yeah, that's what I"m trying to figure out...
I'm not even using a special font, unless it's to do with bootstrap.
nope, removed bootstrap from the resources and it still crashed
ugh
maybe this i slife telling me to take a break
kirbyedy
@kirbyedy
Mar 29 2016 06:52
ok fixed it
Kyle Morton
@kmorton1988
Mar 29 2016 06:52
OH!
fuck
removed a dependency
kirbyedy
@kirbyedy
Mar 29 2016 06:53
 $(document).ready(function(){

if(navigator.geolocation){

     navigator.geolocation.getCurrentPosition(function(location){
      latitude = location.coords.latitude;
      longitude = location.coords.longitude;

       console.log(location);
     });
     }

});
this works, and logs the location to the console
now continue
Kyle Morton
@kmorton1988
Mar 29 2016 06:56
ok. see, this is where I'm stuck.
every weather api seems to only want a zip code as input.
my mind is just not thinking straight. At all. I feel like I need a javascript refresher course.
the jquery section really wasn't helpful to me. It just told you what to do and was like "Good luck!"
kirbyedy
@kirbyedy
Mar 29 2016 07:10
yea :)
well thats why its free :)
Kyle Morton
@kmorton1988
Mar 29 2016 07:11
ha, yeah. sigh I'm almost ready to just succumb to using the ipaddress lookup to find location.
kirbyedy
@kirbyedy
Mar 29 2016 07:11
you dont have a tutor which will guide you, you are on your own, have to dig deep into google and get some help here on the chat from the community
Kyle Morton
@kmorton1988
Mar 29 2016 07:11
I want to know how to call an API, parse the data and use it.
kirbyedy
@kirbyedy
Mar 29 2016 07:11
I used openweather api you can see the documentation on their site and a sample
you only need to register for the api key
Kyle Morton
@kmorton1988
Mar 29 2016 07:12
yeah, openweathermap has the API, and I have a key.
Kumar Kanchan
@Kumar547
Mar 29 2016 07:12
Hello
Kyle Morton
@kmorton1988
Mar 29 2016 07:12
Just can't figure out how to actually use it :/ the getJSON call is what's confusing me.
Ramana Venkata
@vramana
Mar 29 2016 07:12
@Kumar547 Hello
Kumar Kanchan
@Kumar547
Mar 29 2016 07:13
I need some help regarding admin SDK of Google App script
kirbyedy
@kirbyedy
Mar 29 2016 07:13
do you see here the lat and lon ?
Ramana Venkata
@vramana
Mar 29 2016 07:13
@kmorton1988 Paste some code and ask somebody to explain the lines that you didn't get.
kirbyedy
@kirbyedy
Mar 29 2016 07:13
that is you location
Kumar Kanchan
@Kumar547
Mar 29 2016 07:14
AdminDirectory.Users.update(resource, userKey)
whats is resource in above code?
Zach
@Moose1551
Mar 29 2016 07:15
Is it just me, or is "Testing Objects for Properties" an incredibly confusing tutorial?
Kyle Morton
@kmorton1988
Mar 29 2016 07:15
@Moose1551 that lesson really prepares you for figuring out how to target sp ecific items within arrays and objects.
you'll want to use the hasOwnProperty() method.
96street
@96street
Mar 29 2016 07:16
How come clear:both isn't working here? http://codepen.io/anon/pen/MyvYBQ
Zach
@Moose1551
Mar 29 2016 07:17
Looking at the tutorial, this is the best I can figure.
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  myObj.hasOwnProperty("pony");
   myObj.hasOwnProperty("kitten");
  return "Not Found";

}

// Test your code by modifying these values
checkObj("gift", "pet");
Should i be using if/else statement?
Kyle Morton
@kmorton1988
Mar 29 2016 07:21
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

if  (myObj.gift != checkProp)){
    return "Not Found";
}

// Test your code by modifying these values
checkObj("gift", "pet");
or something like that.
you have to check if the specific property and value match.
Zach
@Moose1551
Mar 29 2016 07:22
I was flying through this stuff until Counting Cards. And then the examples and the tutorials just stop giving sufficient information.
Kyle Morton
@kmorton1988
Mar 29 2016 07:22
right, that's when they start testing your ability to search and ask the right questions.
Zach
@Moose1551
Mar 29 2016 07:23
but the hasOwnProperty() method isn't in your example.
Kyle Morton
@kmorton1988
Mar 29 2016 07:23
Right. I'll have to look back and see.
Zach
@Moose1551
Mar 29 2016 07:26
IT'd be nice for codecamp to warn you that they are purposefully not providing sufficient info so that you know you're supposed to research outside of the tutorial. Otherwise if just feels like my reading comprehension is shit. Why don't they give a warning? Would have kept me from going to waypoint for the solutions ...
Michael Botes
@MichaelFF
Mar 29 2016 07:33
they do, "Remember to use Read-Search-Ask if you get stuck."
pretty much how it is in the real world :D
Eva Crawford
@grooveva
Mar 29 2016 07:49
Okay I can tell I'm missing something obvious in this card count challenge

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 = ++count;
break;
case 7:
case 8:
case 9:
count = count;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count = --count;
}
return count;

if (count >= 1) {
return "bet";

} else if (count <= 0) {
return "hold";
} else {
return "Change Me";

}

Michael Botes
@MichaelFF
Mar 29 2016 07:50
case: 7,8,9 => change it to count += 0; see if that works.
Eva Crawford
@grooveva
Mar 29 2016 07:51
will do checking
Still getting an error on the first line of my if/then else statement
Aleksander Gębicki
@Takumar
Mar 29 2016 07:52

@grooveva this part has to be corrected:

return count;
if (count >= 1) {
return "bet";
} else if (count <= 0) {
return "hold";
} else {
return "Change Me";

When first line: return count; is called, it exits your function immediately, so rest of code is not runned.
Later you check if count variable is positive or negative it is good, but you should return other messages.

Eva Crawford
@grooveva
Mar 29 2016 07:53
gotcha okay
Aleksander Gębicki
@Takumar
Mar 29 2016 07:53

@grooveva

return count + " Hold";
or
return count + " Bet";

respectively.

V1ad1m1r
@V1ad1m1r
Mar 29 2016 07:54
i dont know why, but this is killing me.
how do i post the code?
Michael Botes
@MichaelFF
Mar 29 2016 07:54
yeah was just typing that out, @Takumar.
wiki how to post code
CamperBot
@camperbot
Mar 29 2016 07:55
Aleksander Gębicki
@Takumar
Mar 29 2016 07:55
@grooveva one more thing, count = ++count; is unnecessary complicated construction. ++count; is enough, because it is modyfying count variable, so no need to reassign it's value.
Nick Robson
@nickrobson
Mar 29 2016 07:55
```js
[code here]
```
you can replace "js" with whatever language you're putting in and it will highlight it accordingly
V1ad1m1r
@V1ad1m1r
Mar 29 2016 07:56

```function update(id, prop, value) {

if (collection.id !== "" && collection.id.prop !== "tracks") {

collection[id].prop = value;
}

else if(collection.id !== "" && collection.id.prop == "tracks"){

collection.id.tracks.push(value);

}

else if (collection.id.value === ""){
delete collection.id.prop;
}

return collection;
}
```

Eva Crawford
@grooveva
Mar 29 2016 07:56
AH interesting well that certainly gets my returned syntax correct and I'll give that a ++ and -- change a try, I'm still not getting correct values returned for the cards so maybe that's part of the problem
Nick Robson
@nickrobson
Mar 29 2016 07:56
you need a newline after the first backticks
V1ad1m1r
@V1ad1m1r
Mar 29 2016 07:56
oh ok. thanks.
Michael Botes
@MichaelFF
Mar 29 2016 07:57
and specify language type with '''js
CamperBot
@camperbot
Mar 29 2016 07:57
:bulb: to format code use backticks! ``` more info
Aleksander Gębicki
@Takumar
Mar 29 2016 07:57
@V1ad1m1r prop is a variable (parameter) so you have to use bracket notation to access it
collection[id][prop]
Nick Robson
@nickrobson
Mar 29 2016 07:57
@grooveva
count++;
is the same as
++count;
provided that's all that line is doing
Eva Crawford
@grooveva
Mar 29 2016 07:57
I did know that @nickrobson :D thanks! Progress
CamperBot
@camperbot
Mar 29 2016 07:57
grooveva sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 423 | @nickrobson | http://www.freecodecamp.com/nickrobson
Nick Robson
@nickrobson
Mar 29 2016 07:58
:)
Eva Crawford
@grooveva
Mar 29 2016 07:58
@Takumar thanks I'm a lot closer :D
CamperBot
@camperbot
Mar 29 2016 07:58
grooveva sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2885 | @takumar | http://www.freecodecamp.com/takumar
V1ad1m1r
@V1ad1m1r
Mar 29 2016 07:58
@Takumar ok cool.
what makes it a variable parameter?
Nick Robson
@nickrobson
Mar 29 2016 07:59
@V1ad1m1r Remember, if you've got a variable named prop, then you need to use
object[prop] to get the value of it
Aleksander Gębicki
@Takumar
Mar 29 2016 07:59
@V1ad1m1r prop is parameter of function so it is a local variable of that function.
Nick Robson
@nickrobson
Mar 29 2016 07:59
object.prop is the same as doing object["prop"], NOT object[prop]
Aleksander Gębicki
@Takumar
Mar 29 2016 07:59
@grooveva you are welcome.
Eva Crawford
@grooveva
Mar 29 2016 07:59
Now onwards to see what minor I have here gumming up the math @Takumar :)
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:02
@Takumar ok. i understand the variable. but isnt what nick is saying true? why can i access other parameters such as id within my obj with . but have to access prop with [prop]?
aside from a space in a string, what is the functional difference?
Aleksander Gębicki
@Takumar
Mar 29 2016 08:02
@V1ad1m1r id is also parameter :-)
it contains name of property, it is not property itself!
You can use dot when you are sure you know name of property
@V1ad1m1r
var car = {
  wheels: 4,
  colour: green
}

car.wheels = 5;
var prop = "colour";
car[prop]  = "red";
car.prop = 5; // this is WRONG!!!
Markus Kiili
@Masd925
Mar 29 2016 08:04
@V1ad1m1r The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:06
AH!! so because id is numeric i can call it with .id, but because prop and value are strings, they need [] correct?
Markus Kiili
@Masd925
Mar 29 2016 08:07
@V1ad1m1r obj.id looks for property key "id". obj["id"] does the same. obj[id] looks for property key stored in variable id.
Aleksander Gębicki
@Takumar
Mar 29 2016 08:07
@V1ad1m1r no, you cannot use id with dot, because it is not name of property of the object! It has nothing to do whether id is numeric or string.
Andrew
@andrewpalfenier
Mar 29 2016 08:08
help smallest common multiple
CamperBot
@camperbot
Mar 29 2016 08:08

: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

V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:10
ok. so, by calling obj.id i am effectively calling ob["id"]. its looking for that exact phrase not the variable id. so if I call something by . it will look for that exact thing, not for something under that variable. correct?
sorry this particular lesson is making my brain twist.
Markus Kiili
@Masd925
Mar 29 2016 08:10
@V1ad1m1r yes.
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:11
excellent! thanks so much guys. that makes way more sense.
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:19
``` js
Eva Crawford
@grooveva
Mar 29 2016 08:20
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 = count + 0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
     --count;
  }
  if (count >= 1) {
    return count + " bet";
  } else if (count <= 0) {
    return count + " hold";
  } else {
     return "Change Me";
  }
  // Only change code above this line

}
Okay I'm super close here but it's not returning the correct values
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:21
shouldnt it be count++ instead of ++count?
i could be wrong.
Eva Crawford
@grooveva
Mar 29 2016 08:21
by the way do I even need those cases for 7, 8, & 9 ?
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:22
i dont think i used them on that challenge. I just left them out. if i remember correctly.
Eva Crawford
@grooveva
Mar 29 2016 08:22
@V1ad1m1r I believe both work the same unless someone more skilled corrects me :)
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:22
@grooveva lol. totally valid :)
function update(id, prop, value) {

  if (value == ""){
delete collection[id][prop];}

  else if (collection[id] !== "" && collection[id][prop] !== "tracks") {

   collection[id][prop] = value;
  }

  else if(collection[id] !== "" && collection[id][prop] == "tracks"){

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


  return collection;
}
Eva Crawford
@grooveva
Mar 29 2016 08:25
interestingly enough all the other examples of the card count challenge used if then else that I could find here on the forum, that seems inefficient, BUT I guess they got it to work unlike me @V1ad1m1r :)
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:26
@grooveva from what i remember i used the switch code as well. WAY quicker!!
Blauelf
@Blauelf
Mar 29 2016 08:27
@V1ad1m1r collection[id] is never "", as it is an object. And not collection[id][prop] should be compared to "tracks", but prop. And don't push an array, but a value.
Markus Kiili
@Masd925
Mar 29 2016 08:27
@grooveva Lookup object is also a good option.
Eva Crawford
@grooveva
Mar 29 2016 08:27
@V1ad1m1r I figured it was a big clue that the previous lessons showed the switch code in usage
Blauelf
@Blauelf
Mar 29 2016 08:28
@grooveva I think it's Bet and Hold, not bet and hold
Eva Crawford
@grooveva
Mar 29 2016 08:28
@Masd925 I don't know that I've used that yet
@Blauelf Oh man if it's that simple i'll be so pissed! HAH
@Blauelf OMG it totally was!!
Blauelf
@Blauelf
Mar 29 2016 08:29
:P
Elizabeth Fine
@elizabethfinedev
Mar 29 2016 08:29
Does anyone think they can maybe look at my Roman Numeral Code and tell me why its returning false?
Eva Crawford
@grooveva
Mar 29 2016 08:29
@Blauelf Gold star! LOL thank you, It's clearly time for me to go to sleep
CamperBot
@camperbot
Mar 29 2016 08:29
grooveva sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1463 | @blauelf | http://www.freecodecamp.com/blauelf
Elizabeth Fine
@elizabethfinedev
Mar 29 2016 08:30
function convert(num)  {
var numberIndex =[]; 
var normalNumbers = [1, 5, 10, 50, 100, 500, 1000];

var romanNumbers = ["I", "V", "X", "L", "C", "D", "M"];

var numCopy = num;
  //while numCopy is greater than zero, look for the biggest number in the array less than or equal to that number and report its index.

  if  (numCopy > 0)  {
     for (i = 0; i < normalNumbers.length; i++)  {
       if ((normalNumbers[i] <= numCopy) && (normalNumbers[i + 1] > numCopy))  {
             numberIndex = normalNumbers.indexOf(i);
       }

     }
  } 
  return numberIndex;
}
convert(10);
totally stuck, not sure why it is returning false instead of the index of 2
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:32
@Blauelf i have tried pushing just the value. but it still seems to be having an issue. The code is working, i can see the readout its looking for in the console, but it seems not to notice that "Addicted to Love" is the last element.
Blauelf
@Blauelf
Mar 29 2016 08:34
@V1ad1m1r Which console do you use? The browser console (using console.log) shows more clearly what happens, as the return value console on the left in FCC has some formatting issues.
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:35
@Blauelf not sure how to change the console.
i am using the one on the left on the site
but it is displaying the desired output :/
Blauelf
@Blauelf
Mar 29 2016 08:37

@V1ad1m1r Show browser console by using F12 or Ctrl+Shift+I. Write to it using console.log().
The structure used in this challenge is usually something like

  if (value=="") {
    // remove entry
  } else {
    if (prop=="tracks") {
      // add to tracks list
    } else {
      // set property value
    }
  }

or somewhat condensed

  if (value=="") {
    // remove entry
  } else if (prop=="tracks") {
    // add to tracks list
  } else {
    // set property value
  }

or something equivalent (some prefer one level using if-elseif-else with two conditions in each if, so they have the same order as in the instructions).

V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:40
hmm.
full code
// 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 == ""){
delete collection[id][prop];}

    else if(collection[id] !== "" && collection[id][prop] == "tracks"){

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

  else if (collection[id] !== "" && collection[id][prop] !== "tracks") {

   collection[id][prop] = value;
  } 

  return collection;
}

// Alter values below to test your code
update(1245, "tracks", "Addicted to Love");
Aleksander Gębicki
@Takumar
Mar 29 2016 08:41
@V1ad1m1r you were already told, that you should not compare value of property with name of property: && collection[id][prop] == "tracks"
but prop === "tracks"
Blauelf
@Blauelf
Mar 29 2016 08:41
As I said, compare value and prop to those strings, not collection[id] and collection[id][prop]. (but the actions seem right now)
Oh, as you do value=="" first, you don't need two conditions in those elseif/else. Just the test for prop=="tracks".
V1ad1m1r
@V1ad1m1r
Mar 29 2016 08:48
thanks guys! finally got it. :)
so my issue was instead of checking by the local variables, it was comparing variables already within my object correct?
Szűgyi Dávid
@szugyi92
Mar 29 2016 08:51
Hello guys! I have a question.
How use camelCase?
Coy Sanders
@coymeetsworld
Mar 29 2016 08:59
you just did @szugyi92 :)
camel case is just putting multiple words together into one word, but capitalizing each word inside
Thats java....
No script
But anyone??
Can any one tell me what's the problem with scanner...
Aleksander Gębicki
@Takumar
Mar 29 2016 09:24
@LENZFLIKER shouldn't it be: Scanner scan = new Scanner(System.in);
You create new object of Scanner class not "scanner"
LENZFLIKER
@LENZFLIKER
Mar 29 2016 09:27
What's variable input symbol ? @Takumar
Errors.... ⬆
LENZFLIKER
@LENZFLIKER
Mar 29 2016 09:41
Hmmm...
Thanx @Takumar
CamperBot
@camperbot
Mar 29 2016 09:42
lenzfliker sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:warning: lenzfliker already gave takumar points
AbdHan
@abdhan
Mar 29 2016 09:49
Hola! I was doing my Wikipedia viewer Zipline and I noticed the example app used AngularJS. I think it used it mainly because it does client side form validation? I have no idea about AngularJS. Is there anyway I can parse form submitted value to process and output on the same page?
kirbyedy
@kirbyedy
Mar 29 2016 10:07
you dont have to use angular @abdhan
use the ajax call
AbdHan
@abdhan
Mar 29 2016 10:08
Okay I see. thanks :thumbsup:
Lawrence Eagles
@lawrenceagles
Mar 29 2016 10:23

can anybody tell me what is wrong with my code please... http://i1302.photobucket.com/albums/ag136/lawrenceagles/Screenshot%20from%202016-03-29%2006-52-30_zpstqifankv.png I'm doning the Card Count exercise. Here is my code: var count = 0;
var outPut = "";

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

switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = count + 1;
outPut = "Bet";

break;
case 7:
case 8:
case 9:
count = count + 0;
outPut = "Hold";
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count = count -1;
outPut = "Hold";
break;

}

return count + " " + outPut;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc("J");

Markus Kiili
@Masd925
Mar 29 2016 10:27
@lawrenceagles Change value of count on the switch, and after it figure out the return value based on count.
Simon Jacobs
@SimonJacobsTLD
Mar 29 2016 10:35
help make a person
CamperBot
@camperbot
Mar 29 2016 10:35

:point_right: algorithm make a person [wiki]

Explanation:

When I started the program I figured I just had to create the six functions mentioned in the details. However, it was not that simple. Creating them as a function was not the right way, I had to create them in a different way to make them a key.

There is also a tricky part as you need six keys no more or less, so at first I had the variable that store the original name as a key too which was wrong.

As for the usage of array, that is optional, you could also create new variable to hold the separated string if you wish but an array is easier to deal with as strings are immutable.

Read the instructions carefully, it is always a good hint in itself to run the code and check what the test results were so you know what to expect but do not fixate yourself on that. Once you understand what you need to do, this problem is very easy and straightforward.

:pencil: read more about algorithm make a person on the FCC Wiki

Lawrence Eagles
@lawrenceagles
Mar 29 2016 10:38
@Masd925 I don't get you.
Markus Kiili
@Masd925
Mar 29 2016 10:40
@lawrenceagles Count is a global variable that function calls change. Based on that global variable, you should figure out the return value (not based on one card).
João Alves
@JADSN
Mar 29 2016 10:42
var count = 0;

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

  var answer = "";

  switch(card){


    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      answer = " Bet";
      count++;
      break;
    case 7:
    case 8:
    case 9:
      answer = " Hold";
      count += 0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      answer = " Hold";
      count--;
      break;     
    default:
      answer = " Bet";
      count = 1;
      break;

  }


  return count + answer;
  // Only change code above this line
}
How can i resolve "1 Bet" in Counting Cards ?
Brendan Kinahan
@BKinahan
Mar 29 2016 10:46
@JADSN answer should depend on the current value of count, not what the last drawn card was
João Alves
@JADSN
Mar 29 2016 10:49
@BKinahan Thanks
CamperBot
@camperbot
Mar 29 2016 10:50
jadsn sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1183 | @bkinahan | http://www.freecodecamp.com/bkinahan
Zabe Sangary
@zabesangary
Mar 29 2016 10:53
This message was deleted
function myTest(val) {
  var answer = "";
  switch(answer){
    case "alpha":
      break;

    return answer;  
}
}
// Change this value to test
myTest(1);
what am i doing wrong?
Brendan Kinahan
@BKinahan
Mar 29 2016 10:56
@zabefloyd switch should operate on val since that can have multiple values, rather than answer which has only one possible value at that point ("")
@zabefloyd also the return statement shouldn't be within the switch statement, and the switch should assign a value to answer
Lawrence Eagles
@lawrenceagles
Mar 29 2016 11:01
@JADSN it did not work.

var count = 0;

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

var answer;

switch(card){

case 2:
case 3:
case 4:
case 5:
case 6:
  answer = " Bet";
  count++;
  break;
case 7:
case 8:
case 9:
  answer = " Hold";
  count += 0;
  break;
case 10:
case "J":
case "Q":
case "K":
case "A":
  answer = " Hold";
  count--;
  break;     
default:
  answer = " Bet";
  count = 1;
  break;

}

return count + answer;
// 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');

Mooli
@Mooli88
Mar 29 2016 11:04
hi all , im doing the weather project and i can use some help. how can i get access to those files from the server http://bulk.openweathermap.org/sample/ ?
Andrew
@andrewpalfenier
Mar 29 2016 11:04
help drop it
CamperBot
@camperbot
Mar 29 2016 11:04

:point_right: algorithm drop it [wiki]

Explanation:

Basically while the second argument is not true, you will have to remove the first element from the left of the array that was passed as the first argument.

:pencil: read more about algorithm drop it on the FCC Wiki

ajaybti
@ajaybti
Mar 29 2016 11:11
help
CamperBot
@camperbot
Mar 29 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

ajaybti
@ajaybti
Mar 29 2016 11:12
Return Largest Numbers in Arrays
Return Largest Numbers in Arrays info
Algorithm Return Largest Numbers in Arrays
Lawrence Eagles
@lawrenceagles
Mar 29 2016 11:23
about @LawrenceArcher
CamperBot
@camperbot
Mar 29 2016 11:23
:star: 266 | @lawrencearcher | http://www.freecodecamp.com/lawrencearcher
Zabe Sangary
@zabesangary
Mar 29 2016 11:32
thanks for the respond @BKinahan
function myTest(val) {
  var answer = "";
  switch(val){
    case "alpha":
    return answer;  
    break;

}
}
// Change this value to test
myTest(1)
CamperBot
@camperbot
Mar 29 2016 11:32
zabefloyd sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1184 | @bkinahan | http://www.freecodecamp.com/bkinahan
Zabe Sangary
@zabesangary
Mar 29 2016 11:32
did you mean something like that?
Mahak Narayan Singh
@makkBit
Mar 29 2016 11:33
Open Weather Api suggested for Local Weather App by FCC, doesn't serves https for a free id, serving http gives mixed content blocking on codepen. Is there any way to resolve this issue?
Blauelf
@Blauelf
Mar 29 2016 11:37
@zabefloyd I would not return from the switch, but only assign to answer inside, more like
function myTest(val) {
  var answer = "";
  switch(val){
    case "alpha":
      answer="Adams";  
      break;
  }
  return answer;
}
// Change this value to test
myTest(1)
Zabe Sangary
@zabesangary
Mar 29 2016 11:38
answer is a statement in this case?
Blauelf
@Blauelf
Mar 29 2016 11:39
answer is a variable. answer = "Adams" is both an expression and a statement (used as a statement here).
Zabe Sangary
@zabesangary
Mar 29 2016 11:41
thanks @Blauelf did you try it in console I get Empty double "" it should return alpha?
CamperBot
@camperbot
Mar 29 2016 11:41
zabefloyd sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1464 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Mar 29 2016 11:41
Oh, what are you supposed for which values of val?
In that case, it would be like
  switch(val) {
    case 1: answer = "alpha";
            break;
  }
Zabe Sangary
@zabesangary
Mar 29 2016 11:43
instruction
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
awesome
Thanks very much, now is more clear, have to read the mdn article tho.. appreciated @Blauelf
CamperBot
@camperbot
Mar 29 2016 11:45
zabefloyd sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: zabefloyd already gave blauelf points
Zabe Sangary
@zabesangary
Mar 29 2016 11:46
easily you forget I knew how the switch works, did it at codeacdemy
Blauelf
@Blauelf
Mar 29 2016 11:46
@zabefloyd switch first evaluates what you put in the switch statement (here it is val), and then one after the other evaluates the expressions in the case statements and compares the result with the result from above, and from the first match it executes all lines until it hits a break.
Zabe Sangary
@zabesangary
Mar 29 2016 11:51
so Val is the expression and answer is statement, if I understand correctly
little confused what case dose...
Blauelf
@Blauelf
Mar 29 2016 11:55
case specifies an expression that is evaluated and tested against the result of the expression given to switch. And again, answer is a variable, but the assignment is a statement (as is the break).
ObedJosiah
@obedjosiah
Mar 29 2016 11:56

Hi. I need help with Truncate String. I can't get through the 3rd & 4th test cases. Here's my code: ```function truncateString(str, num) {
// Clear out that junk in your trunk
var dots = '...';
if(num <= 3){
str = str.slice(0, num);
return str+dots;
}
else if(num > 3){
str = str.slice(0, num-3);
str = str.concat(dots);
return str;
}
else if(num >= str.length){
return str;
}

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

Hi. I need help with Truncate String. I can't get through the 3rd & 4th test cases. Here's my code: function truncateString(str, num) { // Clear out that junk in your trunk var dots = '...'; if(num <= 3){ str = str.slice(0, num); return str+dots; } else if(num > 3){ str = str.slice(0, num-3); str = str.concat(dots); return str; } else if(num >= str.length){ return str; } } truncateString("A-tisket a-tasket A green and yellow basket", 11);
Blauelf
@Blauelf
Mar 29 2016 11:58
@obedjosiah num>=str.length should be your first question, as num does not matter if str does not need to be truncated.
Mooli
@Mooli88
Mar 29 2016 11:59
hi guys, how can i create a local server with node.js ?
Blauelf
@Blauelf
Mar 29 2016 12:00

@obedjosiah Use triple backticks followed by the used language (like ```js, ```html, or ```css) for multi-line code, but add line breaks using Shift+Return, as these need to be on separate lines (also needs triple backtick at the end):

function truncateString(str, num) {
  // Clear out that junk in your trunk
  var dots = '...';
  if(num <= 3){
    str = str.slice(0, num);
    return str+dots;
  }
  else if(num > 3){
    str = str.slice(0, num-3);
    str = str.concat(dots);
    return str;
  }
  else if(num >= str.length){
    return str;
  }

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

Used ```js for this

Lawrence Eagles
@lawrenceagles
Mar 29 2016 12:04

@BKinahan can you please take a look at my code. I have gotten the card count exercise to work but I need you to review if my method is good. var count = 0;

function cc(card) {
// Only change code below this line
var currentCount;
var descion;

switch (card) {

case 2:
case 3:
case 4:
case 5:
case 6:
count ++;
descion = "Bet";
break;
case 7:
case 8:
case 9:
descion = "Hold";
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
descion = "Hold";
break; 

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

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc("J"); cc(9); cc(2); cc(7);

ObedJosiah
@obedjosiah
Mar 29 2016 12:05
@Blauelf Ok. Thanks a lot. I made the change. The code worked👍.
CamperBot
@camperbot
Mar 29 2016 12:05
obedjosiah sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1465 | @blauelf | http://www.freecodecamp.com/blauelf
Brendan Kinahan
@BKinahan
Mar 29 2016 12:06
@lawrenceagles it passes all of the tests, but you have a few extra lines of code that aren't doing anything and can be removed. your variable descion is not used, so you can remove its declaration and all assignments to it.
@lawrenceagles also with those removed, cases 7, 8, and 9 won't do anything either, so they could be removed as well.
ObedJosiah
@obedjosiah
Mar 29 2016 12:07
@Blauelf About the code formatting, I use my phone to code on freecodecamp most of the time. How do I use shift-return??
Zabe Sangary
@zabesangary
Mar 29 2016 12:08
great that makes more sense @Blauelf
Lawrence Eagles
@lawrenceagles
Mar 29 2016 12:10
@BKinahan thanks a lot I just needed this pep to make my codes cleaner and better. It is not really about passing the texts for me, but by what standards did I pass them. I appreciate.
CamperBot
@camperbot
Mar 29 2016 12:10
lawrenceagles sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1185 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brian Kilrain
@bkilrain
Mar 29 2016 12:18

Hello helpful campers - Please help me with my code: http://codepen.io/bkilrain/pen/ZWBxwV?editors=0011 (twitch viewer)

Specifically, the problem is: sometimes the tables all populate correctly with every username specified (I am searching 12 separate usernames)… but sometimes not all of them get populated. I assume this is an asynchronous issue… but I can’t figure it out! Please help~

Tim Alaerts
@corteki
Mar 29 2016 12:20

`$(document).ready(function() {
$("#getQuote").click(function() {
$.ajax({
url: 'https://en.wikiquote.org/w/api.php?action=parse&format=json&page=Seneca_the_Elder&section=1&prop=parsetree',
dataType: 'jsonp',
success: function(data) {
var quotes = data.parse.parsetree["*"];
console.log(quotes)
$(".quote").html(quotes);
}
});

});

});`I'm really stuck with this random quote excercise... I can only display the data but I don't know what to do next. Can someone lead me back on the right track?

Brian Kilrain
@bkilrain
Mar 29 2016 12:22
can you send your codepen url @corteki
It sounds like all you need to do is make the actual quote pretty… and then add a button to post the quote on twitter
And yes I know, but I really can't figure out how
kirbyedy
@kirbyedy
Mar 29 2016 12:26
@corteki you can set the width of your div if you want in the css
for example 70%
Brian Kilrain
@bkilrain
Mar 29 2016 12:26
@corteki Ahhh… I see what you’ve done. You are just pulling up the specific quote from Seneca… and it is stuck deep inside a bunch of other junk
Tim Alaerts
@corteki
Mar 29 2016 12:28
@bkilrain yes, I don't know how to just acces the quotes... leave aside the styling, I just need to display one quote at the time but I don't know how to use my data.
Brian Kilrain
@bkilrain
Mar 29 2016 12:28
I think the assignment was to have a new random quote appear each time you click the button. So… I’ve seen campers do one of two things: find an API that has a database of quotes that you can call (just like you did with your wikiquote API)… or you can make your own json with a handful of quotes that you like and configure your javascript to select a random one each time the button is pressed
Blauelf
@Blauelf
Mar 29 2016 12:29
@obedjosiah Phone is some challenge. On my keyboard line-break is on long-pressing the smiley button (has some icon shaped like the one on the return key)
ManBearPigg
@ManBearPigg
Mar 29 2016 12:29

Smallest Common Multiple
Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters.

For this question, isn’t 1 always teh smallest common multiple that can be evenly divided by both? They don’t say “except for 1” but I feel like that must be too easy to be right?

Blauelf
@Blauelf
Mar 29 2016 12:30
1 is the smallest common divider.
ManBearPigg
@ManBearPigg
Mar 29 2016 12:30
@Blauelf Which is 1 right
Brian Kilrain
@bkilrain
Mar 29 2016 12:30
@corteki I had a hell of a time with this assignment because it was the first time I’d ever tried to work with APIs… I used this api: http://forismatic.com/en/api/ and eventually figured it out with some major googling
Blauelf
@Blauelf
Mar 29 2016 12:31
@ManBearPigg You are meant to find the smallest common multiple. Which is at least the largest of those numbers, probably much larger.
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 29 2016 12:32
Hi everyone, I'm having a problem, I'm on the project random quote machine and I would like to do a crossfading on my quotes but it isn't really working, can you help me?
seasons
@seasonscao
Mar 29 2016 12:32
Hey, what’s wrong with my code?
Abdullah Hoosen
@abdullahhoosen
Mar 29 2016 12:32
Is it necessary to 'break' after the last switch statement?
ManBearPigg
@ManBearPigg
Mar 29 2016 12:32
@Blauelf If you had 4 and 8, is 2 not a common multiple? Why does it have to be bigger
seasons
@seasonscao
Mar 29 2016 12:32
//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
  for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName != firstName){
      return "No such contact";
    }else if(contacts[i].hasOwnProperty('prop') === false){
      return "No such property";
    }else if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty('prop')===true){
      return contact[i].prop;
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Brian Kilrain
@bkilrain
Mar 29 2016 12:33
@corteki So… once you get the random quotes issue sorted, go back and see how you made your portfolio and tribute pages… all the css styling and html divs and whatnot. That should give you some good ideas on how to present the quote in a nice way :)
seasons
@seasonscao
Mar 29 2016 12:33
i don’t know how to return the value?
Blauelf
@Blauelf
Mar 29 2016 12:33
@abdullahhoosen It is not, just if you add additional case statements (or a default case) you'll have to remember to add one.
ManBearPigg
@ManBearPigg
Mar 29 2016 12:33
@Blauelf Oh I see, so it’s not 1 because when they are both multiplied by that, they don’t return the same result. It’s always 0
Abdullah Hoosen
@abdullahhoosen
Mar 29 2016 12:33
@Blauelf thanks
CamperBot
@camperbot
Mar 29 2016 12:33
abdullahhoosen sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1466 | @blauelf | http://www.freecodecamp.com/blauelf
ManBearPigg
@ManBearPigg
Mar 29 2016 12:34
@Blauelf Oh that can be evenly divided by both. Ok I get it now lol thanks
CamperBot
@camperbot
Mar 29 2016 12:34
manbearpigg sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1467 | @blauelf | http://www.freecodecamp.com/blauelf
Tim Alaerts
@corteki
Mar 29 2016 12:34
@bkilrain but the problem is not css and styling, using another API isn't either, I want to know how to acces the quotes from the API I'm using right now, how to deal with it
Blauelf
@Blauelf
Mar 29 2016 12:35
@ManBearPigg The smallest common multiple is the smallest number that can be evenly divided by those numbers. So for 4 and 6, it would be 12 (is 3 times 4 and 2 times 6)
kirbyedy
@kirbyedy
Mar 29 2016 12:37
@corteki as far as I can see the data you are pulling is not json object
Theodore P.
@Ierofantis
Mar 29 2016 12:38
How can I select the arguments outside the array for making this code really works?I am stuck...(seek and destroy algorithm)
function destroyer(arr) {

function one(arg){
 var args = Array.prototype.slice.call(arguments); 
return args;

}

  var filtered = arr.filter(one);
  return filtered;
}






destroyer([1, 2, 3, 1, 2, 3,7], 2, 3);
Lars
@LarsEum
Mar 29 2016 12:39
thanks @TreadStone071
CamperBot
@camperbot
Mar 29 2016 12:39
larseum sends brownie points to @treadstone071 :sparkles: :thumbsup: :sparkles:
kirbyedy
@kirbyedy
Mar 29 2016 12:39
@corteki compare your console log with this output: http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=JSON_CALLBACK
CamperBot
@camperbot
Mar 29 2016 12:39
:warning: could not find receiver for treadstone071
seasons
@seasonscao
Mar 29 2016 12:41
excuse me, what’s wrong with my code?
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
Brian Kilrain
@bkilrain
Mar 29 2016 12:41

@corteki re: the api you are using right now: you are using the url: https://en.wikiquote.org/w/api.php?action=parse&format=json&page=Seneca_the_Elder&section=1&prop=parsetree

if you enter that url into your browser, you get back the json. Everytime you enter that url, you get the same json… so the quotes will never be random. You’ll always end up with the same quote.

I don’t know enought about wikiquote api to give you advice on how to get random quotes… re: that specific url and quote: You’d have to do some major algorithmic magic to dig into that big long string and yank the quote out. The forismatic api is quite easy by contrast. I believe the relevant keys in the json were “quote” and “quote_author” or something easy like that.

Much more manageable

Clark
@shroomduck
Mar 29 2016 12:41
Hello, I was hoping someone could help me with escaping characters in Javascript. It seems like no matter how I code the following - backslash tab tab carriage-return new-line and assign it to myStr -- I cannot seem to get it to work.
Theodore P.
@Ierofantis
Mar 29 2016 12:41
@negyvenketto I have read It but can you tell me what I am missing?
Tim Alaerts
@corteki
Mar 29 2016 12:41
@kirbyedy okay, so once I get it like that I can just treat it like an object right?
kirbyedy
@kirbyedy
Mar 29 2016 12:41
yes
if you can change your api call it will be great
Aleksander Gębicki
@Takumar
Mar 29 2016 12:42

@shroomduck check codes for backslash and others and create string with that codes:

var myStr = "\\ \t ....

separate all codes with spaces

Tim Alaerts
@corteki
Mar 29 2016 12:42
@kirbyedy I can make it in such a format by setting action=query but then the quotes are gone so ugh
Clark
@shroomduck
Mar 29 2016 12:43
@Takumar I did this and it just writes them as strings to the console, sec i will take picture
Aleksander Gębicki
@Takumar
Mar 29 2016 12:43
@shroomduck paste your code as text not picture.
negyvenketto
@negyvenketto
Mar 29 2016 12:44
@Ierofantis i'm not sure what your function is trying to do, i don't know call. but in your example arguments[1] is 2 and arguments[2]is 3
Clark
@shroomduck
Mar 29 2016 12:44
@Takumar Oh I apparently was doing it correctly, my apologies, I did not know it was supposed to dump the text to the console, I guess I was expecting a "tab" or a "new line" to appear. Thanks!
CamperBot
@camperbot
Mar 29 2016 12:44
shroomduck sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2891 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Mar 29 2016 12:44
@shroomduck you are welcome
negyvenketto
@negyvenketto
Mar 29 2016 12:45
@Ierofantis i think you need to do the comparison one by one for every 'extra' element of the argument
Theodore P.
@Ierofantis
Mar 29 2016 12:47
@negyvenketto ok i get it but the problem is that when i add something like arguments1 it returns me an empty array, but when i add arguments[0] it returns me the first array. Why I can't choose 2,3?Maybe I have to put them all in one big array?But I think I will do things overcomplicated and It will not a very sufficient way
Clem
@ctataru
Mar 29 2016 12:48

hey guys. i have a question about my "for...in" loop regarding the roman numeral converter exercise. i have an object with the values of each roman numeral figure up to 1000 {M: 1000, CM: 900, D: 500, CD: 400}etc. i use a for..in loop like this one to iterate over each item of the object:

for (i in object) {
    while (num >= object[i]) {
        roman += i;
        num -= lookup[i];
    }
}

my question is: if for...in loops iterate over an object/array in arbitrary order, how does the roman variable always return the roman numerals in the right order? how come 9 doesn't sometimes equal XI, if it's arbitrary?

negyvenketto
@negyvenketto
Mar 29 2016 12:50
@Ierofantis arguments[1] is not an array, it's one number. where do you want to add it? (i think i don't really understand what you are saying)
Blauelf
@Blauelf
Mar 29 2016 12:50
@ctataru Don't use for-in on arrays unless you don't care in which order the iteration is done (for-in does not guarantee any order!). It will however be in right order for small arrays most times.
But could be different on another browser...
Theodore P.
@Ierofantis
Mar 29 2016 12:53
@negyvenketto I want to choose 2(the number outside the array) for example. How can I do this?
Clem
@ctataru
Mar 29 2016 12:54
@Blauelf so you're saying, in some cases roman will be a combination of roman numerals in the wrong order?
negyvenketto
@negyvenketto
Mar 29 2016 12:54
@Ierofantis what do you want to do with it? return arguments[1] will return it. console.log(arguments[1]) will log it.
Theodore P.
@Ierofantis
Mar 29 2016 12:55
I want it to be filtered by the array
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Mar 29 2016 12:56
@thomlom
Hi everyone, I'm having a problem, I'm on the project random quote machine and I would like to do a crossfading on my quotes but it isn't really working, can you help me?
http://codepen.io/thomlom/pen/eZRWLY
Theodore P.
@Ierofantis
Mar 29 2016 12:56
@negyvenketto I want it to be filtered by the array
ElvisTheStriker
@ElvisTheStriker
Mar 29 2016 12:57
Hi. I'm attempting the "profile lookup exercise" and I'm getting a warning stating "expected and indentifier but saw else" ... can anyone help?
Blauelf
@Blauelf
Mar 29 2016 12:58
@ctataru It's not guaranteed that it will be the same order on any engine. But for small arrays, it usually is (larger sparse arrays may be saved in more efficient structures and might return keys in the order of insertion or any other order)
negyvenketto
@negyvenketto
Mar 29 2016 12:59
@Ierofantis the function for filter needs to return true or false. if i'm right yours is trying to return something that is not boolean
Blauelf
@Blauelf
Mar 29 2016 13:00

@ctataru Try this:

var arr=[];
arr[47000000000]=11;
arr[23000000000]=42;
for(i in arr)console.log(i,arr[i]);

For me that gives order of insertion:

47000000000 11
23000000000 42
negyvenketto
@negyvenketto
Mar 29 2016 13:00
@ElvisTheStiker can you paste your code here? it looks like you forgot a semicolon or parenthesis or something
Theodore P.
@Ierofantis
Mar 29 2016 13:01
@negyvenketto ok thanks
CamperBot
@camperbot
Mar 29 2016 13:01
ierofantis sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 329 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
ElvisTheStriker
@ElvisTheStriker
Mar 29 2016 13:03
@negyvenketto unction lookUp(firstName, prop){
// Only change code below this line
//go through contacts array checking for firstname
for (i=0;i<contacts.length;i++){
//console.log(contacts[i].firstname); test
if (contacts[i].firstName == firstName){ //if for firstname and if found
for(j=0;j<contacts[i].length;j++){ //check for the prop
if(contacts[i][j]==prop){
result=contacts[i][j];// if prop found return its value
return result; }
else {
result = "No such property" ; // if not found say so
return result;}
else {
result = "No such contact" ; // if name not found say so
return result;}
}
}
}
getting the warning at the final else
ravitej177
@ravitej177
Mar 29 2016 13:05
@ElvisTheStiker use elseif if u want to use multiple conditions
Blauelf
@Blauelf
Mar 29 2016 13:07
function lookUp(firstName, prop){
  // Only change code below this line
  //go through contacts array checking for firstname  
  for (i=0;i<contacts.length;i++){
    //console.log(contacts[i].firstname); test
    if (contacts[i].firstName == firstName){  //if for firstname and if found

      // contacts[i] is no array, so don't iterate it, check for property by using hasOwnProperty instead

      for(j=0;j<contacts[i].length;j++){  //check for the prop 
        if(contacts[i][j]==prop){
          result=contacts[i][j];// if prop found return its value
          return result; } 
        else { 
          result = "No such property" ; // if not found say so
          return result;} 

    // here a } was missing, I took it from below

  }
   else {

  // This part should probably be outside the loop, after you tested all contacts!

    result = "No such contact" ; // if  name not found say so
    return result;}     
  }
}
ElvisTheStriker
@ElvisTheStriker
Mar 29 2016 13:10
Thanks @Blauelf . I'll check that.
CamperBot
@camperbot
Mar 29 2016 13:10
elvisthestiker sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1468 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Mar 29 2016 13:11

@ElvisTheStiker if-else is easier to read if you follow the style

if (condition1) {
  ...
} else if (condition2) {
  ...
} else {
  ...
}

(of course only the parts you need, but the style is useful as you can easily spot the blocks)
There's also another school that recommends something like

if (condition1)
  {
    ...
  }
else if (condition2)
  {
    ...
  }
else
  {
    ...
  }

(which emphasizes the blocks even more, but needs more space, I recommend the first)

Ramsay Sewell
@ramsaysewell
Mar 29 2016 13:22
When are you able to skip a challenge?
For example the intermediate front end projects, can I move on to algorithms and come back to them later?
Blauelf
@Blauelf
Mar 29 2016 13:22
You can do them in any order.
Ramsay Sewell
@ramsaysewell
Mar 29 2016 13:22
ok
I feel my progress slows down if I spend the entire day working on one project
Leo19909
@Leo19909
Mar 29 2016 13:23
hi all) on my site on the search engine of choice slider city category and actually very search button . I need to when you select cities and categories link on the search button is changed accordingly. Not necessarily so she took the information from the data base itd I can link and write is not difficult.I just want to working search engine by id categories and changed when selecting a link .
Ie need obratchik event , nowhere could find this is possible in the search engine does not correctly write, but they all infa only drop-down list , and there is in fact necessary as all this is to bridge the button search and categories ... That is, if we choose Moscow and videographer then pressing the button to go to find the link www.my-site.ru ( main page there is a machine ) + Select Moscow / moskva + videografi chosen category , and then go to the page www.my-site.ru / moskva / videografi when you click on the search button . All Internet searched , possibly looking for crap ,Who can tell ?
Blauelf
@Blauelf
Mar 29 2016 13:24
@ramsaysewell There are certain challenges required for certificates, but you can do them in any order. And you can and should revisit old challenges to apply what you have learnt and maybe how to solve this in a more elegant, more readable, more efficient, ..., way.
Theodore P.
@Ierofantis
Mar 29 2016 13:27
I am so close to solve seek and destroy algorithm but I can't add multiple return statements.Is there any way to add args1,args2 etc on my return statement?
function destroyer(arr) {


 var args = Array.prototype.slice.call(arguments); 

  function check(i) {

    return i>= args[1];

}    

  var filtered = arr.filter(check);
  return filtered;
}







destroyer([1, 2, 3, 1, 2, 3,7], 2, 3);
negyvenketto
@negyvenketto
Mar 29 2016 13:30
@Ierofantis try adding a for loop?
Ramsay Sewell
@ramsaysewell
Mar 29 2016 13:30
Why doesn’t this work? Math.max(arr)
Blauelf
@Blauelf
Mar 29 2016 13:30
@Ierofantis You can use args.indexOf(i,1)==-1 to check if i is not inside args (the ",1" is for ignore-the-first-as-this-is-arr)
Theodore P.
@Ierofantis
Mar 29 2016 13:30
@negyvenketto yup but It doesn't work
Blauelf
@Blauelf
Mar 29 2016 13:31
@ramsaysewell Math.max needs individual arguments, like Math.max(arr[0],arr[1]). ES6 allows spreading, like Math.max(...arr)
Theodore P.
@Ierofantis
Mar 29 2016 13:31
@Blauelf ok let me try and I will tell you
Trilok reddy
@Trilokreddy007
Mar 29 2016 13:32
plesae help me im not able to understand word blanks concept wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Theodore P.
@Ierofantis
Mar 29 2016 13:33
@Blauelf that worked thank you very much
CamperBot
@camperbot
Mar 29 2016 13:33
ierofantis sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
Brendan Kinahan
@BKinahan
Mar 29 2016 13:33
@Trilokreddy007 return something in the form of "The little cat was hit by a slowly moving water balloon."
CamperBot
@camperbot
Mar 29 2016 13:33
:star: 1469 | @blauelf | http://www.freecodecamp.com/blauelf
Theodore P.
@Ierofantis
Mar 29 2016 13:34
@Blauelf but just asking if you know, there is a way to add multiple return statements?
Samson Alajede
@ajesamson
Mar 29 2016 13:34
@Trilokreddy007 concatenate all the strings passed the wordBlanks
and return the result
Blauelf
@Blauelf
Mar 29 2016 13:35
Return ends execution of the function, how do you want to return multiple times? Or what do you want to do?
Ramsay Sewell
@ramsaysewell
Mar 29 2016 13:36
@Blauelf What’s wrong with this? var newArray = [(Math.max(arr[0], arr[1]), (Math.min(arr[0], arr[1]))];
var newArray = [(Math.max(arr[0], arr[1]), (Math.min(arr[0], arr[1]))];
if that helps…
dhstambolliu
@dhstambolliu
Mar 29 2016 13:37
Blauelf
@Blauelf
Mar 29 2016 13:37
@ramsaysewell Would not use so many parentheses (those are unmatched, that's where it crashes!)
var newArray = [Math.max(arr[0], arr[1]),
                Math.min(arr[0], arr[1])];
Theodore P.
@Ierofantis
Mar 29 2016 13:38
@Blauelf I am just wondering is there a way if you want to have return statements in a sequence. I ve read a way that i don't know if it is possible like
var a =.....;
var b =....;
return [a,b];