These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Mar 2017
Conrad Kay
@conradkay
Mar 19 2017 00:00
i am confused on a regular expression challenge
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:00
@ronnieg1988 how youve written youre case statements is wrong
silver537
@silver537
Mar 19 2017 00:00
@ronnieg1988 yea and make sure it's += and -=
Conrad Kay
@conradkay
Mar 19 2017 00:00

the istructions are:
1) The only numbers in the username have to be at the end. There can be zero or more of them at the end.

2) Username letters can be lowercase and uppercase.

3) Usernames have to be at least two characters long. A two-letter username can only use alphabet letter characters.

HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:00
case 2 case 'K' etc
Conrad Kay
@conradkay
Mar 19 2017 00:00
code so far is
silver537
@silver537
Mar 19 2017 00:00
@HeebieGeeBee na it's right
its a different way
Ronald Johnson
@ronnieg1988
Mar 19 2017 00:01
ah cool it worked thank you @silver537
CamperBot
@camperbot
Mar 19 2017 00:01
ronnieg1988 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 876 | @silver537 |http://www.freecodecamp.com/silver537
Conrad Kay
@conradkay
Mar 19 2017 00:01
let userCheck = /[a-zA-Z]\d$/; // Change this line let result = userCheck.test(username);
^code so far
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:01
ok well its a redundant way of writing them
Conrad Kay
@conradkay
Mar 19 2017 00:01
confused on number 3 mostly
silver537
@silver537
Mar 19 2017 00:02
@HeebieGeeBee yep
but makes for annoying looking code. if you want to annoy the reader
like this
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:03
what would be the purpose of annoying the reader?
Conrad Kay
@conradkay
Mar 19 2017 00:03
^nasty
silver537
@silver537
Mar 19 2017 00:03
have you seen my picture. -.-
im mischievous
:smiling_imp:
john94
@lpy1994
Mar 19 2017 00:05
@HeebieGeeBee
function validatePIN (pin) {
  //return true or false
  var arr = pin.split("");
  for(var i = 0;  i < arr.length; i++){
      if(arr.length === 4 || arr.length === 6 && typeof arr[i] === 'number'){
          return true;
      }
      return false;
  }
}

console.log(validatePIN("1114"));
silver537
@silver537
Mar 19 2017 00:07
@lpy1994 reverse your return logic
and your if statement should be checking for the moment the element is not a number type. but then again, typeof will return string and not number
john94
@lpy1994
Mar 19 2017 00:10
@silver537 try to set arr[i] >= 0
Conrad Kay
@conradkay
Mar 19 2017 00:11

1) The only numbers in the username have to be at the end. There can be zero or more of them at the end.

2) Username letters can be lowercase and uppercase.

3) Usernames have to be at least two characters long. A two-letter username can only use alphabet letter characters.

how would i do that as a regular expression?
JDW
@jd-wheaton
Mar 19 2017 00:12
well that didn't format correctly.
silver537
@silver537
Mar 19 2017 00:12
erase it
JDW
@jd-wheaton
Mar 19 2017 00:13
nice...
silver537
@silver537
Mar 19 2017 00:13
i mean edit it, instead of posting it again
my bad
sounded rude
Xi
@yuman959
Mar 19 2017 00:13
Hi guys, I try to call Wikipedia API to return the title of the article. Why it’s not working? (The request URL is tested to be correct. Something wrong with the callback function) https://codepen.io/yuman959/pen/gmWKag/
JDW
@jd-wheaton
Mar 19 2017 00:14
nah, all good
function lookUpProfile(firstName, prop){
// Only change code below this line
  var a = firstName;
  var b = prop;
  var c;
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == a) {
      console.log("Match: " + a);
      if (contacts[i].hasOwnProperty(b)) {
        c = contacts[i].b;
        console.log("Prop: " + c);
      } else {
        c = "No such property";
        console.log(c);
      }
    } else { 
      console.log("No Match: " + a); 
    }
  }
// Only change code above this line
}
not sure how to return the contents of the likes property, I just get undefined
silver537
@silver537
Mar 19 2017 00:16
idk why you're redefining the variables
JDW
@jd-wheaton
Mar 19 2017 00:16
I will change it after I get it all working
it's just easier for me to read
silver537
@silver537
Mar 19 2017 00:17
post the whole code
with the objects
JDW
@jd-wheaton
Mar 19 2017 00:18
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  var a = firstName;
  var b = prop;
  var c;
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == a) {
      console.log("Match: " + a);
      if (contacts[i].hasOwnProperty(b)) {
        c = contacts[i].b;
        console.log("Prop: " + c);
      } else {
        c = "No such property";
        console.log(c);
      }
    } else { 
      console.log("No Match: " + a); 
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:18
@lpy1994 why are you splitting the pin and why are you using a loop?
john94
@lpy1994
Mar 19 2017 00:19
@HeebieGeeBee ok, I just notice that I need to transform string to number
alfred
@alfed1203
Mar 19 2017 00:19
how do u call the object in that?
im stuck there 2
silver537
@silver537
Mar 19 2017 00:22
@jd-wheaton how do you access an object property with a variable?
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:22
@yuman959 whats wrong exactly?
@yuman959 data is the whole object, so youre just putting the whole object into the html
john94
@lpy1994
Mar 19 2017 00:32
@HeebieGeeBee thank you guys, I think I am getting there.
CamperBot
@camperbot
Mar 19 2017 00:32
lpy1994 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1090 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
john94
@lpy1994
Mar 19 2017 00:32
@silver537 thx
Eugeniu Botnaru
@ebv-gh
Mar 19 2017 00:52
Been playing with this RegEx challenge for the past hour and Its driving me crazy. Someone please help me out! Here is my code:
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

  var cap = /\s*([A-Z][a-z]*)/g;
  return str.replace(cap, "$1-");
}

spinalCase('This Is Spinal Tap');
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:54
@rumpumpum what are you trying to do?
@rumpumpum maybe you should try put in spaces when theres a lowercase letter next to an upper case letter
then replace all the spaces with dashes
Dan Couper
@DanCouper
Mar 19 2017 00:57
@conradkay what you have at the minute finds a string that matches one letter (A-Z or a-z) followed by one digit, then end of string. You can specify two or more of the previous (in your case [A-Za-z]) using {2,} - note the comma is supposed to be there - the curly brackets/number works like if there is just a number, look for that many exactly. If it's a number then a comma then a number, look for at least the first number, up to the second number. If it's a number, then a comma, look for at least that number, as many as you can find in a row. Then you want zero or more, which is *.
Eugeniu Botnaru
@ebv-gh
Mar 19 2017 00:57
Hey @HeebieGeeBee thanks for your feedback. What do you suggest for this case: spinalCase("thisIsSpinalTap”)
CamperBot
@camperbot
Mar 19 2017 00:57
rumpumpum sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1091 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Conrad Kay
@conradkay
Mar 19 2017 00:57
@DanCouper thanks
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 00:58
@rumpumpum what i just said
Dan Couper
@DanCouper
Mar 19 2017 00:59
@conradkay What you had is correct to start off, you just need to add the right quantifie after each item (at least two after the a-z, zero or more after the \d)
Conrad Kay
@conradkay
Mar 19 2017 01:01
let userCheck = /[A-Za-z]{2,}\d$/;
thats what ive got now
Dan Couper
@DanCouper
Mar 19 2017 01:01
Star after the d
Conrad Kay
@conradkay
Mar 19 2017 01:02
@DanCouper thank you
Jasmine Marie Bouges
@jbouges
Mar 19 2017 01:02
i'm not sure why my .join() method is returning numbers instead of a string.

function rot13(str) {
  var strCharCodes = [];
  var charCode;
  for(i = 0; i < str.length; i++) {
      if (str.charCodeAt(i) > 77 && str.charCodeAt(i) <= 90) {
        charCode = str.charCodeAt(i) - 13;
        strCharCodes.push(charCode);
      } else if (str.charCodeAt(i) <= 77 && str.charCodeAt(i) >= 65) {
        charCode = str.charCodeAt(i) + 13;
        strCharCodes.push(charCode);
      } else {
        strCharCodes.push(str[i]);
      }
  }
  console.log(strCharCodes);
  var cipherStr = strCharCodes.join(', ');
  var testStr = String.fromCharCode(cipherStr);
  console.log(cipherStr);
  console.log(testStr);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Dan Couper
@DanCouper
Mar 19 2017 01:02
\d* for zero or more
Conrad Kay
@conradkay
Mar 19 2017 01:02
feel so stupid after this stuff :P
Dan Couper
@DanCouper
Mar 19 2017 01:02
Regex is painful 🙃
Mario Lukic
@pasuljG
Mar 19 2017 01:03
Hi I'm doing project in codepen. I want my js function to open a link in new windows. What can I use instead of windows.open which is overriden
Conrad Kay
@conradkay
Mar 19 2017 01:03
you could use <a> in html
Dan Couper
@DanCouper
Mar 19 2017 01:04
@conradkay I'd put a ^ right at the start as well (given you have the $ at the end) - that means "start of string", often good practice to have the start and end specified when you're doing something like validation, just to ensure you match the entire string
silver537
@silver537
Mar 19 2017 01:05
@rumpumpum you don't need the asterisk, use the g flag instead
Dan Couper
@DanCouper
Mar 19 2017 01:05
Just means nothing else can sneak through
Conrad Kay
@conradkay
Mar 19 2017 01:08
ah
how would remove white spaces at beginning and end of a string?
last question :)
cannot use .trim though
Moisés Man
@moigithub
Mar 19 2017 01:16
" h e l l o ".replace(/(^\s|\s$)/g,"")
// h e l l o
dmg10007
@dmg10007
Mar 19 2017 01:22
var code = "formatted";

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

  result = 'The ' + myAdjective + 'brown ' + myNoun + 'just ' + myVerb + 'very ' + myAdverb + " home.";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog ", "big ", "ran ", "quickly");
wondering why this isnt working for the wordblanks map point?
any help would be appreciated!
PNjinu
@PNjinu
Mar 19 2017 01:23

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

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr)); //This is Stand in Line for JavaScript, where am I going wrong?

Moisés Man
@moigithub
Mar 19 2017 01:24
@dmg10007
u should not add spaces on ur function call wordBlanks("dog ", "big ", "ran ", "quickly");
only inside ur function
dmg10007
@dmg10007
Mar 19 2017 01:25
I guess I could add the space before the wordblank words instead?
Manish Giri
@Manish-Giri
Mar 19 2017 01:31
@PNjinu arr.push(1);
why 1?
HN
@haydennorthcott
Mar 19 2017 01:37

Carrying out the Escape Sequences in Strings challenge.

My code is: var myStr = "FirstLine\r\SecondLine\\nThirdLine"; // Change this line

and this is the error message I am getting: myStr should have encoded text with the proper escape sequences and no spacing.

I don't believe I have a spacing issue.

Joseph
@revisualize
Mar 19 2017 01:38
My selfie stick has arrived!
Nick Sladic
@Nickadiemus
Mar 19 2017 01:42
Can anybody answer a question for me?
Donnie
@Donnie-D
Mar 19 2017 01:43
if i declared a variable in a function as var A;(not assigned a value yet) and ran an if(some sort of true expression to execute below)
{A=10;}
if(some sort of true expression to execute below)
{console.log(A);}
WOULD IT LOG A'S VALUE ON CONSOLE?
Anyone? lol
silver537
@silver537
Mar 19 2017 01:47
@revisualize gonna take a selfie while coding?
@Donnie-D yep
Donnie
@Donnie-D
Mar 19 2017 01:49
@silver537 but a was declared in a separate section local to that and logged in another one .
silver537
@silver537
Mar 19 2017 01:49
you used var to declare
so it's global
Donnie
@Donnie-D
Mar 19 2017 01:50
@silver537 yeah thats right but I assigned the value onlyu locally. didnt I?
Jose Antonio Rivas
@joseantonio
Mar 19 2017 01:52
Greetings
Donnie
@Donnie-D
Mar 19 2017 01:52
lol i dont know how i can run it somewhere to find out. i am a noob
Joseph
@revisualize
Mar 19 2017 01:53
@silver537 Nope.
Donnie
@Donnie-D
Mar 19 2017 01:53
@revisualize is that an answer to my problem?
silver537
@silver537
Mar 19 2017 01:53
@Donnie-D na
to my question earlier
Donnie
@Donnie-D
Mar 19 2017 01:53
oh sorry
silver537
@silver537
Mar 19 2017 01:56
@Donnie-D you assigned a global value locally
JDW
@jd-wheaton
Mar 19 2017 01:56
Getting closer ;/
function lookUpProfile(firstName, prop){
// Only change code below this line
  var propResult;
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      console.log("Match: " + firstName);
      if (contacts[i].hasOwnProperty(prop)) {
        propResult = contacts[i][prop];
        console.log("Prop: " + propResult);
      } else {
        propResult = "No such property";
        console.log(propResult);
      }
    } else { 
      console.log("No Match: " + firstName); 
    }
  }
// Only change code above this line
}
Donnie
@Donnie-D
Mar 19 2017 01:56
yes
@silver537
silver537
@silver537
Mar 19 2017 01:57
so it's still available in any local scope
@jd-wheaton so then what's the problem? your code works
anish khatri
@anishkhatri8080
Mar 19 2017 01:59

Assign the value 7 to variable a.

Assign the contents of a to variable b.

Run tests (ctrl + enter)


// Setup
var myName;
var a = 2;
var b = ;
// Only change code below this line
silver537
@silver537
Mar 19 2017 01:59
@anishkhatri8080 let me ask you something
Joseph
@revisualize
Mar 19 2017 02:00
Hi.
silver537
@silver537
Mar 19 2017 02:00

if i said that this => :apple: is called a house...

and i told you you can have my house, what do i really mean?

Joseph
@revisualize
Mar 19 2017 02:00
@anishkhatri8080 How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
anish khatri
@anishkhatri8080
Mar 19 2017 02:00
@silver537 what do you want to ask me
Joseph
@revisualize
Mar 19 2017 02:01
@silver537 What I call a house and what you call a house are different.
JDW
@jd-wheaton
Mar 19 2017 02:01
@silver537 I can have your apple
silver537
@silver537
Mar 19 2017 02:01
^ exactly
Donnie
@Donnie-D
Mar 19 2017 02:01

@silver537 so in below situation...
var x;
if(true)
{x=10;}
if(true)
{console.log(x);}

value assigned to x under any local scope would be applicable to neighbours as well... Is that correct?

silver537
@silver537
Mar 19 2017 02:02
so when i say, a is equal to 7
but then i want that to be b instead. but 7 is already a
like i gave you an apple and said here have my house
and then you give that apple, which is called house, to someone else and say, here have my car
JDW
@jd-wheaton
Mar 19 2017 02:04
watch out for those apple car's, heard they are buggy
silver537
@silver537
Mar 19 2017 02:05
apple is now called car, but it's also called house too.
car = house
a= b
you're just naming a value.
value doesn't change
Donnie
@Donnie-D
Mar 19 2017 02:07
@jd-wheaton wit :+1: @silver537 :/ but i only called that house as an apple between you and me, when I give that house to someone else and call it an apple, they wont know why I call it an apple.
anish khatri
@anishkhatri8080
Mar 19 2017 02:09

// Setup
var a;
var b = 2;

// Only change code below this line
var b=b+5;
var a = b;
how to assigned a to b
silver537
@silver537
Mar 19 2017 02:10
@Donnie-D i forgot to answer you haha.
it wouldn't matter what you do in the local scope, as long as the variable is declared at the global scope, any local scope can manipulate it.
Joseph
@revisualize
Mar 19 2017 02:11
That's backwards
silver537
@silver537
Mar 19 2017 02:11
lol
hoddedman
@hoddedman
Mar 19 2017 02:12
function reverseString(str) {
  str.split();
  str.reverse();
  str.join();
  return str;
}

reverseString("hello");
silver537
@silver537
Mar 19 2017 02:12
@Donnie-D but in what you're saying with the apple is not the same as scoping. what you're saying is declaring at the local scope level
hoddedman
@hoddedman
Mar 19 2017 02:12
what am I doing wrong?
silver537
@silver537
Mar 19 2017 02:13
so yea, between you and me, it's called house but with someone else, they're not gonna understand it.
because only you and i know it locally
but if we wanted the apple to be called house
then it would be standardized and EVERYONE will know it as house
"how about when you change the value locally?"
well that's like a scientist finding out the real name of the apple which is car
and so now, EVERYONE know the apple's true name; car
Donnie
@Donnie-D
Mar 19 2017 02:15
@silver537 exactly. so if i assigned that global variable only locally and in another local section tried to print the value that i assigned in previous local section but the variable itself was declared globally, would i be able to print that value?
silver537
@silver537
Mar 19 2017 02:16
lol
this is getting out of hand'
Joseph
@revisualize
Mar 19 2017 02:16
@hoddedman So... Strings are immutable.
Donnie
@Donnie-D
Mar 19 2017 02:16
lol
@silver537 pardon me sire
Joseph
@revisualize
Mar 19 2017 02:16

@hoddedman Doing all of this:

  str.split();
  str.reverse();
  str.join();

Doesn't actually change the value of the string because strings are immutable.

silver537
@silver537
Mar 19 2017 02:17
@Donnie-D
var x = 'apple'
if(true){
  x = 'banana'
}

if(true) {
  console.log(x)
}
Joseph
@revisualize
Mar 19 2017 02:17
@anishkhatri8080 How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
silver537
@silver537
Mar 19 2017 02:19
since x was declared globally i can manipulate it in any local scope. which is anything between { }
so the console will log banana because i changed a global variable
but what if i did something like this
hoddedman
@hoddedman
Mar 19 2017 02:20
@revisualize so do I assign str to a variable?
silver537
@silver537
Mar 19 2017 02:22
var x= 23
if(true){
  let x= 1
}

console.log(x)
what do you think we will se in the console?
@Donnie-D
Donnie
@Donnie-D
Mar 19 2017 02:22
1
@silver537
silver537
@silver537
Mar 19 2017 02:23
no
Donnie
@Donnie-D
Mar 19 2017 02:23
@silver537 :/
silver537
@silver537
Mar 19 2017 02:23
23
Donnie
@Donnie-D
Mar 19 2017 02:23
what is let?
silver537
@silver537
Mar 19 2017 02:23
var is flawed
let is like var, but cleaner
Donnie
@Donnie-D
Mar 19 2017 02:24
oh ok thanks
silver537
@silver537
Mar 19 2017 02:24
it lets you initialize variables on the fly in local scopes that you dont need for the entire application, but only on that moment in the app.
then when its use is done, it gets destroyed
Donnie
@Donnie-D
Mar 19 2017 02:25
@silver537 may i ask where (editor) you wrote that text to run it please?
HN
@haydennorthcott
Mar 19 2017 02:26

doesn't work: var myStr = "FirstLine\r\SecondLine\\nThirdLine"; // Change this line

help?

HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 02:26
@haydennorthcott your \r and \n are the wrong way round
Donnie
@Donnie-D
Mar 19 2017 02:27
@silver537 would it take my github login details?
silver537
@silver537
Mar 19 2017 02:27
try that code, then try this code.
var x= 23
if(true){
  let x= 1
  console.log(x)
}

console.log(x)
Donnie
@Donnie-D
Mar 19 2017 02:27
oh sorry lol just saw . it would
silver537
@silver537
Mar 19 2017 02:27
the only difference is a console log
JDW
@jd-wheaton
Mar 19 2017 02:27
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var i = 0; i < contacts.length; i++) {
    if ((contacts[i].firstName == firstName) && contacts[i].hasOwnProperty(prop)) {
      console.log("prop: " + contacts[i][prop]);
      return contacts[i][prop];
    }
    else if (contacts[i].firstName === undefined) {
      console.log("No such contact: " + contacts[i].firstName);
      return "No such contact";
    } 
    else if (!contacts[i][prop]) {
      console.log("No such property: " + contacts[i][prop]);
      return "No such property";
    }
  }
// Only change code above this line
}
Donnie
@Donnie-D
Mar 19 2017 02:27
ok
JDW
@jd-wheaton
Mar 19 2017 02:28
anyone help me with the 1st else if
silver537
@silver537
Mar 19 2017 02:28
@jd-wheaton it's redundant
lol
HN
@haydennorthcott
Mar 19 2017 02:29
@HeebieGeeBee thanks. What logic does that follow?
CamperBot
@camperbot
Mar 19 2017 02:29
haydennorthcott sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1092 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 02:29
@haydennorthcott its just what the challenge asked for
Joseph
@revisualize
Mar 19 2017 02:29
@hoddedman How do you assign a value to a variable?
HN
@haydennorthcott
Mar 19 2017 02:29
@HeebieGeeBee was it this part: FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 02:30
yes
HN
@haydennorthcott
Mar 19 2017 02:30
cool.
silver537
@silver537
Mar 19 2017 02:30
@jd-wheaton if i asked you to look through the phone book for someone, are you just gonna look at the first name, notice that it doesnt match, then throw the phone book away?
JDW
@jd-wheaton
Mar 19 2017 02:30
I'm doing both steps on the first if, I have to test again to return "No such contact" if the firstName value of the firstName property doesn't match
silver537
@silver537
Mar 19 2017 02:30
cause that's what your code is doing
Donnie
@Donnie-D
Mar 19 2017 02:31
@silver537
var x;
if(true){
x=10;
}
if(true){
console.log(x);
}

Native Browser JavaScript

10
=> undefined

JDW
@jd-wheaton
Mar 19 2017 02:31
so your saying to add another if
silver537
@silver537
Mar 19 2017 02:32
nope
JDW
@jd-wheaton
Mar 19 2017 02:32
then I'm not following what your trying to drag me too
silver537
@silver537
Mar 19 2017 02:32
what is the use of return
mainly to return a value right?
JDW
@jd-wheaton
Mar 19 2017 02:33
and to finish*
silver537
@silver537
Mar 19 2017 02:33
nope, it terminates
hehe yea it finishes
JDW
@jd-wheaton
Mar 19 2017 02:33
finish = terminate
silver537
@silver537
Mar 19 2017 02:33
but that sounds more dramatic :D
Donnie
@Donnie-D
Mar 19 2017 02:34
@silver537 btw :+1: for help and letting me do your head in lol . much appreciated
JDW
@jd-wheaton
Mar 19 2017 02:34
what other action can I take here to "return" the props if they exist
Donnie
@Donnie-D
Mar 19 2017 02:35
@silver537 also got my answer so not gonna pester on this one lol
JDW
@jd-wheaton
Mar 19 2017 02:38
I did this...
function lookUpProfile(firstName, prop){
// Only change code below this line
  var result;
  for (var i = 0; i < contacts.length; i++) {
    if ((contacts[i].firstName == firstName) && contacts[i].hasOwnProperty(prop)) {
      console.log("prop: " + contacts[i][prop]);
      result = contacts[i][prop];
    }
    else if (contacts[i].firstName === undefined) {
      console.log("No such contact: " + contacts[i].firstName);
      result = "No such contact";
    } 
    else if (!contacts[i][prop]) {
      console.log("No such property: " + contacts[i][prop]);
      result = "No such property";
    }
    return result;
  }
// Only change code above this line
}
silver537
@silver537
Mar 19 2017 02:41
@jd-wheaton well... first things first, you want to return 'No such contact'; outside of the for loop, because we don't want to prematurely terminate the program.
the only time we want to finish the program inside the loop is when we find
  1. firstname
  2. the property.
    only then will we return contacts[i][prop] and terminate the program.
    but if we managed to find firstname and not the property, then we can return 'No such property'
Joseph
@revisualize
Mar 19 2017 02:42
@jd-wheaton Your for loop isn't looping.
silver537
@silver537
Mar 19 2017 02:43
so in reality, you only need two if statements
one nested within the other
anish khatri
@anishkhatri8080
Mar 19 2017 02:46

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

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

// Change the inputs below to test your code
convertToF(30);
convertToF(10);
silver537
@silver537
Mar 19 2017 02:47
begin function:
  begin loop:
    if statement:
      if statement:
        return values
      else statement:
       return no prop
      end if
    end if
  end loop
  return no such contact
end function
anish khatri
@anishkhatri8080
Mar 19 2017 02:47
this code not returning my value
JDW
@jd-wheaton
Mar 19 2017 02:47
Thanks @silver537 I'll see what I can do with that
CamperBot
@camperbot
Mar 19 2017 02:47
jd-wheaton sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 877 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Mar 19 2017 02:49
convertToF(30); <= what does this mean?
@anishkhatri8080
anish khatri
@anishkhatri8080
Mar 19 2017 02:51
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
silver537
@silver537
Mar 19 2017 02:52
@anishkhatri8080 but what does it mean
convertToF(30);
Roxroy
@roxroy
Mar 19 2017 02:54
@silver537 , it is like a formula, you send in one number lets say 30 and it does the calculation to change it to fahrenheit
silver537
@silver537
Mar 19 2017 02:54
@roxroy i asked @anishkhatri8080 because i want him to understand the point of the statement
@anishkhatri8080 what does convertToF(30); mean?
anish khatri
@anishkhatri8080
Mar 19 2017 02:55
guys if i know that why should i have to ask to u
Roxroy
@roxroy
Mar 19 2017 02:56
@silver537 , I see, I hope he gets it. cheers
silver537
@silver537
Mar 19 2017 02:56
idk anymore lol
Jim
@JLOSS1
Mar 19 2017 02:57
Anybody got a second? need some help with 'Chunky Monkey'
anish khatri
@anishkhatri8080
Mar 19 2017 02:57
i dont get it can you guys explain more about it
susycode
@susycode
Mar 19 2017 02:57

Why can't I understand JavaScript? I keep trying different things to make this add to 88, but it won't accept my answer ever.
var myVar = 87;

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

anish khatri
@anishkhatri8080
Mar 19 2017 02:57
with example
@silver537 and @roxroy
silver537
@silver537
Mar 19 2017 02:58
@susycode cause they want you to use short hand notation
Aaron Fox
@aaronfox
Mar 19 2017 02:58
Hi! I can't figure out why my console won't log this event whenever the new-quote-btn is clicked. It will successfully change the quote with the getNewQuote function, but it will not log the console. Any idea why?
$(document).ready(function() {
    getNewQuote();
    $(".new-quote-btn").on("click", getNewQuote);
    $('.famous-or-movie').on("click", famousOrMovie);
    $(".new-quote-btn").on("click", console.log("PLSWORK"));
  });
susycode
@susycode
Mar 19 2017 02:58
Thank silver537. What's that?
Roxroy
@roxroy
Mar 19 2017 02:58
@anishkhatri8080 , it a like a machine you send in one number lets say 30 celcius and it does the calculation to change it to fahrenheit
silver537
@silver537
Mar 19 2017 02:58
@JLOSS1 ask away
@susycode they show you in the text
Jim
@JLOSS1
Mar 19 2017 02:59
@silver537 I'm pretty sure i'm using push and slice correctly but it's not returning a multiple dimension array. I have
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var array = [arr];
  for (var i = 0; i > arr.length; i += size){
  array.push(arr.slice(i, i + size));
  }
  return array;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
susycode
@susycode
Mar 19 2017 02:59
@silver537 ++ right? I can't make it work.
silver537
@silver537
Mar 19 2017 03:00
@JLOSS1 because array should only be an empty array.
@susycode yea
no spaces
Jim
@JLOSS1
Mar 19 2017 03:00
hm, that's what I thought but it comes back with an empty array.
silver537
@silver537
Mar 19 2017 03:01
oh yea... dont use array
use another name
susycode
@susycode
Mar 19 2017 03:02
var myVar = 87;
myVar = myVar++; ?? doesn't work
Jim
@JLOSS1
Mar 19 2017 03:02
@silver537 okay, changed the name of that variable to thisSucks but it's still outputting an empty array
silver537
@silver537
Mar 19 2017 03:02
did they show you like this? myVar = myVar++
or like this myVar++?
Jim
@JLOSS1
Mar 19 2017 03:03
@susycode just making sure but you are inputting a return command right?
susycode
@susycode
Mar 19 2017 03:04
Maybe. I'm so confused.
silver537
@silver537
Mar 19 2017 03:04
just look and answer my question @susycode its very simple
youll be surprised :P
susycode
@susycode
Mar 19 2017 03:05
@silver537 It's the first one.
silver537
@silver537
Mar 19 2017 03:06
no its supposed to be the second one
Jim
@JLOSS1
Mar 19 2017 03:06
@silver537 I have a > when it's supposed to be a < haha I'm an idiot
silver537
@silver537
Mar 19 2017 03:07
@susycode this is literally in their text
You can easily increment or add one to a variable with the ++ operator.

i++;
susycode
@susycode
Mar 19 2017 03:07
THANK YOU @silver537 !!! Now I'm going to study that to see why I couldn't figure it out.
CamperBot
@camperbot
Mar 19 2017 03:07
susycode sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 878 | @silver537 |http://www.freecodecamp.com/silver537
susycode
@susycode
Mar 19 2017 03:07
I was trying to keep both sides of the equation somehow.
Jim
@JLOSS1
Mar 19 2017 03:07
Thanks for the patience @silver537
CamperBot
@camperbot
Mar 19 2017 03:07
jloss1 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 879 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Mar 19 2017 03:08

Note

The entire line becomes i++;, eliminating the need for the equal sign.
oh you got it
haha im waaaaaay behind
Jim
@JLOSS1
Mar 19 2017 03:09
haha no worries. it was a dumb question anyway.
silver537
@silver537
Mar 19 2017 03:09
no it wasnt
susycode
@susycode
Mar 19 2017 03:09
I'm not sure I have the brain for this. I thought I was good at math, but this is so different.
silver537
@silver537
Mar 19 2017 03:09
its not math
it's logic
which math utilizes.
susycode
@susycode
Mar 19 2017 03:09
Maybe that's my problem.
Forget algebra, think JavaScript. New motto.
silver537
@silver537
Mar 19 2017 03:10
not necessarily.. we've been taught in simple terms. this is this, that is that.
but we always get in trouble for thinking outside the box
so we learned to think without logic
which is why so many people voted for trump
i digress
susycode
@susycode
Mar 19 2017 03:10
Yeah. Now it makes so much sense, looking at it.
And I totally agree on that point!
Jim
@JLOSS1
Mar 19 2017 03:11
@susycode just don't pull your hair out when you get to algorithms.
silver537
@silver537
Mar 19 2017 03:11
but if you do, make sure you donate to the hairless
Jim
@JLOSS1
Mar 19 2017 03:11
hahaha yes. for sure.
susycode
@susycode
Mar 19 2017 03:12
@JLOSS1 is that what you're doing?
Jim
@JLOSS1
Mar 19 2017 03:12
@susycode yeah, only on the basic algorithms. I made the mistake of flying through the lessons not really retaining anything in about a week and now I hit these and have only been able to accomplish one challenge a day so far.
JDW
@jd-wheaton
Mar 19 2017 03:14
finally....
susycode
@susycode
Mar 19 2017 03:14
I went through HTML and CSS like it was kindergarten. This is a whole different world. I feel like I AM a kindergartener now.
Jim
@JLOSS1
Mar 19 2017 03:15
@susycode it get easier very gradually. you'll learn google or bing are your absolute best friends.
JDW
@jd-wheaton
Mar 19 2017 03:15
@silver537 thanks again for your help on the Profile Lookup challenge
CamperBot
@camperbot
Mar 19 2017 03:15
:warning: jd-wheaton already gave silver537 points
jd-wheaton sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
VitaliiUk
@VitaliiUk
Mar 19 2017 03:16

var a;
var b = 2;

var a = 7;
var b = 7;

Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
susycode
@susycode
Mar 19 2017 03:16
Thank you @JLOSS1 . @silver537 is my new best friend tonight. :-)
CamperBot
@camperbot
Mar 19 2017 03:16
susycode sends brownie points to @jloss1 and @silver537 :sparkles: :thumbsup: :sparkles:
Jim
@JLOSS1
Mar 19 2017 03:16
at least I'm racking up my bing points like crazy since starting the algorithms
CamperBot
@camperbot
Mar 19 2017 03:16
:cookie: 262 | @jloss1 |http://www.freecodecamp.com/jloss1
:warning: susycode already gave silver537 points
VitaliiUk
@VitaliiUk
Mar 19 2017 03:16
How can i assign a to b?

@VitaliiUk
var a;
var b = 2;

var a = 7;
var b = 7;
Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =

JDW
@jd-wheaton
Mar 19 2017 03:17
@VitaliiUk a = b
Jim
@JLOSS1
Mar 19 2017 03:17
no problem.
VitaliiUk
@VitaliiUk
Mar 19 2017 03:18
@jd-wheaton no, doesnt work
JDW
@jd-wheaton
Mar 19 2017 03:18
@VitaliiUk try b = a
VitaliiUk
@VitaliiUk
Mar 19 2017 03:18
i should values var a = 7; var b = 7; assign
@jd-wheaton yes it works, from right to left, why i didn't understand this
@jd-wheaton sometimes i think that coding is not for me
Ben Carp
@carpben
Mar 19 2017 03:21
In chromes JS console, how do I enter values from my code? Lets say In my code I have a var x === 10, how can I get the value of X in the console?
JDW
@jd-wheaton
Mar 19 2017 03:21
@VitaliiUk You'll get the hang of it, I just spent about 4 hours on one small block. And had to get help several times.
VitaliiUk
@VitaliiUk
Mar 19 2017 03:21
@jd-wheaton how long do you code?
JDW
@jd-wheaton
Mar 19 2017 03:24
@VitaliiUk I've spent a long time dabbling, this is the first time I've done anything structured. This is a great platform to learn on. Help is always nearby, don't forget to check the forums for help, researching on the web helps as well. I think it's a great service.
Aaron Fox
@aaronfox
Mar 19 2017 03:26
@carpben you should just be able to type x
you should say var x = 10 though without all of the === unless you're trying to compare strict equality
silver537
@silver537
Mar 19 2017 03:34
baddabing
baddaboo
David Amanze
@GodKingShogun
Mar 19 2017 03:36
hello everyone :smile:
anyone still on that can help
tech-tron
@tech-tron
Mar 19 2017 03:37
im guessing Math.max is the highest number (Math.min= lowest) and reduce, which i somewhat recall from a foctorial challenge, will give you the numbers counting it. Right?
Roxroy
@roxroy
Mar 19 2017 03:41
@tech-tron , yes. You just need to put them together to solve the challenge.
silver537
@silver537
Mar 19 2017 03:41
reduce merges all the elements into a single value
depening on your callback
Roxroy
@roxroy
Mar 19 2017 03:42
@GodKingShogun , what up?
tech-tron
@tech-tron
Mar 19 2017 03:45
kind of like concat ?
silver537
@silver537
Mar 19 2017 03:45
no cause you can also do math
tech-tron
@tech-tron
Mar 19 2017 03:47
it just goes from one number to another doing what you tell it for a ,b variables
silver537
@silver537
Mar 19 2017 03:54
we are talking about values. so when you don't pass a value, it will use the first index of the array as it's value, then it manipulates that value with the consecutive elements in the array
tech-tron
@tech-tron
Mar 19 2017 03:56
thx @silver537 i get it
CamperBot
@camperbot
Mar 19 2017 03:56
tech-tron sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 880 | @silver537 |http://www.freecodecamp.com/silver537
tech-tron
@tech-tron
Mar 19 2017 03:56
wonder why they skip the 0 index
without an accumulator does it assumes you are starting with the value at 0 index
silver537
@silver537
Mar 19 2017 04:00
yes
Baraka Mahili
@gbmahili
Mar 19 2017 04:03

I am having an issue with Bootstrap table...I have more than 10 items in my table, I wrote a script that gets me the 'Item' name when I click on it...The Bootstrap page displays 10 by default, but when I go to the next page, I am not getting the item name of anything after the 10th element...It won't even run the script of alert on any item after the 10th

Here is my Codepen code:

http://codepen.io/GBMahili/full/gmXGzb/

bukhari07
@bukhari07
Mar 19 2017 04:03
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
how to solve this
heroiczero
@heroiczero
Mar 19 2017 04:04
@bukhari07 gotta use \n and \r and \ to make the code
Baraka Mahili
@gbmahili
Mar 19 2017 04:04
Any help will be appreciated
silver537
@silver537
Mar 19 2017 04:07
var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
done
Manish Giri
@Manish-Giri
Mar 19 2017 04:07
@gbmahili it works for me..
Baraka Mahili
@gbmahili
Mar 19 2017 04:08
@Manish-Giri How come it works for me, but it can't work for me, did you do anything special to the code?
When you click on item 11 , did it alert 'Item 11'?
Manish Giri
@Manish-Giri
Mar 19 2017 04:09
@gbmahili oh you meant the alert..
I thought you meant the display
hold on..
Baraka Mahili
@gbmahili
Mar 19 2017 04:10
@Manish-Giri Yes, I meant alert
silver537
@silver537
Mar 19 2017 04:10
ugh i want to code.... but then i remember how annoying coding is
Drew Steiner
@absteiner
Mar 19 2017 04:11

I'm not sure what I did wrong. I followed the example on // Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

testObj["hamburger"]; // Change this line
testObj['water']; // Change this line

Accessing Objects Properties with Bracket Notation
Nick Sladic
@Nickadiemus
Mar 19 2017 04:12
@absteiner Are you trying to access the object or change the contents?
Sandip Shrestha
@saninmersion
Mar 19 2017 04:13
@absteiner you need to acess value hamburger and for that you need to point to an entree not hamburger itself. it's key value pair thinh
Roxroy
@roxroy
Mar 19 2017 04:14
@absteiner , the order is key : value , use the left side for your testObj
heroiczero
@heroiczero
Mar 19 2017 04:14
@absteiner gotta us the an entree key value to access the property
Manish Giri
@Manish-Giri
Mar 19 2017 04:21
@gbmahili done.
Baraka Mahili
@gbmahili
Mar 19 2017 04:22
@Manish-Giri did you find the error?
Manish Giri
@Manish-Giri
Mar 19 2017 04:22
change your JS code to this
$(document).ready(()=>{$('#item_list').DataTable();})

$('.ct').click(function() {

  var x = $(this).text();
  //alert (x);
  //alert(typeof(x));
  alert(x);
});
Baraka Mahili
@gbmahili
Mar 19 2017 04:23
@Manish-Giri Thanks...let me try it
CamperBot
@camperbot
Mar 19 2017 04:23
gbmahili sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4819 | @manish-giri |http://www.freecodecamp.com/manish-giri
Baraka Mahili
@gbmahili
Mar 19 2017 04:27
@Manish-Giri Thanks so much, that fixed the issue...can you explain why mine wasn't working?
CamperBot
@camperbot
Mar 19 2017 04:27
:warning: gbmahili already gave manish-giri points
gbmahili sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Mar 19 2017 04:28
@gbmahili I think it was an initialization issue...the plugin needs to be initialized with the table on the current page (probably)
rznova17
@rznova17
Mar 19 2017 04:31
Anyone can help with Testing Objects for Properties?
Baraka Mahili
@gbmahili
Mar 19 2017 04:31
@Manish-Giri Awesome...thanks again
CamperBot
@camperbot
Mar 19 2017 04:31
gbmahili sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: gbmahili already gave manish-giri points
Manish Giri
@Manish-Giri
Mar 19 2017 04:31
@gbmahili :+1:
heroiczero
@heroiczero
Mar 19 2017 04:32
@rznova17 what did you do so far?
rznova17
@rznova17
Mar 19 2017 04:32

function checkObj(checkProp) {
// Your Code Here

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

heroiczero
@heroiczero
Mar 19 2017 04:34
@rznova17 myObj.hasOwnProperty("gift") not only "gift" but checkProp
Jor
@joreyesl
Mar 19 2017 04:34
@rznova17 you need to use checkProp when checking if myObjhas that property. Dont use literal "gift"
rznova17
@rznova17
Mar 19 2017 04:37
so this?:

function checkObj(checkProp) {
// Your Code Here

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

}

ran it, it works :)
thanks guys!
Jor
@joreyesl
Mar 19 2017 04:39
@rznova17 yea that looks correct
rznova17
@rznova17
Mar 19 2017 04:43
but how is checkProp referring back to the object property in var myObj?
I'm missing something :/
bionbro
@bionbro
Mar 19 2017 04:56
I'm lost on the convert celsius to fahrenheit
VitaliiUk
@VitaliiUk
Mar 19 2017 04:58
@bionbro you can see video on youtube
bionbro
@bionbro
Mar 19 2017 04:58
ok thanks!
JenimDacket
@JenimDacket
Mar 19 2017 05:14
My code looks like the numerical embodiment of attention deficit disorder
I mean, it goes, but.....
Would anyone be so kind as to help me clean this up?

function mutation(arr) {
var arr2 = arr[1].toString().toLowerCase().split("");  
var arr3 = [];
  for (i=0; i<arr2.length; i++){
    arr3.push(arr[0].toLowerCase().indexOf(arr2[i]));



  }
  if (arr3.indexOf(-1)!==-1){
    return false;
  }
  else {return true;}
}

mutation(["Mary", "Army"]);
Herman Fassett
@HermanFassett
Mar 19 2017 05:17
Like how much clean it up
Jor
@joreyesl
Mar 19 2017 05:17
@rznova17 checkProp is a parameter in the function. when you do checkObj("gift") you are passing "gift" as an argument to the function checkObj() and since we have defined a parameter checkProp then "gift" is copied to that variable and so inside the the function we can check if "gift" property exists by using checkProp
Nick Sladic
@Nickadiemus
Mar 19 2017 05:19
@JenimDacket Here's a more advance and clean version of it
function mutation(arr) {
  return arr[1].toLowerCase()
    .split('')
    .every(function(letter) {
      return arr[0].toLowerCase()
        .indexOf(letter) != -1;
    });
}
Herman Fassett
@HermanFassett
Mar 19 2017 05:19
Yeah every is the best for function solution
JenimDacket
@JenimDacket
Mar 19 2017 05:19
whaaaaaaaaaaaaaaaat
no more "for" statements?
<3
idrees khan
@khanidrees
Mar 19 2017 05:20
function truncateString(str, num) {
// Clear out that junk in your trunk
if((num<str.lenght)&&(num>3)){
str=str.slice(0,num-3);
str+="...";
return str;
}else{
if(num>=str.length){
return str;
}else{
str=str.slice(0,num);
str+="...";
return str;
}
}
}
Herman Fassett
@HermanFassett
Mar 19 2017 05:20
If you don't know all the functional stuff, my first attempt a good year+ ago:
function mutation(arr) {
  for (var i = 0; i < arr[1].length; i++) {
    if(arr[0].toLowerCase().indexOf(arr[1].toLowerCase()[i]) === -1)
      return false;
  }
  return true;
}
idrees khan
@khanidrees
Mar 19 2017 05:20
help me
JenimDacket
@JenimDacket
Mar 19 2017 05:22
@HermanFassett I was trying to do this exact way, but my (hello, hey) kept coming out true for some reason... I'm not sure what I was missing.
Anyway, thanks @HermanFassett
CamperBot
@camperbot
Mar 19 2017 05:22
jenimdacket sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1691 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Mar 19 2017 05:23
;)
JenimDacket
@JenimDacket
Mar 19 2017 05:23
@Nickadiemus Could you explain the .every() method? does that function as "for" statement?
Herman Fassett
@HermanFassett
Mar 19 2017 05:23
Well you misspelled length @khanidrees :D
idrees khan
@khanidrees
Mar 19 2017 05:23
ya
thanks @HermanFassett
CamperBot
@camperbot
Mar 19 2017 05:24
khanidrees sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1692 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Ben Carp
@carpben
Mar 19 2017 05:26
@aaronfox Are u sure? I don't think this is correct. My experience is that u can't access variables in this way from the chrome console.
Nick Sladic
@Nickadiemus
Mar 19 2017 05:26
@JenimDacket The every() method tests whether all elements in the array pass the test implemented by the provided function.
JenimDacket
@JenimDacket
Mar 19 2017 05:27
@Nickadiemus I just read the link Herman posted.... That is such an amazing method! =D
@Nickadiemus Thanks man!
CamperBot
@camperbot
Mar 19 2017 05:27
jenimdacket sends brownie points to @nickadiemus :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @nickadiemus |http://www.freecodecamp.com/nickadiemus
Herman Fassett
@HermanFassett
Mar 19 2017 05:28
There are a few methods like that that can really simplify some situations :thumbsup: just don't ridicule the simplicity of a for loop and try never to use it
What I mean is, sometimes people try all sorts of fancy stuff when a for loop would be much better xD
JenimDacket
@JenimDacket
Mar 19 2017 05:29
Could you give me an example situation?
Every challenge I have done so far, I think, could have been completed with "for" substituted for .every()
I am aware that I am just a bab in the eyes of code though.. haha
Herman Fassett
@HermanFassett
Mar 19 2017 05:31
Hmm?
Vikram
@vikramnr
Mar 19 2017 05:31

Hi All. This is my code for counting cards in js tasksvar count = 0;

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

case 1:
case 2:
case 3:
case 4:
     count=(count+1);
     count=count.toString(); 
     count= count+ " Bet";
  break;
case 7:
case 8:
case 9:

  count=count.toString();
  count=count+" Hold";
  break;
case 10:
case "J":
case "Q":
case "K":
case "A":
  count=(count-1);
  count=count.toString();
  count = count+ "Hold";

}
return count;

// Only change code above this line
}

This code is not passing the test?? Any reason why?
Jor
@joreyesl
Mar 19 2017 05:32
@JenimDacket js has nice utility methods to help with common tasks, but you should learn how they work under the hood. Try to see if you can create a function with the same functionality as .every()
JenimDacket
@JenimDacket
Mar 19 2017 05:33
@joreyesl Don't worry, I did... hahaha I overdid it even. My code for mutations was a bit robust.
Herman Fassett
@HermanFassett
Mar 19 2017 05:35
often functions like forEach might be easier but also less efficient than a simple for loop
@vikramnr you probably want to keep count separate from a string... If you make count a string, then the next function call will not work how you want when trying to increment/decrement count.
silver537
@silver537
Mar 19 2017 05:39
imagine if we have the network key?
posh everyone would be hacking everyone
and then sadly realize it gets boring
philiplee15
@philiplee15
Mar 19 2017 05:49
any opinions on coding dojo vs hack reactor?
Aaron Bell
@awb715
Mar 19 2017 05:49
are you in seattle @philiplee15
Joseph
@revisualize
Mar 19 2017 05:50
@vikramnr you need to return based on the value of count. Not based on the value of the card.
idrees khan
@khanidrees
Mar 19 2017 05:50
how to do the chunky monkey
Joseph
@revisualize
Mar 19 2017 05:51
@vikramnr Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Aaron Bell
@awb715
Mar 19 2017 05:51
@revisualize you should write a ebook based on freecodecmap challenges and sell it for a dollar or something
MR-Em
@MR-Em
Mar 19 2017 05:52
Concatenating strings
Anyone can help with that
With plus equal operator
philiplee15
@philiplee15
Mar 19 2017 05:54
@awb715 im currently in LA
Sandip Shrestha
@saninmersion
Mar 19 2017 05:55
@MR-Em += will append a string if you are working with strings
tylerccarson
@tylerccarson
Mar 19 2017 05:57
Mind the lack of styling, project is still barebones. Why won’t my div elements display the api code that I want them to?
http://codepen.io/tylerccarson/pen/GWrvxW?editors=1010
Thanks!
VitaliiUk
@VitaliiUk
Mar 19 2017 06:02
Can you help me,how can I change

var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
Correct the assignment to myStr to achieve the desired effect.

Ben Carp
@carpben
Mar 19 2017 06:02
In chromes JS console, how do I enter values from my code? Lets say In my code I have a var x === 10, how can I get the value of X in the console?
Sandip Shrestha
@saninmersion
Mar 19 2017 06:03
console.log(x) ? @carpben
@tylerccarson are you getting any data from openweather api. if not it maybe coz you have not specified measurement system in api url
Aaron Bell
@awb715
Mar 19 2017 06:04
anyone up to steamroller?
Ben Carp
@carpben
Mar 19 2017 06:04
@saninmersion
blob
Sandip Shrestha
@saninmersion
Mar 19 2017 06:05
@VitaliiUk string values cannot be accessed like that you need to split your string, change the first char value to H and then join it and return that
Ben Carp
@carpben
Mar 19 2017 06:06
@saninmersion @aaronfox => The answer is not obvious as console.log(x). Here is a screenshot.
blob
Any one know how to access a varaiable from out code in the Chrome's console?
MR-Em
@MR-Em
Mar 19 2017 06:06
@saninmersion tried. Didn't work
Sandip Shrestha
@saninmersion
Mar 19 2017 06:07
I actually use console.log on my code. chrome dev tools I have noy used much
@MR-Em what did u try
post your code
MR-Em
@MR-Em
Mar 19 2017 06:08
Var mystr = "This is the first sentence"
Sandip Shrestha
@saninmersion
Mar 19 2017 06:08
and?
MR-Em
@MR-Em
Mar 19 2017 06:08
Var myStr; this is the second sentence "
Jor
@joreyesl
Mar 19 2017 06:09
@MR-Em var should be lower case
MR-Em
@MR-Em
Mar 19 2017 06:09
With a +=
Yep
@joreyesl yep, phone is doing automatically. Apologies
silver537
@silver537
Mar 19 2017 06:10
weeee javascript so fuuuuuun
Jor
@joreyesl
Mar 19 2017 06:10
@MR-Em also make sure the strings are identically to what they want you to write, spaces capitalization matters
silver537
@silver537
Mar 19 2017 06:10
punctuations too
Jor
@joreyesl
Mar 19 2017 06:11
@MR-Em first sentence should be "This is the first sentence. " second sentence "This is the second sentence.". Make sure you are typing them exact.
Sandip Shrestha
@saninmersion
Mar 19 2017 06:13
when updatinh myStr you dont define it again with var
MR-Em
@MR-Em
Mar 19 2017 06:13
You dont?
silver537
@silver537
Mar 19 2017 06:14
no cause you've already initialized myStr
MR-Em
@MR-Em
Mar 19 2017 06:14
Oh bleeding hell. One full stop..
Was the mistake
Oh yes that's what I've actually done. Not sure why I wrote var again
Thank you all for your help
Rudy Hernandez
@rudolphh
Mar 19 2017 06:32
@carpben var x === 10 is not a valid statement var x = 10 is and then you can console.log(x) and it would say 10 in the console
'===' is for equality so lets say var x = 5 then you did console.log(x===10) it would say false in the console
andry91959
@andry91959
Mar 19 2017 06:38
hi, I am looking for website similar with python tutor where I can visualise my code
Joseph
@revisualize
Mar 19 2017 06:38
@andry91959 What kind of code?
andry91959
@andry91959
Mar 19 2017 06:38
java script
Joseph
@revisualize
Mar 19 2017 06:38
andry91959
@andry91959
Mar 19 2017 06:38
with some of the reason I couldnt use python tutor
it keep crashing
any similar website?
Joseph
@revisualize
Mar 19 2017 06:39
@andry91959 The console.
@andry91959 You can put:
debugger();
inside of your function as the first line.
Vijay S
@kvijay7275
Mar 19 2017 06:39
Hello guys, stuck at a point Unexpected token !=
Joseph
@revisualize
Mar 19 2017 06:40
@andry91959 Which lesson are you working on?
andry91959
@andry91959
Mar 19 2017 06:40
there is no particular
and I only use console.log on python tutor this message comes up
Server error! Your code might be taking too much time to run or using too much memory.
Or the server has CRASHED due to too many people using it at once. Try again later or
report a bug to philip@pgbovine.net by clicking the 'Generate permanent link' button
at the bottom of this page and including a URL in your email.
I currently use laptop
Joseph
@revisualize
Mar 19 2017 06:41
@andry91959 Look up what debugger(); does
andry91959
@andry91959
Mar 19 2017 06:41
but when I use pc there is no problem
Vijay S
@kvijay7275
Mar 19 2017 06:42
My validatoin form is not working. Unexpected token !=
I wonder if anyone could help me out.
andry91959
@andry91959
Mar 19 2017 06:42
It doesnt work. so I visit similar website the other day but I couldnt remember the address
tylerccarson
@tylerccarson
Mar 19 2017 06:44
@saninmersion even specifiying a measurement system doesn’t seem to help either. It doesn’t look like I’m getting any data in the first place not sure what would be preventing in here
Rudy Hernandez
@rudolphh
Mar 19 2017 06:49
@andry91959 try debugger; (its a statement not a function)
Rohan Sharma
@RhnSharma
Mar 19 2017 06:49
can someone help me on profile lookup problem
Here's my codee
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
if(firstName===true || prop===true){
  return "firstName prop";
}else if(firstName===false){
  return "No such contact";
}else if(prop===false){
  return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Rohan Sharma
@RhnSharma
Mar 19 2017 06:58
????
Rudy Hernandez
@rudolphh
Mar 19 2017 07:03
It wants you to loop through the contacts and make the checks
idrees khan
@khanidrees
Mar 19 2017 07:07

function destroyer(arr) {
arr=arr.filter(function(value){
if(value!==arguments1){
return value;
}

});
arr=arr.filter(function(value){
if(value!==arguments2){
return value;
}

});
return arr;
}

help
Shantanu Lawande
@Shantanu337
Mar 19 2017 07:08
need hwlp with Caesars cipher

function rot13(str) {

var str2 = "";
for(var i=0;i<str.length;i++){
str2 += String.fromCharCode(str.charCodeAt(i)-13);
}
return str2;
}

Rudy Hernandez
@rudolphh
Mar 19 2017 07:15
Idrees filter needs to return a true or false so try and rewrite the function within
Cory Bowles
@cbconsulting
Mar 19 2017 07:16
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
having a moment with this one

function nextInLine(arr, item) {
// Your code here
nextInLine([0],1);
return item; // Change this line
}

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

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

idrees khan
@khanidrees
Mar 19 2017 07:18
@rudolphh then why it worked in falsy bouncer

function bouncer(arr) {
arr=arr.filter(function(value){
if((value!==false)&&(value!==null)&&(value!==0)&&(value!==undefined)&&(value!=="")&&(value!==NaN)){

return value;   

}
});// Don't show a false ID to this bouncer.
return arr;
}

Rudy Hernandez
@rudolphh
Mar 19 2017 07:18
Shantanu you only want to change the alphabetic characters and let other types of chars through
Because all you had to do in falsy is this
return value within filter. If the value was true it will be in the final returned array which your logic did; although in an admittedly more complicated way
arr = arr.filter(function(value){ return value; });
Shantanu Lawande
@Shantanu337
Mar 19 2017 07:22
@rudolphh .i'll give that a try
Rudy Hernandez
@rudolphh
Mar 19 2017 07:24
I used regex for that if you're familiar shantanu
Cory look at using array push and shift methods
Cory Bowles
@cbconsulting
Mar 19 2017 07:25
function nextInLine(arr, item) {
// Your code here
arr.push(1);
arr.pop(2);
return item; // Change this line
}
Rudy Hernandez
@rudolphh
Mar 19 2017 07:26
Pop removes from the end shift removes from the front
Cory Bowles
@cbconsulting
Mar 19 2017 07:26
unshift
Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Rudy Hernandez
@rudolphh
Mar 19 2017 07:28
Unshift actually puts an element in the front. Confusing to me at first too
idrees khan
@khanidrees
Mar 19 2017 07:28
@rudolphh why this code is working
function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
args.splice(0, 1);
for(var i=0;i<=args.length;i++){
arr=arr.filter(function(value){
if(value!==args[i])
return value;
});
}
return arr;
}
and first one not

function destroyer(arr) {
arr=arr.filter(function(value){
if(value!==arguments[1]){
return value;
}

});
arr=arr.filter(function(value){
if(value!==arguments[2]){
return value;
}

});
return arr;
}

VitaliiUk
@VitaliiUk
Mar 19 2017 07:31
Help me please
function fun1() {
// Assign 5 to oopsGlobal Here
ooopsGlobal = 5;
}
Rudy Hernandez
@rudolphh
Mar 19 2017 07:31
I'm not at my laptop to test idrees but if it works! Lol
VitaliiUk
@VitaliiUk
Mar 19 2017 07:31
Inside function fun1, assign 5 to oopsGlobal without using the var keyword.
Gulsvi
@gulsvi
Mar 19 2017 07:32

@aaronfox I don't know if you got your answer, but you pass variables in functions as arguments. Kind of like:

function a() {
  var text = 'hello';
  b(text);
}

function b(string) {
  c(string);
}

function c(textString) {
  d(textString);
}

function d(myString) {
  console.log(myString) // hello
}

a();

Same with your location callback function(position), you just need to pass the argument to whatever function or functions need it.

Rudy Hernandez
@rudolphh
Mar 19 2017 07:32
I'll give some feedback in a bit on that
VitaliiUk
@VitaliiUk
Mar 19 2017 07:32
Inside function fun1, assign 5 to oopsGlobal without using the var keyword.
function fun1() {
// Assign 5 to oopsGlobal Here
ooopsGlobal = 5;
}
Luke Sallmen
@LukeSallmen
Mar 19 2017 07:32
say I have an obj
var someObject = {
1: "a",
2:  "b",
3: "c", };
how do I access someObject in the general sense
like if someObject has property [x], then I can do something else
Cory Bowles
@cbconsulting
Mar 19 2017 07:33
Still have trouble with this problem
VitaliiUk
@VitaliiUk
Mar 19 2017 07:33
How can I assign without var?
@VitaliiUk
Inside function fun1, assign 5 to oopsGlobal without using the var keyword.
function fun1() {
// Assign 5 to oopsGlobal Here
ooopsGlobal = 5;
}
idrees khan
@khanidrees
Mar 19 2017 07:33
u can access @rudolphh
Cory Bowles
@cbconsulting
Mar 19 2017 07:33
i know i am close witht he push/unshift and splice
idrees khan
@khanidrees
Mar 19 2017 07:33
link
Rudy Hernandez
@rudolphh
Mar 19 2017 07:36
Cory don't need splice
Cory Bowles
@cbconsulting
Mar 19 2017 07:36

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

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

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

nextInLine([5,6,7,8,9], 1) should return 5
then i get this last check box
Manish Giri
@Manish-Giri
Mar 19 2017 07:36
@truepalyer6 use arr not testArr
Cory Bowles
@cbconsulting
Mar 19 2017 07:36
not checke
Manish Giri
@Manish-Giri
Mar 19 2017 07:36
because function nextInLine(arr, item)
Cory Bowles
@cbconsulting
Mar 19 2017 07:37
bahahahah
i got it thanks you @Manish-Giri
CamperBot
@camperbot
Mar 19 2017 07:37
truepalyer6 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4820 | @manish-giri |http://www.freecodecamp.com/manish-giri
Cory Bowles
@cbconsulting
Mar 19 2017 07:38
and thank you @rudolphh
@rudolphh Thanks
CamperBot
@camperbot
Mar 19 2017 07:38
truepalyer6 sends brownie points to @rudolphh :sparkles: :thumbsup: :sparkles:
:warning: The user instance is not valid. Details: username User already exists (value: "rudolphh"); username is not unique (value: "rudolphh").
Rudy Hernandez
@rudolphh
Mar 19 2017 07:38
Np you got it
Idrees so close but no need to for loop and filter. Can use one or the other
Cory Bowles
@cbconsulting
Mar 19 2017 07:39
still not truly understanding how i figured this problem out
.push and .shift i get why that was needed
but the item= arr[0];

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

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

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

What was the reason for item = arr[0];
Manish Giri
@Manish-Giri
Mar 19 2017 07:40
you don't need it
that's not totally right also
Rudy Hernandez
@rudolphh
Mar 19 2017 07:40
It's not needed if you did item=arr.shift();
Manish Giri
@Manish-Giri
Mar 19 2017 07:40
all you need is return arr.shift();
Rudy Hernandez
@rudolphh
Mar 19 2017 07:41
Or return arr.shift();
Cory Bowles
@cbconsulting
Mar 19 2017 07:41
gotcha
thought i knew arrays
Gulsvi
@gulsvi
Mar 19 2017 07:41
  arr.push(item);
  return arr.shift();
Cory Bowles
@cbconsulting
Mar 19 2017 07:41
interesting on different perspectives why it behaves that way
Luke Sallmen
@LukeSallmen
Mar 19 2017 07:41
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
   if (myObj.hasOwnProperty() === false) {
return "Not Found";}
  return checkObj[];

}
so I'm trying to figure out how to access an object like myObj
idrees khan
@khanidrees
Mar 19 2017 07:42
@rudolphh by nesting of for right
Luke Sallmen
@LukeSallmen
Mar 19 2017 07:42
and determine if it has a property
Gulsvi
@gulsvi
Mar 19 2017 07:42
That's all it asks you to do - push an item, then remove an item and return what was removed. return arr.shift() removes the first item and returns it
idrees khan
@khanidrees
Mar 19 2017 07:42
?
Luke Sallmen
@LukeSallmen
Mar 19 2017 07:42
but the return checkObj[] part is obviously wrong but I'm not sure what it should be.
myObject[gift] is defined, for example, then it should return the other value "pony"
Any one have any tips or advice?
Cory Bowles
@cbconsulting
Mar 19 2017 07:44
@SkyCoder01 Thanks
CamperBot
@camperbot
Mar 19 2017 07:44
truepalyer6 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 576 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Rudy Hernandez
@rudolphh
Mar 19 2017 07:44
No. Can I just show you mine? Lol jk (kinda) I'm sorry still not at the laptop. Typing this in on the phone sucks
Gulsvi
@gulsvi
Mar 19 2017 07:45
@truepalyer6 No problem, it can get confusing which one does what, names aren't intuitive.. .pop(), .push(), .shift(), .unshift()
image.png
^^ That's helped me a lot
Cory Bowles
@cbconsulting
Mar 19 2017 07:46
yes in deed
Alimi Kehinde Morufudeen
@marusoft
Mar 19 2017 07:46
pls fellow camper,help me on this challenge:
Gulsvi
@gulsvi
Mar 19 2017 07:46
still doesn't say which one returns length vs the item that was added/removed
Cory Bowles
@cbconsulting
Mar 19 2017 07:46
any visual aids help out understand what i am typing
Rudy Hernandez
@rudolphh
Mar 19 2017 07:46
Nice image sky
Alimi Kehinde Morufudeen
@marusoft
Mar 19 2017 07:46

@marusoft function myLocalScope() {
'use strict';
myVar = "";

console.log(myVar);
}
myLocalScope();

I need help on this challenge:function myLocalScope() {
'use strict';
myVar = "";

console.log(myVar);
}
myLocalScope();

Nobuhito-Nishi
@Nobuhito-Nishi
Mar 19 2017 07:48
palindrome("1 eye for of 1 eye.") returns true. It supposed to return false. Why??
Rudy Hernandez
@rudolphh
Mar 19 2017 07:49
Idrees stick with filter. Check out the documentation on mdn
Nobuhito-Nishi
@Nobuhito-Nishi
Mar 19 2017 07:50
function palindrome(str) {
var string = str.replace(/\s|[^a-z A-Z]/g,"").toLowerCase();
var reverse = string.split("").reverse().join("");
return string === reverse;
}
VitaliiUk
@VitaliiUk
Mar 19 2017 07:51
Help someone with lesson Global Scope and Functions
Cory Bowles
@cbconsulting
Mar 19 2017 07:51
@VitaliiUk
whats the problem
VitaliiUk
@VitaliiUk
Mar 19 2017 07:52
Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

function fun1() {
// Assign 5 to oopsGlobal Here

}

Rudy Hernandez
@rudolphh
Mar 19 2017 07:53
...
Cory Bowles
@cbconsulting
Mar 19 2017 07:53
ok
What have you typed out so far
VitaliiUk
@VitaliiUk
Mar 19 2017 07:54
I've typed oopsGlobal = 5;
Alimi Kehinde Morufudeen
@marusoft
Mar 19 2017 07:55
pls help help me on Local Scope and Function challenge.I couldn't submit the challeng
Cory Bowles
@cbconsulting
Mar 19 2017 07:55
ok but you did not declare the variables above
so you should be geting a error telling you it has not been declared
VitaliiUk
@VitaliiUk
Mar 19 2017 07:56
@truepalyer6 I've solved this problem thanks
CamperBot
@camperbot
Mar 19 2017 07:56
vitaliiuk sends brownie points to @truepalyer6 :sparkles: :thumbsup: :sparkles:
:cookie: 183 | @truepalyer6 |http://www.freecodecamp.com/truepalyer6
Cory Bowles
@cbconsulting
Mar 19 2017 07:56
@VitaliiUk
glad i can help
Ben Carp
@carpben
Mar 19 2017 07:57
@rudolphh I know that. You can take a look at the screenshot at the forum to understand what I'm referring to. https://forum.freecodecamp.com/t/how-do-i-access-a-variable-from-chromes-console/98029
Rudy Hernandez
@rudolphh
Mar 19 2017 07:59
I used recursion nobuhito but your regex is prob off. You can test it at regex101.com
@carpben sorry let me see
idrees khan
@khanidrees
Mar 19 2017 08:04

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

}

getIndexToIns([3, 10, 5], 3);

why this code is not returning 0
Rudy Hernandez
@rudolphh
Mar 19 2017 08:21
@carpben so updating chrome solved it? interesting.
@khanidrees no need to sort
Rudy Hernandez
@rudolphh
Mar 19 2017 08:29
@khanidrees hint: use a variable to track the index you want to insert and update it (+1) as it passes the test logic
drowningpool5
@drowningpool5
Mar 19 2017 08:30

Hi people :) How could I achieve the same result with DRY rule?...


function sym(args) {  

  var array = [];
  var arg = Array.prototype.slice.call(arguments);

  var one,
      two,
      three,
      four,
      five;

  if (arg.length === 2) {
    one = arg[0].filter(function(a, b, arr) {
      return arr.indexOf(a) == b;
    });
    two = arg[1].filter(function(a, b, arr) {
      return arr.indexOf(a) == b;
    });
    var first = one.concat(two);
  } else if (arg.length === 3) {
    one = arg[0].filter(function(a, b, arr) {
      return arr.indexOf(a) == b;
    });
    two = arg[1].filter(function(a, b, arr) {
      return arr.indexOf(a) == b;
    });
    three = arg[2].filter(function(a, b, arr) {
      return arr.indexOf(a) == b;
    });
    var second = one.concat(two.concat(three));
  }

  return second;

}

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

I am trying to filter each array (remove the duplicates) and then concat everything together :)

Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:30
hello everyone help me to write the counting card code?
help me please
drowningpool5
@drowningpool5
Mar 19 2017 08:31
@Alvin2410 what do you need?
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:31
@drowningpool5 yes...
drowningpool5
@drowningpool5
Mar 19 2017 08:32
@Alvin2410 where are you stuck?
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:32
check out my code first

var count = 0;

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

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

drowningpool5
@drowningpool5
Mar 19 2017 08:32
@Alvin2410 use ```js
@drowningpool5 [code]
@drowningpool5 ```
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:33
which js code?
drowningpool5
@drowningpool5
Mar 19 2017 08:34
no... in this message start the message with ```js
then enter your code..
and then end everything with ```
this way you will paste the code in a more readable way
SR
@sourabhrangdal
Mar 19 2017 08:35

help: i am stuck. from below code, can anyone tell me where i am doing wrong. sorry, i am beginner and little slow.

challenge: profile lookup

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

// Only change code above this line
}
Rudy Hernandez
@rudolphh
Mar 19 2017 08:37
@sourabhrangdal very close. in the for loop you need a length for one
SR
@sourabhrangdal
Mar 19 2017 08:37
@rudolphh like this
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (contacts.firstName[i] == firstName) {
    if (contacts.hasOwnProperty(prop)) {
      return contacts[i][prop];
    } 
  } return "No such contact";
} 
  return "No such property";

// Only change code above this line
}
drowningpool5
@drowningpool5
Mar 19 2017 08:38
@Alvin2410 first of all... do you know what's the difference between = and === ?
SR
@sourabhrangdal
Mar 19 2017 08:39
@rudolphh it returns
TypeError: Cannot read property '0' of undefined
Rudy Hernandez
@rudolphh
Mar 19 2017 08:40
is there even a contacts variable above?
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:41
@drowningpool5 yes
SR
@sourabhrangdal
Mar 19 2017 08:41
@rudolphh
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Rudy Hernandez
@rudolphh
Mar 19 2017 08:41
then that has nothing to do with the length part
drowningpool5
@drowningpool5
Mar 19 2017 08:42
@Alvin2410 what is the difference?
Rudy Hernandez
@rudolphh
Mar 19 2017 08:42
in your first logic part within the loop, think about what you're trying to access to '===' (not '==') firstName
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:43
= means assigned while === strictly equal to
@drowningpool5
Rudy Hernandez
@rudolphh
Mar 19 2017 08:43
contacts is the entire array, you want to access an individual contact
SR
@sourabhrangdal
Mar 19 2017 08:43
@rudolphh ok let me try
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:44

```js var count = 0;

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

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

Rudy Hernandez
@rudolphh
Mar 19 2017 08:45
@drowningpool5 the symmetric difference challenge is easier using the Set object if that helps
Manish Giri
@Manish-Giri
Mar 19 2017 08:45
@Alvin2410 you need to review the syntax for logical operators first..
drowningpool5
@drowningpool5
Mar 19 2017 08:45
@Alvin2410 yes... in your case in the if statements you must use the ===
@rudolphh ok..
Rudy Hernandez
@rudolphh
Mar 19 2017 08:49
@drowningpool5 that said your solution looks nicer
visually
drowningpool5
@drowningpool5
Mar 19 2017 08:49
@rudolphh xD
@rudolphh well atleast something xD
Rudy Hernandez
@rudolphh
Mar 19 2017 08:49
:+1:
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:50
@drowningpool5 yes i have used === in my if statment still its nt working
drowningpool5
@drowningpool5
Mar 19 2017 08:50
@Alvin2410 because you need to divide the numbers with ||
@Alvin2410 if (number === 1, 2,3,4,5,6) doesn't work in Javascript
@Alvin2410 instead you must write if (number === 1 || number === 2 ... and so on...)
@Alvin2410 || means OR
@Alvin2410 also... read the HINT
Ogundele Olumide
@Lumexralph
Mar 19 2017 08:53
@Manish-Giri Hey Bro!
SR
@sourabhrangdal
Mar 19 2017 08:53
@rudolphh i think i am stuck, any hint please?
Rudy Hernandez
@rudolphh
Mar 19 2017 08:54
if (contacts.firstName[i] == firstName) { // something }
you want to access each individual contact so...
if(contacts[i]...
Manish Giri
@Manish-Giri
Mar 19 2017 08:55
@Lumexralph :wave:
see, awake at 5 AM!
Rudy Hernandez
@rudolphh
Mar 19 2017 08:57
@Alvin2410 you were just taught about switch statements i believe. look there
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:58
@drowningpool5 yes it works bt how do i write the code for mixing various cards ?
SR
@sourabhrangdal
Mar 19 2017 08:58
@rudolphh ok
Rudy Hernandez
@rudolphh
Mar 19 2017 08:58
@Manish-Giri east coast girl, 2am here in cali
Alvin Odhiambo
@Alvin2410
Mar 19 2017 08:59
@Alvin2410 instead you must write if (number === 1 || number === 2 ... and so on...) how do i write code for different sequences?
@drowningpool5
Rudy Hernandez
@rudolphh
Mar 19 2017 09:00
@Alvin2410 switch statements aren't exactly the 'go to' for most situations but this is one that i'd recommend.
drowningpool5
@drowningpool5
Mar 19 2017 09:00
@Alvin2410 what do you mean different sequences
@rudolphh IMO he should do it with if statements.. if he started with it.. don't you think?
Rudy Hernandez
@rudolphh
Mar 19 2017 09:01
@drowningpool5 yeah i suppose you're right. learning process.
@Alvin2410 this function only deals with one card at a time, so thats all your logic has to work for.
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:05
@Manish-Giri why?! :worried: taking coffee?
drowningpool5
@drowningpool5
Mar 19 2017 09:05

@Alvin2410

if (card === 1 || card === 2 || card === 3 || card === 4 || card === 5 || card === 6) {
//do something and break out of the loop
}

turbit-smart
@turbit-smart
Mar 19 2017 09:05
hello
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:06
@turbit-smart hi
turbit-smart
@turbit-smart
Mar 19 2017 09:06
it would be great if you can help me solve this
Pieter Stokkink
@forkerino
Mar 19 2017 09:06
morning!
turbit-smart
@turbit-smart
Mar 19 2017 09:06
morning :)
Pieter Stokkink
@forkerino
Mar 19 2017 09:06
@turbit-smart solve what?
turbit-smart
@turbit-smart
Mar 19 2017 09:07
i have this code that should reverse the word or sentince but i cant figure out what did i wrote wrong here

function reverseString(str) {
var uns = str.split(',');
var uns1 = uns.reverse()
str = uns.join();

console.log(uns1);
return str;

}

reverseString("hello");

drowningpool5
@drowningpool5
Mar 19 2017 09:07
@turbit-smart you need to join the string you reversed :)
turbit-smart
@turbit-smart
Mar 19 2017 09:07
i did ?
SR
@sourabhrangdal
Mar 19 2017 09:07
@rudolphh
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.firstName; i++) {
  if (contacts[i].firstName === firstName) {
    if (contacts.hasOwnProperty(prop)) {
      return contacts[i][prop];
    } 
  } return "No such contact";
} 
  return "No such property";

// Only change code above this line
}
Pieter Stokkink
@forkerino
Mar 19 2017 09:07
@turbit-smart your splitting on comma's. There are no commas in your string (at least not in "hello"). Also in the join you need to provide an argument.
@turbit-smart use empty string for both
SR
@sourabhrangdal
Mar 19 2017 09:08
@forkerino hi Pieter
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:08
@turbit-smart why're you splitting with , ? var uns = str.split(',');
Pieter Stokkink
@forkerino
Mar 19 2017 09:08
@sourabhrangdal morning
Alvin Odhiambo
@Alvin2410
Mar 19 2017 09:08
@rudolphh but switch statements are just functions the same way as if statement
Manish Giri
@Manish-Giri
Mar 19 2017 09:08
@Lumexralph nope, no coffee!
innate ability of staying awake :smiling_imp:
Rudy Hernandez
@rudolphh
Mar 19 2017 09:08
@Alvin2410 yes my friend, multiple paths to the same destination :)
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:09
@Manish-Giri i read a book at times if I want to force myself to sleep, eventually I sleep off
SR
@sourabhrangdal
Mar 19 2017 09:09
@forkerino good morning, i'm working on profile lookup challenge, and stuck, can you have a quick look please
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.firstName; i++) {
  if (contacts[i].firstName === firstName) {
    if (contacts.hasOwnProperty(prop)) {
      return contacts[i][prop];
    } 
  } return "No such contact";
} 
  return "No such property";

// Only change code above this line
}
turbit-smart
@turbit-smart
Mar 19 2017 09:09

i tried without comma before but also couldnt make it work
function reverseString(str) {
var uns = str.split();
var uns1 = uns.reverse();
str = uns.join();

console.log(uns1);
return str;

}

reverseString("hello");

drowningpool5
@drowningpool5
Mar 19 2017 09:09
@turbit-smart you need to put in the ""
@drowningpool5 instead of ","
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:09
@turbit-smart split by characters like this var uns = str.split('');
Pieter Stokkink
@forkerino
Mar 19 2017 09:09
@turbit-smart use an empty string. that will tell .split and .join to do it after every letter
Rudy Hernandez
@rudolphh
Mar 19 2017 09:10
@sourabhrangdal now you have the same issue with the second if as you did with the first.
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:10
@sourabhrangdal check that place (contacts.hasOwnProperty(prop)) you don't have the object there
Pieter Stokkink
@forkerino
Mar 19 2017 09:10
@sourabhrangdal switch your No such contact and No such property around! The logic is good, but now you return one when you should return the other.
Alvin Odhiambo
@Alvin2410
Mar 19 2017 09:10
@drowningpool5 yeah i suppose you're right. learning process.
@Alvin2410 what do you mean different sequences :means mixing both card that give postive count and negative counts and 0 count
Rudy Hernandez
@rudolphh
Mar 19 2017 09:10
you want to access the individual contact within the loop, not the entire array
turbit-smart
@turbit-smart
Mar 19 2017 09:11
so i need to use for (i=0, i<uns, i++) something like that ?
Pieter Stokkink
@forkerino
Mar 19 2017 09:11
@sourabhrangdal and yes, add [i] to your second if
SR
@sourabhrangdal
Mar 19 2017 09:11
@rudolphh @Lumexralph @forkerino ok
Pieter Stokkink
@forkerino
Mar 19 2017 09:11
@turbit-smart no need for a loop
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:11
@turbit-smart no need for a loop
turbit-smart
@turbit-smart
Mar 19 2017 09:11
sorry but for some reason i have a blackout :(
Alvin Odhiambo
@Alvin2410
Mar 19 2017 09:12
@rudolphh hhehe okay
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:12
@turbit-smart split, reverse, join...
Pieter Stokkink
@forkerino
Mar 19 2017 09:12
@turbit-smart use .split('') instead of .split()
drowningpool5
@drowningpool5
Mar 19 2017 09:12
@Alvin2410 paste your current code
Pieter Stokkink
@forkerino
Mar 19 2017 09:12
same with join @turbit-smart
Rudy Hernandez
@rudolphh
Mar 19 2017 09:12
@Alvin2410 yes show us what you got bud
SR
@sourabhrangdal
Mar 19 2017 09:14
@rudolphh @Lumexralph @forkerino how about now
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.firstName; i++) {
  if (contacts[i].firstName === firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } 
  } return "No such property";
} 
  return "No such contact";

// Only change code above this line
}
Rudy Hernandez
@rudolphh
Mar 19 2017 09:14
does it pass the tests?
SR
@sourabhrangdal
Mar 19 2017 09:15
@rudolphh :(
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:15
Can anyone help me on challenge "Testing Objects for Properties"
SR
@sourabhrangdal
Mar 19 2017 09:15
sorry i'm little slow to understand things,
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:15
I'm having trouble returning properties of myObj
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
   if (myObj.hasOwnProperty() === false) {
return "Not Found";}
  return checkObj[];

}
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:16
@sourabhrangdal return "No such property"; should be in the if block
Rudy Hernandez
@rudolphh
Mar 19 2017 09:16
@sourabhrangdal nonsense you're fine
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:16
the last part (it should have an else as well but I took it out for a min)
Jor
@joreyesl
Mar 19 2017 09:16
@sourabhrangdal Why this i < contacts.firstName? you want to use length not firstName
SR
@sourabhrangdal
Mar 19 2017 09:16
@LukeSallmen .hasOwnProperty( you need to add something here )
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:16
is giving me trouble - I'm not sure how to return "pony"
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:16
@LukeSallmen myObj.hasOwnProperty(checkProp)
turbit-smart
@turbit-smart
Mar 19 2017 09:16
@forkerino & @Lumexralph thanks a lot i did it, it worked :)
CamperBot
@camperbot
Mar 19 2017 09:16
turbit-smart sends brownie points to @forkerino and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1589 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 1338 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:17
@sourabhrangdal and check what @joreyesl said
SR
@sourabhrangdal
Mar 19 2017 09:17
@rudolphh @Lumexralph yes
Rudy Hernandez
@rudolphh
Mar 19 2017 09:17
@sourabhrangdal you just have to readjust the logic of 'no such property' and 'no such contact'
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:18
@LukeSallmen use checkProp to access the object myObj and return the value
drowningpool5
@drowningpool5
Mar 19 2017 09:18
@Alvin2410 if the card is equal to 1 or 2 or 3 or 4 or 5 or 6 you need to increment the value of count... else if card is equal to some other numbers equal should be the same as it was before... else if card is equal to 10 or king or queen etc. you need to decrement the value of count... :)
Rudy Hernandez
@rudolphh
Mar 19 2017 09:18
@sourabhrangdal yes i thought we already changed it to contacts.length
in which case you might be good already
SR
@sourabhrangdal
Mar 19 2017 09:19
@rudolphh yes, something works
but still has lill issur, let me figure
Jor
@joreyesl
Mar 19 2017 09:19
@sourabhrangdal also your return for no such property should be inside the first if statement, otherwise you will return on the first iteration.
drowningpool5
@drowningpool5
Mar 19 2017 09:20
@Alvin2410 after that you need to check if the value of count is positive and print out the COUNT (number) plus bet, and COUNT plus hold if the count number is negative or equal to 0.
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:20
@joreyesl i told him that don't know if he saw it
SR
@sourabhrangdal
Mar 19 2017 09:20
@joreyesl yes just noticed. i want to say Thank you to @joreyesl @rudolphh @Lumexralph @forkerino
CamperBot
@camperbot
Mar 19 2017 09:20
sourabhrangdal sends brownie points to @joreyesl and @rudolphh and @lumexralph and @forkerino :sparkles: :thumbsup: :sparkles:
:warning: The user instance is not valid. Details: username is not unique (value: "rudolphh"); username User already exists (value: "rudolphh").
:star2: 1590 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 1339 | @lumexralph |http://www.freecodecamp.com/lumexralph
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:20
@Lumexralph I don't understand how to do that :(
CamperBot
@camperbot
Mar 19 2017 09:20
:cookie: 634 | @joreyesl |http://www.freecodecamp.com/joreyesl
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:21
myObj.hasOwnProperty(checkProp)?
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:21
@LukeSallmen yes but used as an if statement condition
Pieter Stokkink
@forkerino
Mar 19 2017 09:21
@sourabhrangdal :)
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:22
@Lumexralph But it has to return the value of the property being checked
if it is checking gift, it has to return "pony"
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:22
@LukeSallmen if it's true use checkProp to access myObj and return that value
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:22
Could you reword that? I know that's what I have to do but I don't know how to do it
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:23
@LukeSallmen how do you use a variable to access an object?
Alvin Odhiambo
@Alvin2410
Mar 19 2017 09:23

```js var count = 0;

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

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

@drowningpool5 theres my code
Pieter Stokkink
@forkerino
Mar 19 2017 09:24
@Alvin2410 don't return anything in the part where you change count (so until your last else if). Create another if/else after it to return the right thing based on count.
Rudy Hernandez
@rudolphh
Mar 19 2017 09:25
@sourabhrangdal so close. show me what you got, you literally have to move one line of code within an else statement type deal
bingo
i think lol
SR
@sourabhrangdal
Mar 19 2017 09:25

@rudolphh yessss, it works
```
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} return "No such property";
}
}
return "No such contact";

// Only change code above this line
}
``` :)

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

// Only change code above this line
}
Rudy Hernandez
@rudolphh
Mar 19 2017 09:26
:thumbsup:
SR
@sourabhrangdal
Mar 19 2017 09:27
@rudolphh @forkerino @Lumexralph can anyone explain what i just did please
Luke Sallmen
@LukeSallmen
Mar 19 2017 09:27
@Lumexralph lol I guess I figured it out
@Lumexralph Thank you.
CamperBot
@camperbot
Mar 19 2017 09:27
lukesallmen sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1340 | @lumexralph |http://www.freecodecamp.com/lumexralph
drowningpool5
@drowningpool5
Mar 19 2017 09:28
@Alvin2410 okay nice :) now what doest return do?
SR
@sourabhrangdal
Mar 19 2017 09:28
to check the "one" : "two", i got confused in these two .hasOwnProperty() and the firstName
Rudy Hernandez
@rudolphh
Mar 19 2017 09:28
lol. i would've added an else to make it more readable. like this.
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName === firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } 
    else { return "No such property"; }
  } 
} 
  return "No such contact";

// Only change code above this line
}
Pieter Stokkink
@forkerino
Mar 19 2017 09:29
OMG I just rewrote my Profile lookup to a 2 line function. :P
SR
@sourabhrangdal
Mar 19 2017 09:29
@rudolphh yeah i used else but i was continuously doing some error, added, removed and now completely removed. but yes, your code looks much readable :thumbsup:
@forkerino can you share please ;)
Rudy Hernandez
@rudolphh
Mar 19 2017 09:29
@forkerino yeah and its like that ;)
Pieter Stokkink
@forkerino
Mar 19 2017 09:30
down from a whopping three lines.
Rudy Hernandez
@rudolphh
Mar 19 2017 09:30
lol
Pieter Stokkink
@forkerino
Mar 19 2017 09:30
  let found = contacts.filter(v => v.firstName == firstName);
  return found.length === 0? "No such contact" : found[0][prop] || "No such property";
Rudy Hernandez
@rudolphh
Mar 19 2017 09:30
i thought so, but the for loop is prob faster
SR
@sourabhrangdal
Mar 19 2017 09:30
@forkerino OMG this is advance
Pieter Stokkink
@forkerino
Mar 19 2017 09:30
@rudolphh I don't care about milliseconds
Rudy Hernandez
@rudolphh
Mar 19 2017 09:30
lol neither do i
Alvin Odhiambo
@Alvin2410
Mar 19 2017 09:30
@Alvin2410 after that you need to check if the value of count is positive and print out the COUNT (number) plus bet, and COUNT plus hold if the count number is negative or equal to 0. @forkerino
@Alvin2410 don't return anything in the part where you change count (so until your last else if). Create another if/else after it to return the right thing based on count.
lemme try
Rudy Hernandez
@rudolphh
Mar 19 2017 09:31
try it with reduce now. please :)
Pieter Stokkink
@forkerino
Mar 19 2017 09:31
That would complicate matters
I think
Rudy Hernandez
@rudolphh
Mar 19 2017 09:31
yeah not two lines, thats sweet
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:31
@forkerino :smirk:
SR
@sourabhrangdal
Mar 19 2017 09:32
@forkerino @rudolphh guys but for us (beginners) are we doing well?
@Lumexralph
Rudy Hernandez
@rudolphh
Mar 19 2017 09:32
@sourabhrangdal you're doing great
Ogundele Olumide
@Lumexralph
Mar 19 2017 09:32
@sourabhrangdal am a beginner
@sourabhrangdal we're doing great... we'll keep at it
Pieter Stokkink
@forkerino
Mar 19 2017 09:32
@rudolphh could optimize it a bit with .find() instead of .filter(), I think.
SR
@sourabhrangdal
Mar 19 2017 09:33
@Lumexralph @rudolphh :thumbsup:
Rudy Hernandez
@rudolphh
Mar 19 2017 09:33
maybe but can't beat a good ole for loop
you guys keep it up, nothing like staying committed. most people would quit long before
drowningpool5
@drowningpool5
Mar 19 2017 09:35
@rudolphh +1
Pieter Stokkink
@forkerino
Mar 19 2017 09:36
yeah, .find is a little more elegant:
  let found = contacts.find(v => v.firstName == firstName);
  return !found ? "No such contact" : found[prop] || "No such property";
no need for indexes and .length
Rudy Hernandez
@rudolphh
Mar 19 2017 09:37
yup
Pieter Stokkink
@forkerino
Mar 19 2017 09:41
@sourabhrangdal don't worry too much about more advanced solutions at this point. You're doing fine. :)
Aliaksandr Falkouski
@falk42
Mar 19 2017 09:42
hello all, i need help. code doesn't work on codepen
Rudy Hernandez
@rudolphh
Mar 19 2017 09:44
yes advanced solutions are sometimes more trouble than they're worth
love that @forkerino thank you
CamperBot
@camperbot
Mar 19 2017 09:44
rudolphh sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1591 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Mar 19 2017 09:45
@falk42 You probably need to wrap all your JS in a $(document).ready() function
@rudolphh :smile:
Aliaksandr Falkouski
@falk42
Mar 19 2017 09:48
@forkerino i did this, no work
@forkerino i try copy code from documentation, but it too
Alvin Odhiambo
@Alvin2410
Mar 19 2017 09:50

var count = 0;

function cc(card) {
// Only change code below this line
if (card===2||card===3||card===4||card===5||card===6){
count++;

}else if (card===7||card===8||card===9){
count=count;

} else if (card===10||card==='J'||card==='Q'||card==='K'||card==='A'){
count--;

}
if (count>0){
return count + "Bet";
}else if (count<=0){
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(3); cc(7); cc('K'); cc('A');

Rudy Hernandez
@rudolphh
Mar 19 2017 09:50
i don't even see markup, i'd start with at least something
Alvin Odhiambo
@Alvin2410
Mar 19 2017 09:50
@drowningpool5 check my code now
WAINGOR
@WAINGOR
Mar 19 2017 09:50
A general question: when a function itsself is a parameter, does it only get passed after it is solved within the parent function?
drowningpool5
@drowningpool5
Mar 19 2017 09:51
@Alvin2410 nice :)
@Alvin2410 you are very close
Pieter Stokkink
@forkerino
Mar 19 2017 09:53
@falk42 I got it to work by wrapping it inside a $(document).ready function. I had to alter the url to https:// instead of http:// because I don't like using the latter and you'll get cors issues if not. https://codepen.io/forkerino/pen/RpxBZP?editors=0010
@WAINGOR what do you mean parent function? It will only get replaced with its return value once it is called();
Aliaksandr Falkouski
@falk42
Mar 19 2017 09:55
@forkerino omg thanks)
CamperBot
@camperbot
Mar 19 2017 09:55
falk42 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1592 | @forkerino |http://www.freecodecamp.com/forkerino
drowningpool5
@drowningpool5
Mar 19 2017 09:55
@Alvin2410 check this part again... you have a typo...
if (count > 0) {
    return count + "Bet";
  } else if (count <= 0) {
    return count + " Hold";
  }
Pieter Stokkink
@forkerino
Mar 19 2017 09:55
@falk42 :)
Rudy Hernandez
@rudolphh
Mar 19 2017 09:55
@forkerino why do cors issues seem to only pop up at certain times? maybe i'm missing something
Aliaksandr Falkouski
@falk42
Mar 19 2017 09:56
@forkerino i don't know where i stuck, but this miracle
Rudy Hernandez
@rudolphh
Mar 19 2017 09:57
my quote generator works mostly, and then at times (typically late night, for me in california) it doesn't. https://codepen.io/rudolphho/pen/WRyBbQ i still don't have a grasp on that
drowningpool5
@drowningpool5
Mar 19 2017 09:59
@rudolphh its nice looking tho :D gz on that
Rudy Hernandez
@rudolphh
Mar 19 2017 09:59
sorry yall, wanted some expert advice myself lol
@drowningpool5 ty
CamperBot
@camperbot
Mar 19 2017 09:59
rudolphh sends brownie points to @drowningpool5 :sparkles: :thumbsup: :sparkles:
:warning: @drowningpool5's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Rudy Hernandez
@rudolphh
Mar 19 2017 10:01
i understand cross-origin just not how codepen is doing things i guess
nvm, just did what you did over der. codepen doesn't like my ajax request if it isn't secure
Pieter Stokkink
@forkerino
Mar 19 2017 10:04
@rudolphh I always access sites through https, so invariably get cors errors when someone uses an api over http. With the quotes on design api you can safely use https. Another way to solve these issues is to use JSONP, or a CORS proxy like https://cors-anywhere.herokuapp.com/ if the api doesn't allow https
Rudy Hernandez
@rudolphh
Mar 19 2017 10:05
@forkerino nice, thank you for the added alternatives
CamperBot
@camperbot
Mar 19 2017 10:05
rudolphh sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: rudolphh already gave forkerino points
Rudy Hernandez
@rudolphh
Mar 19 2017 10:06
i will now always access sites through https, lesson learned kiddies
Aniculaesei
@Aniculaesei
Mar 19 2017 10:09
Hello!Can somebody help me please?Thank you

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


function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){

  if(contacts[i].firstName===firstName){

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

      return contacts[i][prop];

    }return "No such contact";



    }else if(contacts[i].hasOwnProperty(prop)){ 
    }return "No such property";

}  

  }
Rudy Hernandez
@rudolphh
Mar 19 2017 10:10
@sourabhrangdal is your man on this one
jk (kinda) looks good up until the else if, check it out a little more
Pieter Stokkink
@forkerino
Mar 19 2017 10:12
@Aniculaesei your loop won't loop because you will always return something inside it. Return stops the function completely.
__mifflin__
@cdrainxv
Mar 19 2017 10:12
@Aniculaesei: You can only return that you haven't found your person only after the whole loop has been traversed and the name was not found. This means you can only return No such contact outside of your loop.
Rudy Hernandez
@rudolphh
Mar 19 2017 10:13
and just write the code for him guys lol jk
@forkerino literally just gave us a two-liner on this about 30 min ago
Alvin Odhiambo
@Alvin2410
Mar 19 2017 10:14
@Alvin2410 check this part again... you have a typo...
js if (count > 0) { return count + "Bet"; } else if (count <= 0) { return count + " Hold"; }i got it!
Rudy Hernandez
@rudolphh
Mar 19 2017 10:16
@forkerino are you working on any FCC projects? just wondering
Pieter Stokkink
@forkerino
Mar 19 2017 10:16
@rudolphh working on the backend projects now.
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:17
need help with Factorialize a number
Anyone?
function factorialize(num) {
  var numbers = [];
  while(num !== 0){
    numbers.push(num);
    num -= 1;
  }

var newNum = numbers.reduce(function(a,b){
 return a * b;
  },0);
  return newNum;
}

factorialize(5);
why the heck it shows 0 only :|
Rudy Hernandez
@rudolphh
Mar 19 2017 10:20
cool. i know they're getting rid of 'backend' in beta, i'll be where it would be backend next (apis and microservices).
Jor
@joreyesl
Mar 19 2017 10:20
@AuthenticCoder you are initilizing the default value of the accumulator to be 0, what happens when you multiply by 0?
Rudy Hernandez
@rudolphh
Mar 19 2017 10:22
thats right, your computer explodes
so don't do it
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:22
ah
Austin White
@Aeolionx
Mar 19 2017 10:22

can someone tell me why this works? It works perfectly but arr.length = 4 which would mean the loop would run more than it needs to and should be pushing unnecessary empty arrays onto the end.
'''
function chunkArrayInGroups(arr, size) {
var newarr = [];

for(var i=0; i <= arr.length; i++){
newarr.push(arr.slice(0, size));
arr.splice(0, size);
}

if(arr.length > 0)
newarr.push(arr);

return newarr;
}

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

CamperBot
@camperbot
Mar 19 2017 10:22
:bulb: to format code use backticks! ``` more info
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:22
Thanks @joreyesl
CamperBot
@camperbot
Mar 19 2017 10:22
authenticcoder sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 635 | @joreyesl |http://www.freecodecamp.com/joreyesl
Pieter Stokkink
@forkerino
Mar 19 2017 10:23
@rudolphh I want to finish the certificate before we go beta. Should be possible. Only 2 and a half projects left. :)
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:23
factorialize(0) should return 1 :|
Austin White
@Aeolionx
Mar 19 2017 10:23

'''
function chunkArrayInGroups(arr, size) {
var newarr = [];

for(var i=0; i <= arr.length; i++){
newarr.push(arr.slice(0, size));
arr.splice(0, size);
}

if(arr.length > 0)
newarr.push(arr);

return newarr;
}

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

CamperBot
@camperbot
Mar 19 2017 10:23
:bulb: to format code use backticks! ``` more info
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:23
What? 0! is 0
Rudy Hernandez
@rudolphh
Mar 19 2017 10:24
@forkerino definitely. beta is such a mess still. i doubt they push to production yet. the react sections are still in alpha and i think they really want that set beforehand.
Jor
@joreyesl
Mar 19 2017 10:24
no 0! is defined to b 1
just add an if statement and check if num === 0 then return 1 at the top
Pieter Stokkink
@forkerino
Mar 19 2017 10:25
@rudolphh overall, I really like the beta program and think there are big improvements, but still a lot of work left to be done...
Theofanis Despoudis
@theodesp
Mar 19 2017 10:25
Yes because the factorial represents a set of n numbers that can be permuted so an empty set has 1 permutation
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:26
Thanks again @joreyesl
CamperBot
@camperbot
Mar 19 2017 10:26
authenticcoder sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: authenticcoder already gave joreyesl points
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:26
React is popular
so I also think they're gonna push for react first
Rudy Hernandez
@rudolphh
Mar 19 2017 10:29
@forkerino yeah the beta map is why i stuck with fcc. i just joined almost three months ago, but had joined the regular fcc maybe six months ago and left. did all kinds of crap with little guidance in between, learned vue, hack reactor prep etc., but once i saw the beta map i knew they were really putting together a solid curriculum.
Jor
@joreyesl
Mar 19 2017 10:29
the beta looks amazing, can't wait
Theofanis Despoudis
@theodesp
Mar 19 2017 10:31
have you got any links about the beta map?
Pieter Stokkink
@forkerino
Mar 19 2017 10:31
@theodesp beta.freecodecamp.com
Theofanis Despoudis
@theodesp
Mar 19 2017 10:31
ok thanx
Rudy Hernandez
@rudolphh
Mar 19 2017 10:32
your work will be blown to oblivion when it goes to production so if you decide to use it just save the challenges with the (*) by them.
i think its why i can't get brownie points here but the team hasn't figured out why. i used my github for both regular and beta. so camperbot says my name isn't unique and no brownie points for me :(
Theofanis Despoudis
@theodesp
Mar 19 2017 10:33
Omg tha map is huge
Rudy Hernandez
@rudolphh
Mar 19 2017 10:33
@theodesp lovely isn't it?
Theofanis Despoudis
@theodesp
Mar 19 2017 10:34
they have only one task for react?
Rudy Hernandez
@rudolphh
Mar 19 2017 10:34
no its just in alpha, they provide a link to it, and its good. i learned react with codeacademy
but i do like fccs much better
Jor
@joreyesl
Mar 19 2017 10:35
@theodesp they are still building it
Theofanis Despoudis
@theodesp
Mar 19 2017 10:35
Gee i feel like I’m in univercity again:P
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:36
Worse than university :P
university's syllabus stays the same
fcc is always changing
Rudy Hernandez
@rudolphh
Mar 19 2017 10:36
@AuthenticCoder that is a good thing in this field
i learned 80s computer programming in cs when i went to university lol
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:38
yah, it's a good thing
but compared to whats out there it's still slow :D
skugz
@skugz
Mar 19 2017 10:38
hhaving trouble with accessing arrays
never before encountered these kind of script identifiers in arrays. How do I access scherlock if for example the first element of a nested array is "firstname" : "sherlock"
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:38
Apparently, a new javascript frameworks is built by the time it takes to code a todo list for a developer
Rudy Hernandez
@rudolphh
Mar 19 2017 10:39
yeah in all fairness react is so 2015, but still, the industry lags a bit behind
so jobs take a bit to follow the trends
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:40
react got famous because of react native
Rudy Hernandez
@rudolphh
Mar 19 2017 10:40
@skugz what do you got?
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:40
also when angular 2 decided to drop everything from angular 1 and build from scratch
Theofanis Despoudis
@theodesp
Mar 19 2017 10:40
@AuthenticCoder Its only that it has to be a solid product
Rudy Hernandez
@rudolphh
Mar 19 2017 10:41
@AuthenticCoder yeah i haven't tried native but from what i've read its not all its cracked up to be
like ionic i guess
skugz
@skugz
Mar 19 2017 10:41
well it's the profile lookup lesson in javascript for beginners
Rudy Hernandez
@rudolphh
Mar 19 2017 10:42
i want to learn angular 2, never learned angular 1, but i'm leery
Theofanis Despoudis
@theodesp
Mar 19 2017 10:42
good luck with that lol
Rudy Hernandez
@rudolphh
Mar 19 2017 10:42
@skugz you're joking right?
jk bud, its just we've been handling that for some time in this session
Pieter Stokkink
@forkerino
Mar 19 2017 10:43
it is the most asked question here.
Rudy Hernandez
@rudolphh
Mar 19 2017 10:43
lol yeah
Pieter Stokkink
@forkerino
Mar 19 2017 10:43
by a mile
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:43
Profile lookup is the reason I joined this chatroom :D
Pieter Stokkink
@forkerino
Mar 19 2017 10:43
@skugz did you write some code? Please copy paste the function here (not the data)
skugz
@skugz
Mar 19 2017 10:44

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

    }

} else {return "No such contact";}

}
// Only change code above this line
}

Rudy Hernandez
@rudolphh
Mar 19 2017 10:45
@theodesp if its worth it i can learn it quick. i just feel like its not from what i read. the jobs are there but it feels like others are taking over in the near future. i could def be wrong
@skugz you're dealing with an array of objects
not an array of arrays
if that helps
Theofanis Despoudis
@theodesp
Mar 19 2017 10:46
you might be able to play with it make a project or 2 and see if you like it
skugz
@skugz
Mar 19 2017 10:47
@rudolphh ok, but how do I acces them since the objects don't have names...I'm used to c++ where I can specify these things
Theofanis Despoudis
@theodesp
Mar 19 2017 10:47
there are a lot of tutorials in https://thinkster.io/
Rudy Hernandez
@rudolphh
Mar 19 2017 10:47
yeah i'll try that. i will say i didn't like react at first (not sure who does) but after a few it grew on me. that said, vue felt more natural but doesn't have the support like react does obv
@theodesp thank you
CamperBot
@camperbot
Mar 19 2017 10:48
rudolphh sends brownie points to @theodesp :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @theodesp |http://www.freecodecamp.com/theodesp
Authentic Coder
@AuthenticCoder
Mar 19 2017 10:48
react uses typescript, right?
Rudy Hernandez
@rudolphh
Mar 19 2017 10:49
@skugz my first language (love), yeah javascript is like a red-headed bastard step-child of c++.
Theofanis Despoudis
@theodesp
Mar 19 2017 10:49
I would also like to see cycle.js in the curriculum but this is too far fetched maybe as an alternative
fcc-extras
Rudy Hernandez
@rudolphh
Mar 19 2017 10:50
@skugz well since its an array of objects contacts[i] is an object
so from there you can use dot notation to access its properties
@theodespp cycle.js haven't heard of it thank you
CamperBot
@camperbot
Mar 19 2017 10:51
rudolphh sends brownie points to @theodespp :sparkles: :thumbsup: :sparkles:
:warning: @theodespp's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Theofanis Despoudis
@theodesp
Mar 19 2017 10:51
there are a lot of frameworks there in the wild wild js land
Rudy Hernandez
@rudolphh
Mar 19 2017 10:51
have you looked into vue @theodesp ?
so many i know
devpaaji
@devpaaji
Mar 19 2017 10:51
@forkerino
Pieter Stokkink
@forkerino
Mar 19 2017 10:52
@theodesp was trying to use cycle.js for my last project. Failed miserably. One step at a time.
Theofanis Despoudis
@theodesp
Mar 19 2017 10:52
i know it but ihaven’t worked with it
devpaaji
@devpaaji
Mar 19 2017 10:52
var myFunction = function(z, s, d) {
 return arguments.length;
};
console.log(myFunction()); // logs 0
Theofanis Despoudis
@theodesp
Mar 19 2017 10:52
maybe I’ll give it a try someday
devpaaji
@devpaaji
Mar 19 2017 10:52
var myFunction = function(z, s, d, e, r, m, q) {
return myFunction.length;
};
console.log(myFunction()); //logs 7
why
Rudy Hernandez
@rudolphh
Mar 19 2017 10:52
i did the markdown previewer in react and vue, but vue didn't pass the tests. i thought it was weird because they were simple tests
skugz
@skugz
Mar 19 2017 10:53
@rudolphh thanks I think that'll help
CamperBot
@camperbot
Mar 19 2017 10:53
skugz sends brownie points to @rudolphh :sparkles: :thumbsup: :sparkles:
:warning: The user instance is not valid. Details: username User already exists (value: "rudolphh"); username is not unique (value: "rudolphh").
devpaaji
@devpaaji
Mar 19 2017 10:53
what we mean here
Rudy Hernandez
@rudolphh
Mar 19 2017 10:53
so i'd skip vue for fcc projects but def worth learning. the complete guide on udemy (i believe) is so worth it
devpaaji
@devpaaji
Mar 19 2017 10:53
While you might think this length property will
give you the number of defined arguments, it actually gives the number of parameters sent to the
function during invocation.
@forkerino
Ogundele Olumide
@Lumexralph
Mar 19 2017 10:53
@devpaaji length property of a function is the number of the legal parameters
Theofanis Despoudis
@theodesp
Mar 19 2017 10:54
i have a subscription ot safari books online and it has everything i need lol
Ogundele Olumide
@Lumexralph
Mar 19 2017 10:54
@devpaaji arguments works with no of values when the function was called
devpaaji
@devpaaji
Mar 19 2017 10:54
var myFunction = function(z, s, d) {
return arguments.length;
};
console.log(myFunction());
can you explain using the example @Lumexralph
Theofanis Despoudis
@theodesp
Mar 19 2017 10:55
hey if you are ready for some challenges head over this site http://adventofcode.com/
its amazing
Ogundele Olumide
@Lumexralph
Mar 19 2017 10:55
@devpaaji
var myFunction = function(z, s, d) {
 return arguments.length;
};

console.log(myFunction(3)); // 1
devpaaji
@devpaaji
Mar 19 2017 10:55
oh yes
Rudy Hernandez
@rudolphh
Mar 19 2017 10:56
@theodesp wut!!! lol, i'm checking it out now
Theofanis Despoudis
@theodesp
Mar 19 2017 10:56
beware they are not trivial
Rudy Hernandez
@rudolphh
Mar 19 2017 10:56
hack reactor prep is good though for recall in javascript fyi
PeetaJ
@PeetaJ
Mar 19 2017 10:56
function largestOfFour(arr) {
var a = [];
var b = 0;
for (i = 0; i < arr.length; i++) {
for (o = 0; o < arr[i].length; o++) {
if (arr[i][o] > b) {
b = arr[i][o];
}
}
a.push(b);
}
return a;
}
Rudy Hernandez
@rudolphh
Mar 19 2017 10:57
@theodesp omg talk about nostalgia on another level. 12 years old, no joke.
with a modern twist
Ogundele Olumide
@Lumexralph
Mar 19 2017 10:58
@PeetaJ you need to reset b for every iteration of the sub-array
Code_Minded
@mnedariya
Mar 19 2017 10:58
coders_at_work_.png
Pieter Stokkink
@forkerino
Mar 19 2017 10:58
@PeetaJ please don't call your variable o. it is too close to zero. use something else. :)
devpaaji
@devpaaji
Mar 19 2017 10:59
@Lumexralph
// function statement
function addStatement(x, y) {
! return x + y;
}
// function expression
var addExpression = function(x, y) {
return x + y;
};
Ogundele Olumide
@Lumexralph
Mar 19 2017 10:59
@forkerino i was meticulous when reading the code :smile:
PeetaJ
@PeetaJ
Mar 19 2017 10:59
Thank you.
devpaaji
@devpaaji
Mar 19 2017 10:59
when should we use a FE vs FS
Rudy Hernandez
@rudolphh
Mar 19 2017 10:59
@theodesp thank you
CamperBot
@camperbot
Mar 19 2017 10:59
rudolphh sends brownie points to @theodesp :sparkles: :thumbsup: :sparkles:
:warning: rudolphh already gave theodesp points
devpaaji
@devpaaji
Mar 19 2017 10:59
why should we store the func value in a var
Ogundele Olumide
@Lumexralph
Mar 19 2017 10:59
@devpaaji FE is good for IIFE
devpaaji
@devpaaji
Mar 19 2017 11:00
why we should write IIFE
Theofanis Despoudis
@theodesp
Mar 19 2017 11:00
dont use FE use FS
Ogundele Olumide
@Lumexralph
Mar 19 2017 11:00
@devpaaji i don't know bro...you might need a function to be called immediately when parsed by the JS engine, to get a value
Theofanis Despoudis
@theodesp
Mar 19 2017 11:01
variables get hoisted so you ave to deal with that
Ogundele Olumide
@Lumexralph
Mar 19 2017 11:01
@theodesp depends on what he's doing FE is not wrong as long as you're aware
FelixRe0
@FelixRe0
Mar 19 2017 11:02
Hi I need help on the Chunky Monkey challenge. How can I create the correct Array?
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
for (var x = 0; x < (arr.length/size + (arr.length % size)); x++) {
  newArr[x] = [];
}


  var check = 0;
while(arr.length > 0){
  for(var n = 0; n<size;n++){
      newArr[check].push(arr.shift());
   } 
  check++;
}
  console.log("Länge : "+ arr.length);
  return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
Theofanis Despoudis
@theodesp
Mar 19 2017 11:03
its not only you have to be aware but the other programmers using your code
Rudy Hernandez
@rudolphh
Mar 19 2017 11:04
@FelixRe0 i recommend push and slice
Anna
@AnnaVih
Mar 19 2017 11:04
hello guys!
Rudy Hernandez
@rudolphh
Mar 19 2017 11:04
@AnnaVih hi
Anna
@AnnaVih
Mar 19 2017 11:05
i got some problem with exercise Return Early Pattern for Function
JavaScript
FelixRe0
@FelixRe0
Mar 19 2017 11:05
@rudolphh I tried it with that but didn't get the right length
Anna
@AnnaVih
Mar 19 2017 11:05
i cant figure out
Rudy Hernandez
@rudolphh
Mar 19 2017 11:06
@FelixRe0 can you post what you came up with?
Anna
@AnnaVih
Mar 19 2017 11:06
blob
Azamat
@Azomas
Mar 19 2017 11:07
Hello. Dear friends I need your help. I want to write a code that saves content of my chrome.storage area to a variable, but I can't figure out how to use callback there. I need callback because chrome.local is asynchronous. Sample code below
function getData (keys) {    
    chrome.storage.local.get(keys, function(items) {        
        return items;
    });    
    return items;
}
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 11:07
@AnnaVih do you remember how to make if statements?
Anna
@AnnaVih
Mar 19 2017 11:07
yes
i tried
FelixRe0
@FelixRe0
Mar 19 2017 11:08

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
for (var x = 0; x < (arr.length/size + (arr.length % size)); x++) {
  newArr[x] = [];
}

  var arrLength = arr.length;

  var check = 0;
while(arrLength > 0){
  for(var n = 0; n<size;n++){
      newArr[check].push(arr.slice(0));
   } 
  arrLength--;
}
  console.log("Länge : "+ arr.length);
  return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 11:08
@AnnaVih how would you make a conditional asking if a is less than 0?
Anna
@AnnaVih
Mar 19 2017 11:08
if(a<0|| b<0){
HeebieGeeBee
@HeebieGeeBee
Mar 19 2017 11:08
ok so whats the problem?
Rudy Hernandez
@rudolphh
Mar 19 2017 11:08
boom
what would you return?
Nazar
@IsaakNazar
Mar 19 2017 11:08
Guys, how to UpperCase character after - symbol?
function camel(str) {
 for(var i = 0; i<str.length; i++){
 if(str.charAt(i) === '-') {return str.charAt(i+1).toUpperCase();}
  } 

}
console.log('eu-je');
Anna
@AnnaVih
Mar 19 2017 11:09
return "undefined";
HeebieGee