These are chat archives for FreeCodeCamp/HelpJavaScript

25th
Mar 2017
Stephen James
@sjames1958gm
Mar 25 2017 00:00

@the-vampiire Just for you information - when you return from a function called by filter - it converts the value to boolean. So a simple solution is

return arr.filter(function(val) { return val; });

Falsey values are converted to false and filtered out

Vamp
@the-vampiire
Mar 25 2017 00:01

wow
he one lines me
brilliant dude hahah
Kaue Rodrigo Pacheco
@kauepacheco
Mar 25 2017 00:02
Guys i need help

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

      return contacts[i][prop];
    } else {
      return "No such contact";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
why is this not working
Vamp
@the-vampiire
Mar 25 2017 00:09
@kauepacheco check where is this else statement? inside or outside your loop?
also check if you understand this - when you have return in a loop and your loop hits that return statement it will kick out the loop and return. meaning if you iterate through the loop once and don’t fid the contact (contacts[0]) then you will hit the return and break the loop.
so knowing this. should your else go inside or outside the loop?
Saboor Malik
@MathematicsCoding
Mar 25 2017 00:13
function titleCase(str) {
   var abc = str.split(" ");
  var i;
   for (i = 0; i < abc.length; i++) {
     abc[i] = abc[i][0].toUpperCase() + abc[i].substr(1, abc[i].length - 1); 

   }
   return abc.join(" ");
}
titleCase("hello world");
Jeff
@geenious
Mar 25 2017 00:15
I think I'm having a hard time with the logic for the Chunky Monkey excersize. I can create the first col but the second col isn't coming out right.
Michael Grienauer
@mgrienauer
Mar 25 2017 00:15
@sjames1958gm is there a way to use regex to match brackets?
Kaue Rodrigo Pacheco
@kauepacheco
Mar 25 2017 00:15
@the-vampiire Thank you dude!!!
CamperBot
@camperbot
Mar 25 2017 00:15
kauepacheco sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Jeff
@geenious
Mar 25 2017 00:15
function chunkArrayInGroups(arr, size) {
    var newArray = [];
    for (var i = 0; i < arr.length; i++) {
        newArray.push(arr.slice(arr[i].length, size));
        //newArray.push(arr.slice(arr[i + size].length, size));
        return newArray;
    }
}
Vamp
@the-vampiire
Mar 25 2017 00:15
@mike93og93 [
\[
escape it
Michael Grienauer
@mgrienauer
Mar 25 2017 00:17
function steamrollArray(arr) {
  var newArr = arr.reduce(function(x,y){
    x = x.concat(y);
    return x;
  },[]);

  var finalarr = [];
  var re = /\[\]/;
  for(var i = 0; i<newArr.length; i++){
    if(newArr[i]!== re){
      finalarr.push(newArr[i]);
    }
  }
  return finalarr;
}

steamrollArray([1, {}, [3, [[4]]]]);
Manish Giri
@Manish-Giri
Mar 25 2017 00:17
@geenious return outside the loop..
Michael Grienauer
@mgrienauer
Mar 25 2017 00:17
shouldnt this be pushing items to a new array if they aren't brackets?
Vamp
@the-vampiire
Mar 25 2017 00:18
@kauepacheco you’re welcome man
@mike93og93 what is all this ,[]); on line 5?
Gulsvi
@gulsvi
Mar 25 2017 00:20
@mike93og93 that re variable format will only work with methods that accept a regular expression (.match(), .replace(), for example)
Jeff
@geenious
Mar 25 2017 00:20
@Manish-Giri thanks! that output looks better. now when I try to make changes they'll come out what I'm thinking!
CamperBot
@camperbot
Mar 25 2017 00:20
geenious sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4908 | @manish-giri |http://www.freecodecamp.com/manish-giri
Vamp
@the-vampiire
Mar 25 2017 00:21

just starting on Algorithms Seek and Destroy

How do I obtain the additional arguments that are passed? I didn’t even know it was possible to pass arguments that weren’t listed as parameters in a function. almost like *args in python...

Manish Giri
@Manish-Giri
Mar 25 2017 00:22
@the-vampiire the arguments object has it..
Vamp
@the-vampiire
Mar 25 2017 00:23
dog
doh* should have clicked the mdn arguments link. sorry for wasting time
Michael Grienauer
@mgrienauer
Mar 25 2017 00:24
@SkyCoder01 ahh ok ill try using replace
@the-vampiire that's the second argument to reduce
its like an inital value
Gulsvi
@gulsvi
Mar 25 2017 00:25
@mike93og93 If you're trying to figure out if it's an array, use Array.isArray(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
Michael Grienauer
@mgrienauer
Mar 25 2017 00:26
@SkyCoder01 ah...shit lol yea
@SkyCoder01 thanks
CamperBot
@camperbot
Mar 25 2017 00:26
mike93og93 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 665 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
Mar 25 2017 00:27
No problem :)
I didn't think of it until just now either for some reason...
Michael Grienauer
@mgrienauer
Mar 25 2017 00:32
@SkyCoder01 its the only hint in the challenge lol idk why it didnt click in my head
Dick Tonye
@SimpletechSolution
Mar 25 2017 00:33

my code for counting cardvar count = 0;

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

I'm thinking of using nested if/else as another option, my problem is with testing the new value of count vs. zero to return Bet or Hold @sjames1958gm help please
Michael Grienauer
@mgrienauer
Mar 25 2017 00:35
@SkyCoder01 not really sure what to do once I know its an array though...then im back at trying to use regex to replace the brackets
Gulsvi
@gulsvi
Mar 25 2017 00:36
@mike93og93 Once you find out if it's in array, you need to try and reduce/flatten it again.
This is where recursion can come in handy
Michael Grienauer
@mgrienauer
Mar 25 2017 00:39
@SkyCoder01 but my original reduce is making a new array, which i dont really want to do with this array within an array
Moisés Man
@moigithub
Mar 25 2017 00:39

@SimpletechSolution u should do in 2 steps..

  1. increase or decrease count based on card value
  2. evaluate count.. and return Hold or Bet

make sure u not reset/set to 0 count value

Saboor Malik
@MathematicsCoding
Mar 25 2017 00:40
function titleCase(str) {
    str = str.toLowerCase();
    str = str.split(' ');
    str = str.map(capitalize).join(" ");
    return str;
}

function capitalize(val) {
    var a = val.charAt(0);
    var b = a.toUpperCase();
    val = val.replace(a, b);
    return val;
}
titleCase("hello");
Michael Grant Warshowksy
@step48765
Mar 25 2017 00:48
Hey guys I have a question at what point do you think someone could classify themselves as good at JavaScript and move onto another language?
Nefer Lopez
@thatguynef
Mar 25 2017 01:02

Can you help me refactor my code?

Objective
Radio button selection populates option elements with values from "pizza" object into a dropdown menu.

There must be a more efficient approach.

Here's my code: https://jsfiddle.net/rugezw0t/2/

I welcome your critiques.

Thanks in advance!

JDW
@jd-wheaton
Mar 25 2017 01:03
For the challenge "Build a Random Quote Machine" are we to just find a quote generation API?
everybody in bed? :)
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:07
lol
@jd-wheaton Can you help me?
Actually just a question
JDW
@jd-wheaton
Mar 25 2017 01:07
Sure, if I'm able too, I will.
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:07
How do you access array from parameter? like inside function block?
Manish Giri
@Manish-Giri
Mar 25 2017 01:07
@jd-wheaton you could, or you could just store the quotes in arrays..
JDW
@jd-wheaton
Mar 25 2017 01:08
By parameter do you mean argument?
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:08
function abc(str) {
return str;
}
abc([4,5,6,7]);
Like How do I return 4 or something...
JDW
@jd-wheaton
Mar 25 2017 01:08
You could use a loop.
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:08
Inside function?
Ahmed Osman
@Noby707
Mar 25 2017 01:09
Do you want to return 4
like get the value
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:09
Nah that just an example
Yeah I guess
Vamp
@the-vampiire
Mar 25 2017 01:09
@MathematicsCoding great job man! unique way of approaching that problem here you can condense a lot of the main body function
function titleCase(str) {

    return str.toLowerCase().split(' ').map(capitalize).join(' ');
}

function capitalize(val) {
    var a = val.charAt(0);
    var b = a.toUpperCase();
    val = val.replace(a, b);
    return val;
}
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:09
For this challenge: Return Largest Numbers in Arrays
JDW
@jd-wheaton
Mar 25 2017 01:09
Put an if inside a for loop
Oh, I see what your asking.
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:10
@the-vampiire thanks actually someone gave me a different solution and explain that solution through to me I understood but I wanted to find different one easier one
CamperBot
@camperbot
Mar 25 2017 01:10
mathematicscoding sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Vamp
@the-vampiire
Mar 25 2017 01:11
@MathematicsCoding you can use sort to set it from largest to smallest then use an array method to remove and return the largest (first) value. or sort from small to large and use other method to remove and return the last one
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:11
I found code like that on youtube and adjusted it alittle
JDW
@jd-wheaton
Mar 25 2017 01:11
Multi-dimensional array.
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:12
.split wont works on array right?
Vamp
@the-vampiire
Mar 25 2017 01:12
@MathematicsCoding
function make_caps(str){
// create a variable array called split
// take the function argument ‘str’ and make it all lowercase then split it into individual words separated by spaces
// this makes an array called split whose elements are each individual word in the original string in lowercase 
   var  split = str.toLowerCase().split(' ‘);

// create an empty array called ‘in_caps’ to store the output of the loop below
   var  in_caps = [];

// loop through each element in the array ‘split’ by startin at 0 and going up to the length of the array split
    for(var i = 0; i < split.length; i++){

// add each iteration to the array ‘in_caps’ by using the array method push()
// inside push is where you define what you want to push into array ‘in_caps’
// split[i].slice(0,1) —> this is taking split element ‘i’ (for each iteration of the loop) 
// and taking the first character of that element
// now that you have identified the first character you will make it upper case using .upperCase() method
// now concatinate this new uppercase first character with the rest of the word using +split[i].slice(1);
// this will combine the uppercase letter with the remainder of each word string slice(1)
//  means slice from index 1 of the word to the end meaning 
// every letter beyond the first that you already capitalized

        in_caps.push(split[i].slice(0,1).toUpperCase()+split[i].slice(1));
    }

// outside of the loop you will return in_caps as a string by using join(‘ ‘) method
// here you are joining with a space in between each element of ‘in_caps’ 

    return in_caps.join(' ');
}

console.log(make_caps('toDay i WAlked tHe dOGs.')); // returns: 'Today I Walked The Dogs.'
@MathematicsCoding I wrote this for you earlier I guess you never saw it
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:12
@the-vampiire I completed that challenge..
Yeah I did :p
When someone gave an solution that time then I saw it
Vamp
@the-vampiire
Mar 25 2017 01:13
split is to turn a string into array
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:13
But somehow that solution never worked and I realized he forgot to add str = str.toLowerCase();
JDW
@jd-wheaton
Mar 25 2017 01:14
You need to iterate (for) the array, but you need to access the array inside the array. aka. arr[i][0];
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:14
@the-vampiire Oh of course they are string method
Vamp
@the-vampiire
Mar 25 2017 01:14
@jd-wheaton what? the problem he posted code for is a single dimension he can just index it as usual
JDW
@jd-wheaton
Mar 25 2017 01:15
Return Largest Numbers in Array?
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:15
Yeah
Vamp
@the-vampiire
Mar 25 2017 01:15
I didnt look at the problem jst the code he posted
function abc(str) {
return str;
}
abc([4,5,6,7]);
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:15
Well I was just...
Never mind here's my current code
Vamp
@the-vampiire
Mar 25 2017 01:16
[4, 5, 6, 7] is single dimension
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:16

function largestOfFour(arr) {
  // You can do this!
  return arr.sort(' ');
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
JDW
@jd-wheaton
Mar 25 2017 01:16
Yeah, you need to look at an array in an array: largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])
Vamp
@the-vampiire
Mar 25 2017 01:16
oh this is a completely different problem
idk what that code was you posted before
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:16
@the-vampiire I was asking how to return that 4
JDW
@jd-wheaton
Mar 25 2017 01:16
first off, you don't need to sort it
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:17
Okay it just reverse it
JDW
@jd-wheaton
Mar 25 2017 01:17
You don't need to do that either
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:17
Oh
Vamp
@the-vampiire
Mar 25 2017 01:17
return the first 4?
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:17
So I dont need .sort for this challenge?
Yeah @the-vampiire
Vamp
@the-vampiire
Mar 25 2017 01:17
arr[0][0]
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:17
Like inside function
JDW
@jd-wheaton
Mar 25 2017 01:17
@the-vampiire correct
you don't need any array methods for this challenge
Vamp
@the-vampiire
Mar 25 2017 01:18
arr[index of outer array][index of inner array][index of inner inner array…]
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:18
I got it...

function largestOfFour(arr) {
  // You can do this!
   arr = arr[0][0];
  return arr;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Now that refresh my memory...
Vamp
@the-vampiire
Mar 25 2017 01:18
isnt this question asking you to return an array of the largest value in each sub-array?
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:19
Yes
Vamp
@the-vampiire
Mar 25 2017 01:19
I don’t remember specifically waht it asked for
but I thought thats waht is ws
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:19
It does
Vamp
@the-vampiire
Mar 25 2017 01:19
what it was*
so why do you want 4?
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:19
I just forgot how to access array
So..
Vamp
@the-vampiire
Mar 25 2017 01:19
the largest number in arr[0] is 5, in arr[1] is 27, in arr[2] is 39, in arr[3] is 1001
JDW
@jd-wheaton
Mar 25 2017 01:19
so loop the array -> access the inner array arr[i][0] -> iterate the inner array -> look for largest element -> save largest element to new array -> return the resulting array
grantknaver
@grantknaver
Mar 25 2017 01:20
anyone free to help me with a problem with the ticktac toe assignment
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:20
a for loop?
if so inside function?
JDW
@jd-wheaton
Mar 25 2017 01:20
for loop, inside the func yes
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:20
Okay
function largestOfFour(arr) {
  // You can do this!
  for (i = 0; i < arr.length; i++) {

 }
  return arr;


}
JDW
@jd-wheaton
Mar 25 2017 01:22
put a var in front of your i
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:22
Alright
I forgot... that or var i before for loop
Whats now?
Vamp
@the-vampiire
Mar 25 2017 01:22
saboor you need to think about your code my man
i think you spend too much time copying from videos or other solutions and you dont think about what you are doing
JDW
@jd-wheaton
Mar 25 2017 01:23
now you need to access the inner array
and save it to a new var
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:24
After for loop? create new variable then assign it arr?
JDW
@jd-wheaton
Mar 25 2017 01:24
it should look like this
function largestOfFour(arr) {
  for (var i = 0; i < arr.length; i++) {
    var a = arr[i][0];
  }
}
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:25
Yeah I did that
Oh didnt add var...
I thought it would be something like this
JDW
@jd-wheaton
Mar 25 2017 01:25
Now use another for loop, and itterate through the inner array.
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:25

function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr.length; i++) {
   arr = arr[i][0];
 }
  var abc = arr.length;
  return abc;


}
JDW
@jd-wheaton
Mar 25 2017 01:25
don't use i
on your second loop, don't use i again, use a new counter
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:26
function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
 }
}
Okay I will use j
JDW
@jd-wheaton
Mar 25 2017 01:26
since your already at element [0] on the inner array, start your j counter at 1
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:26
function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
 }
  for (var j = 0; j < arr.length; i++) {

  }
}
Vamp
@the-vampiire
Mar 25 2017 01:27
why are you capturing the first element in each subarray? they are not sorted this will just be an arbitrarily sized element. could be biggest could be smallest could be anything in between...
JDW
@jd-wheaton
Mar 25 2017 01:27
Nope, that needs to go inside the first for loop
you'll see @the-vampiire
Vamp
@the-vampiire
Mar 25 2017 01:27
and you are incrementing j in this second loop, check your increment
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:27
Ok create another var or same var to store that arr[j][0]?
JDW
@jd-wheaton
Mar 25 2017 01:28
yeah, your second loops max length should be arr[i].length
no, you need an if statement
to see what's larger
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:28
function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr[i].length; i++) {
   var x = arr[i][0];
    for (var j = 0; j < arr[j].length; i++) {

 }
  }
}
Is that ok now?
Carson Michael
@Carson2003
Mar 25 2017 01:29
can someone help me understand the return early pattern for functions challenge
Vamp
@the-vampiire
Mar 25 2017 01:29
@MathematicsCoding check your increment in your inner for loop..
@Carson2003 post your code and what the question is asking / where you are stuck
JDW
@jd-wheaton
Mar 25 2017 01:29
Sort of...
function largestOfFour(arr) {
  for (var i = 0; i < arr.length; i++) {
    var a = arr[i][0];
    for (var j = 1; j < arr[i].length; j++) {

    }
  }
}
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:29
..
whoops...
Carson Michael
@Carson2003
Mar 25 2017 01:30
I just dont understand what to do here is my code

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

// Only change code above this line

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

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

Saboor Malik
@MathematicsCoding
Mar 25 2017 01:30
Ok done
Vamp
@the-vampiire
Mar 25 2017 01:30
when you post code use `` above and below the code to format it properly for the chat. the \ symbol is the key below your esc key
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:30
Output says it will crash my browser...
Vamp
@the-vampiire
Mar 25 2017 01:30
```
JDW
@jd-wheaton
Mar 25 2017 01:30
Now, you need to do a test of arr[i][j] > largest
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:31
After second for loop?
Vamp
@the-vampiire
Mar 25 2017 01:31
@Carson2003 like this
// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
JDW
@jd-wheaton
Mar 25 2017 01:31
yes, inside second loop, you need an if
Carson Michael
@Carson2003
Mar 25 2017 01:31
ok
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:31
function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr[i].length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[j].length; i++) {
    if (arr[i][j] > largest) {

      }
    }
  }
}
JDW
@jd-wheaton
Mar 25 2017 01:32
yes, but your first and second loop have a bad max length assignment
Carson Michael
@Carson2003
Mar 25 2017 01:32
what you have is all I have
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:32
So change length to 2000?
JDW
@jd-wheaton
Mar 25 2017 01:33
1st loop arr.length 2nd loop arr[i].length
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:33
function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[i].length; i++) {
    if (arr[i][j] > largest) {

      }
    }
  }
}
JDW
@jd-wheaton
Mar 25 2017 01:33
arr [i] not j
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:33
oh..
Largest is not defined
Vamp
@the-vampiire
Mar 25 2017 01:34
@Carson2003 there is nothing we can do with that code. we have no context as to what you are trying to accomplish
JDW
@jd-wheaton
Mar 25 2017 01:34
ok, so now you need to set the largest var to the element you just tested
Carson Michael
@Carson2003
Mar 25 2017 01:35
It wants me to do this "Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined."
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:35
@jd-wheaton I dont get it..
What do you mean by largest var?
JDW
@jd-wheaton
Mar 25 2017 01:36
largest = arr[i][j]
inside your if block
Vamp
@the-vampiire
Mar 25 2017 01:36
@Carson2003 so then put a conditional statement above that return to test if a or b are less than 0 and return ‘undefined’ in the conditonal block
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:36

function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[i].length; i++) {
      var largest;
    if (arr[i][j] > largest) {
      largest = arr[i][j];
      }
    }
  }
}
JDW
@jd-wheaton
Mar 25 2017 01:37
now, at the top of your code block, create an empty array with a name of your choosing
Vamp
@the-vampiire
Mar 25 2017 01:37
@Carson2003
if(what the question is asking){
return undefined
}

return the statement already given to you in the problem
Carson Michael
@Carson2003
Mar 25 2017 01:38
thanks @the-vampiire
CamperBot
@camperbot
Mar 25 2017 01:38
carson2003 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:38
largestOfFour = [];
function largestOfFour(arr) {
  // You can do this!
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[i].length; i++) {
      var largest;
    if (arr[i][j] > largest) {
      largest = arr[i][j];
      }
    }
  }
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Vamp
@the-vampiire
Mar 25 2017 01:38
@Carson2003 does this solve your problem?
JDW
@jd-wheaton
Mar 25 2017 01:38
don't use that name, and put it just inside the function
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:39

function largestOfFour(arr) {
  abc = [];
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[i].length; i++) {
      var largest;
    if (arr[i][j] > largest) {
      largest = arr[i][j];
      }
    }
  }
}
JDW
@jd-wheaton
Mar 25 2017 01:40
ok, now, at the end of the 1st for block, you need to set your new array at index "i" to largest
Ricky Jairath
@rckjairath
Mar 25 2017 01:40
var myStr="FirstLine \n \SecondLine\ \r ThirdLine"; // Change this line
special characters are not working
JDW
@jd-wheaton
Mar 25 2017 01:40
@rckjairath you only need to escape certain characters
Moisés Man
@moigithub
Mar 25 2017 01:40
instruction says NO spaces @rckjairath
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:41

function largestOfFour(arr) {
  abc = [i];
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[i].length; i++) {
      var largest;
    if (arr[i][j] > largest) {
      largest = arr[i][j];
      }
    }
  }
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
JDW
@jd-wheaton
Mar 25 2017 01:43
function largestOfFour(arr) {
  abc = [];
  for (var i = 0; i < arr.length; i++) {
    var a = arr[i][0];
    for (var j = 1; j < arr[i].length; j++) {
      if (arr[i][j] > largest) {
        largest = arr[i][j];
      }
    }
    abc[i] = largest;
  }
}
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:43

function largestOfFour(arr) {
  abc = [];
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[i].length; i++) {
      var largest;
    if (arr[i][j] > largest) {
      largest = arr[i][j];
      }
      abc[i] = largest;
    }
  }
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
JDW
@jd-wheaton
Mar 25 2017 01:44
nope, one more brace out
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:44
oh
Why is that?
JDW
@jd-wheaton
Mar 25 2017 01:44
your indenting is messed up, you can't see why that is
your putting data in during initial for loop is why
now all you have to do is return abc, just before your closing brace
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:46
It says "largest used out of scope"
JDW
@jd-wheaton
Mar 25 2017 01:46
well where did you put it?
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:47
Same place where you put it...

function largestOfFour(arr) {
  abc = [];
  for (var i = 0; i < arr.length; i++) {
   var x = arr[i][0];
    for (var j = 1; j < arr[i].length; i++) {
      var largest;
    if (arr[i][j] > largest) {
      largest = arr[i][j];
      }
    }
    abc[i] = largest;
  }
}
Vamp
@the-vampiire
Mar 25 2017 01:47
you can not use a variable in a conditional statement and then define it within that conditional block it must be defined before it is used
JDW
@jd-wheaton
Mar 25 2017 01:47
look at your indentation, it's wrong
you want to take out that var largest line
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:48
oh
JDW
@jd-wheaton
Mar 25 2017 01:48
you should have this
function largestOfFour(arr) {
  abc = [];
  for (var i = 0; i < arr.length; i++) {
    var a = arr[i][0];
    for (var j = 1; j < arr[i].length; j++) {
      if (arr[i][j] > largest) {
        largest = arr[i][j];
      }
    }
    abc[i] = largest;
  }
}
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:48
Yeah
removed that variable
JDW
@jd-wheaton
Mar 25 2017 01:48
now before the closing brace, return your abc array
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:49
But largest is not defined...
Vamp
@the-vampiire
Mar 25 2017 01:49
ya
you can not use a variable in a conditional statement and then define it within that conditional block it must be defined before it is used
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:49
Which is why I put that variable..

function largestOfFour(arr) {
  abc = [];
  for (var i = 0; i < arr.length; i++) {
    var a = arr[i][0];
    for (var j = 1; j < arr[i].length; j++) {
      if (arr[i][j] > largest) {
        largest = arr[i][j];
      }
    }
    abc[i] = largest;
  }
  return abc;
}
Joseph
@revisualize
Mar 25 2017 01:52
Or you could .push()
JDW
@jd-wheaton
Mar 25 2017 01:52
you could do that, this is way more ghetto
Joseph
@revisualize
Mar 25 2017 01:53
abc[i] = ..... Should be a push.
Vamp
@the-vampiire
Mar 25 2017 01:53
here is the solution @MathematicsCoding
except one or two things may be misplaced or missing. if you go line by line you will see how to fix it and get the answer
function largestOfFour(arr) {
    // You can do this!
    largest = [];
    for(var i = ?; i < arr.length; i??) {
        arr[i].sort(function (a, b) {
            return a - b;
        });

        largest.push(arr[].pop());

    }

    return largest;

}
Jordan
@jl-code1721
Mar 25 2017 01:53
Can someone please help me with 'Profile Lookup' no. ~216
I can't really do any of it
Saboor Malik
@MathematicsCoding
Mar 25 2017 01:56
function largestOfFour(arr) {
    // You can do this!
    largest = [];
    for(var i = 0; i < arr.length; i++) {
        arr[i].sort(function (a, b) {
            return a - b;
        });

        largest.push(arr[].pop);

    }

    return largest;

}
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 01:57
can you loop through an object like an array?
Vamp
@the-vampiire
Mar 25 2017 01:57
object properties?
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 01:58
I'm working on Profile Search, and I'm having a lot of difficulty with it.
Jordan
@jl-code1721
Mar 25 2017 01:58
@TinCan-Assassin So am i!
Manish Giri
@Manish-Giri
Mar 25 2017 01:59
@TinCan-Assassin all you need to do is check if the object does have the property you're looking for.
you can use .hasOwnProperty() for it.
you don't need to loop through the object properties specifically, for that challenge.
Vamp
@the-vampiire
Mar 25 2017 02:04
@MathematicsCoding nope
Saboor Malik
@MathematicsCoding
Mar 25 2017 02:04
I dont want that solution...
Vamp
@the-vampiire
Mar 25 2017 02:04
@Manish-Giri for the record though you can access object properties using an index like an array, no?
@MathematicsCoding okay
Saboor Malik
@MathematicsCoding
Mar 25 2017 02:05
Sorry
Vamp
@the-vampiire
Mar 25 2017 02:05
@MathematicsCoding no worries
Manish Giri
@Manish-Giri
Mar 25 2017 02:07
@the-vampiire yup
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:07
function confirmEnding(str, target) {
  var start= str;
  var start1= start.substring(start.length -4);
  if (target.length===start1.length){
    return true;
  } else {
    return false;
  }
  return start1;
}

confirmEnding("Bastian", "n");
Bastian n should return true
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:08
@Manish-Giri I've tried. nothing Im doing is working.
Vamp
@the-vampiire
Mar 25 2017 02:09
@Manish-Giri well thinking about it I believe you can access the contacts by index because they are objects within an array. but for example you could not do
var person = {
‘name’:’bob’,
‘height’:64,
‘weight’:150
}

person[0] != bob
@ronnieg1988 I disagree
you have return start1
this is a string (more specifically a substring) not a boolean
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:11
@the-vampiire its not thats what im say
Vamp
@the-vampiire
Mar 25 2017 02:11
well even in your condition
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:12
its have to return a true or false
Vamp
@the-vampiire
Mar 25 2017 02:12
substring(start,end)
substring(start) without specifying an end will go from the start automatically to the end
so start1.length = 4, target.length = 1
start1.length != target.length
@ronnieg1988 make sense?
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:14
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var x =0; x < contacts.length; x++){
    for (var y = 0; y < contacts[x].length; y++){
      if (firstName === contacts[x][y].hasOwnProperty()){
        if (prop === contacts[x][y].hasOwnProperty()){
          return prop;
        }
         return firstName;
      }
      else return "No such property";
    } 
     return "No such contact";
}

// Only change code above this line
}
What am I doing wrong?
Manish Giri
@Manish-Giri
Mar 25 2017 02:14
@the-vampiire I thought you meant to access the object properties (not their values) in an array format..
var person = {
'name':'bob',
'height':64,
'weight':150
}

Object.keys(person)[1]; //"height"
Eric Long
@ejlong90
Mar 25 2017 02:15
Ok so i have taken a little break from doing javascript and i hope that isn't the reason i am having trouble. But I am stuck with this
Vamp
@the-vampiire
Mar 25 2017 02:15
@TinCan-Assassin you can only access each object in the array called contacts using an index. you can not access the properties OF the object using an index
Eric Long
@ejlong90
Mar 25 2017 02:15

Instructions
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.

this is my code:

function myLocalScope() {
'use strict';
myVar = "Hello World";

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

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

Vamp
@the-vampiire
Mar 25 2017 02:16
function myLocalScope() {
'use strict';
myVar = "Hello World";
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
// Now remove the console log line to pass the test
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:16

We have an array of objects representing different people in our contacts lists.

A lookUpProfile function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Vamp
@the-vampiire
Mar 25 2017 02:17
@Manish-Giri oh okay maybe through this method. I meant in a simple index like you would index an array
@Manish-Giri which is what @TinCan-Assassin is trying to do in his function
Manish Giri
@Manish-Giri
Mar 25 2017 02:17
@the-vampiire yeah that won't work..
Vamp
@the-vampiire
Mar 25 2017 02:18
@ejlong90 wha is the problem asking you to do?
@ejlong90 I am reading ‘now remove the console log line to pass the test'
Manish Giri
@Manish-Giri
Mar 25 2017 02:18
@TinCan-Assassin for (var y = 0; y < contacts[x].length; y++){
why're you doing this?
contacts is not a 2D array..
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:19

function confirmEnding(str, target) {
  var start= str;
  var start1= start.substring(start.length -4);
  if (target.length==4, start1.length==1){
    return true;
  } else if (start1.length != target.length){
    return false;
  }
  return start1;
}

confirmEnding("Bastian", "n");
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:19
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var x =0; x < contacts.length; x++){
      if (firstName === contacts[x].hasOwnProperty()){
        if (prop === contacts[x].hasOwnProperty()){
          return prop;
        }
         return firstName;
      }
      else return "No such property";
    } 
     return "No such contact";


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Still doesn't work
Eric Long
@ejlong90
Mar 25 2017 02:19
Declare the variable @the-vampiire , which i did, and i removed the console.log line and nothing happened. Both of them
Vamp
@the-vampiire
Mar 25 2017 02:19
what is the name of this challenge @ejlong90
Eric Long
@ejlong90
Mar 25 2017 02:20
Local Scopes and Functions
@the-vampiire
Vamp
@the-vampiire
Mar 25 2017 02:20
@ejlong90 I will look up what I had to do to pass it so I can guide you
Manish Giri
@Manish-Giri
Mar 25 2017 02:20
@TinCan-Assassin you need to lookup .hasOwnProperty()
Eric Long
@ejlong90
Mar 25 2017 02:20
Thank you, yeah all i am looking for is how to understand it @the-vampiire
CamperBot
@camperbot
Mar 25 2017 02:20
ejlong90 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Vamp
@the-vampiire
Mar 25 2017 02:20
@ejlong90 paste the code exactly as you have it currently please so I can compare
Eric Long
@ejlong90
Mar 25 2017 02:21

@the-vampiire
function myLocalScope() {
'use strict';
myVar = "Hello World";

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

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

Vamp
@the-vampiire
Mar 25 2017 02:21
btw you can use ``` mark to paste your code
put ``` above and below your code then hit enter and it will format it
@ejlong90
like this
function myLocalScope() {
'use strict';
myVar = "Hello World";
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
// Now remove the console log line to pass the test
when you come in the chat for help you are much more likely to receive help if you format it like this. easier on the eyes. let me take a look now
Eric Long
@ejlong90
Mar 25 2017 02:22
function myLocalScope() {
  'use strict';
myVar = "Hello World";


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

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test
I see now
Vamp
@the-vampiire
Mar 25 2017 02:22
nice
@ejlong90 okay I see your problem
the challenge is asking you to define a var myVar
what you have done is define a var myVar AND assigned a string to it.
try just doing the former, as well as deleting that console log it tells you to delete.
Saboor Malik
@MathematicsCoding
Mar 25 2017 02:24
function largestOfFour(arr) {
    return arr.map(function(x){return Math.max(...x)});
    }
Vamp
@the-vampiire
Mar 25 2017 02:25
@ejlong90 lessons here
to DEFINE a variable use the keyword ‘var’
var aVariable;
to ASSIGN a variable use the assignment operator ‘=‘
var aVariable = assignment;
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:26

function confirmEnding(str, target) {
  var start= str;
  var start1= start.substring(start.length -4);
  if (target.length==4, start1.length==1){
    return true;
  } else if (start1.length != target.length){
    return false;
  }
  return start1;
}

confirmEnding("Bastian", "n");
Vamp
@the-vampiire
Mar 25 2017 02:26
and in order to assign a variable you must define it first as you see. in your case you went too far ahead of what they asked! you are in the begnning of FCC so if you have prior experience some stuff may seem so trivial that you overthink / overdo it as you have in this case.
Saboor Malik
@MathematicsCoding
Mar 25 2017 02:26
Sigh Im not good with Javascript yet
I guess I will do JS lessons on codecademy and get a book about JS
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:27
@the-vampiire i guess im still confused
Vamp
@the-vampiire
Mar 25 2017 02:27
@MathematicsCoding I will reiterate. you are not improving your skills by copy and pasting code or asking somoene to write it for you. you need to THINK and TRY on your own. this is how you learn

@MathematicsCoding I have been in this chat all day. I spent 3 hours trying to help you understand without outright giving you the code to solve the first capital letter challenge. instead you ignored all of my advice and attempts to help and turned to copying from youtube. this is now how you learn my man. sorry to be harsh but this is what you need to hear.

I will spend hours of my own day helping with what I can as long as I see a genuine effort and attempt to learn from the person I am helping. but if I do not see genuine effort and learning then I am insulted for wasting my time

Eric Long
@ejlong90
Mar 25 2017 02:29
I got it now the issue i was having was simply not defining the variable

function myLocalScope() {
  'use strict';
var myVar = myVar; 


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

// Run and check the console
// myVar is not defined outside of myLocalScope


// Now remove the console log line to pass the test
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:30
i know i need to return a true or false value on the string not the length like "bastian" "n" has to return true and "connor" "n" should be false to its not the length of the strings @the-vampiire
Saboor Malik
@MathematicsCoding
Mar 25 2017 02:30
I know... Im not just copying solution... So I can try to understand them
Vamp
@the-vampiire
Mar 25 2017 02:30
@ejlong90 hah you actually got around it by assigning the variable to itself. the answer you were looking for was just var myVar;
@ejlong90 thats all. no assignment to the variable, no ‘=‘ assignment operator is to be used for that challenge
Eric Long
@ejlong90
Mar 25 2017 02:31
oh so i still didn't do it right? @the-vampiire
Vamp
@the-vampiire
Mar 25 2017 02:31
@ronnieg1988 you are looking at the problem wrong. your current approach is finding and comparing lengths. the problem is not asking if their lengths match. the problem is asking if the characters / string of characters match
@ejlong90 technically you beat the system lol. the correct answer is simply to write var myVar; nothing else
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:32
I'm very, very frustrated.
Vamp
@the-vampiire
Mar 25 2017 02:32
@ejlong90 I believe you have broken through the test by writing var myVar = myVar; so the system thinks you never assigned anything
Manish Giri
@Manish-Giri
Mar 25 2017 02:32
@TinCan-Assassin why?
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:32
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var x =0; x < contacts.length; x++){
      if (contacts[x].hasOwnProperty(firstName)){
        return contacts[x][firstName];
        }
         else return "No such contact";

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



// Only change code above this line
}
Eric Long
@ejlong90
Mar 25 2017 02:32

like this

```

function myLocalScope() {
  'use strict';
var myVar; 


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

// Run and check the console
// myVar is not defined outside of myLocalScope


// Now remove the console log line to pass the test
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:33
Still not working.
Vamp
@the-vampiire
Mar 25 2017 02:33
@ejlong90 yep you got it bro
Eric Long
@ejlong90
Mar 25 2017 02:33
cool man @the-vampiire
Vamp
@the-vampiire
Mar 25 2017 02:34
@ejlong90 like I said right now you are in the beginning so you are overthinking and overdoing your solutions. the system that is testing whether you got it right or not is purely objective. follow the directions literally and you’ll be fine
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:34
lol sometimes the directions are confusing
Vamp
@the-vampiire
Mar 25 2017 02:35
@TinCan-Assassin lets start at the top. you need to check what? if the first name given to you as an argument to the function is found in your contacts list
Eric Long
@ejlong90
Mar 25 2017 02:35
thanks again @the-vampiire
CamperBot
@camperbot
Mar 25 2017 02:35
ejlong90 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: ejlong90 already gave the-vampiire points
Vamp
@the-vampiire
Mar 25 2017 02:35
@ejlong90 got you bro
Eric Long
@ejlong90
Mar 25 2017 02:35
and i agree @ronnieg1988 its confusing a lot
Vamp
@the-vampiire
Mar 25 2017 02:36
@ronnieg1988 it helps to write out in words (pseudocode) what you want your code to accomplish. then start writing the code to accomplish what you want it to do. it is said that it’s better to write out the pseudocode before you ever begin typing out your code
akhilreddy2623
@akhilreddy2623
Mar 25 2017 02:36
can anyone help me with Stand in Line
Vamp
@the-vampiire
Mar 25 2017 02:36
@ronnieg1988 that way you know exactlly what you are doing on every line rather than mucking about and getting confused
Tre' Anderson-Davis
@TreAhmad3
Mar 25 2017 02:37
could anybody help with the Counting Cards function?
Vamp
@the-vampiire
Mar 25 2017 02:37
@ronnieg1988 so why dont you try here. write out in words what you want your function to do. I am not trying to patronize you - I promise this will help
@TinCan-Assassin do the same
ellen he
@naellenhe
Mar 25 2017 02:38
I'm stuck in Profile Lookup too..
Manish Giri
@Manish-Giri
Mar 25 2017 02:38
@TreAhmad3 what's the problem?
akhilreddy2623
@akhilreddy2623
Mar 25 2017 02:38
console.log("After: " + JSON.stringify(testArr));///
Vamp
@the-vampiire
Mar 25 2017 02:39
does anyone here know if I can use twitch to stream my screen as I work through the code?
I can help you guys it will be much easier for me to explain in words rather than type everything out in this busy chat room
akhilreddy2623
@akhilreddy2623
Mar 25 2017 02:39

function nextInLine(arr, item) {
// Your code here
arr.push([5,6,7,8,9]);
return item; // Change this line
}

// Test Setup
var testArr = [];

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

Tre' Anderson-Davis
@TreAhmad3
Mar 25 2017 02:39
@Manish-Giri I'm getting everything correct answers for everything except for when the card sequence is (2, J, 9, 2, 7) and (2, 2, 10)
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:39
OK. I want to check the arguments in the function against the objects in the array. The function is already declared.
Collin Ballou
@BlueEagle
Mar 25 2017 02:39
Trying the Golf Code portion of the course and I haven't the slightest clue where I goofed. Any ideas?

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == 1) return "Hole-in-one!";
  if (strokes <= par-2) return "Eagle!";
  if (strokes == par-1) return "Birdie!";
  if (strokes == par) return "Par";
  if (strokes == par+1) return "Bogey!";
  if (strokes == par+2) return "Double Bogey!";
  if (strokes >= par+3) return "Go Home!";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
CamperBot
@camperbot
Mar 25 2017 02:39
:bulb: to format code use backticks! ``` more info
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:40
So I need to loop through the array to get to the right object.
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:40
@the-vampiire i need to check the first string argument(str) ends with the second string argument (target)
Vamp
@the-vampiire
Mar 25 2017 02:40
@ronnieg1988 ok perfect now lets expand on this idea
how MUCH of the first string needs to match?
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:40
Is there such a thing as PM in here?
Vamp
@the-vampiire
Mar 25 2017 02:41
@TinCan-Assassin yes you hover over the picture and go to private message
Manish Giri
@Manish-Giri
Mar 25 2017 02:41
@TreAhmad3 show your code..
Collin Ballou
@BlueEagle
Mar 25 2017 02:41
Ah, nice catch! @the-vampiire
Tre' Anderson-Davis
@TreAhmad3
Mar 25 2017 02:41

``` var count = 0;

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

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

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

Saboor Malik
@MathematicsCoding
Mar 25 2017 02:42
@TinCan-Assassin In full chatroom yeah
Vamp
@the-vampiire
Mar 25 2017 02:42
@TreAhmad3 hey man dont forget to put ``` at the end of your code as well.
Eric Long
@ejlong90
Mar 25 2017 02:42
@the-vampiire that makes a lot of sense when you said it helps to write out in pseudocode what you want your code to do. then to start writing the code in the way it tell you to
Tre' Anderson-Davis
@TreAhmad3
Mar 25 2017 02:43
var count = 0;

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


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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(2); cc(10);
thank you @the-vampiire
CamperBot
@camperbot
Mar 25 2017 02:43
treahmad3 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Vamp
@the-vampiire
Mar 25 2017 02:43
@ejlong90 its a word map if you will. if you go on a trip somewhere new (javascript land) will you go without any idea of where you’re going or how you’ll get there? no way. so you write a map first and then you have something ti follow
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:43
@the-vampiire i know substring() can return the values from the end of the strings
Manish Giri
@Manish-Giri
Mar 25 2017 02:43
@TreAhmad3 keep the if statements outside the switch..
Vamp
@the-vampiire
Mar 25 2017 02:44
@ronnieg1988 dont skip ahead. I will walk you through the problem if you think of good answers to my questions. i wont give the solution you will get there yourself
TinCan-Assassin
@TinCan-Assassin
Mar 25 2017 02:44
Can I get someone to privately chat with me to solve the Profile Lookup problem?
Eric Long
@ejlong90
Mar 25 2017 02:44
true @the-vampiire
Saboor Malik
@MathematicsCoding
Mar 25 2017 02:44
Ok bye Im going to watch a video about Javascript (5.6 hours)
akhilreddy2623
@akhilreddy2623
Mar 25 2017 02:45
how to copy the code from editor to here,can any one help me
Tre' Anderson-Davis
@TreAhmad3
Mar 25 2017 02:45
thank you @Manish-Giri
CamperBot
@camperbot
Mar 25 2017 02:45
treahmad3 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4909 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 25 2017 02:45
@akhilreddy2623
''' read the link
CamperBot
@camperbot
Mar 25 2017 02:45
:bulb: to format code use backticks! ``` more info
queenoflamps
@queenoflamps
Mar 25 2017 02:46
does anyone know what im supposed to do for the first challenge on wordblanks?
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:47
@the-vampiire it doesnt have a specific length it has to end with it just has to end with the target
Moisés Man
@moigithub
Mar 25 2017 02:47
form a phrase/sentence with the words provided @queenoflamps
and of course.. USING the parameters/variables
Vamp
@the-vampiire
Mar 25 2017 02:47
@ronnieg1988 okay. now is this target always the same length?
queenoflamps
@queenoflamps
Mar 25 2017 02:47
ok
thanks
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:47
@the-vampiire no
Vamp
@the-vampiire
Mar 25 2017 02:48
@ronnieg1988 ok good. so this means that the length of your main string that you need to match will be based on the length of the target?
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:48
@the-vampiire yes
Vamp
@the-vampiire
Mar 25 2017 02:49
@ronnieg1988 good okay. so what string method can you use to get a specifically sized portion of the main string?
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:51
substr() can extract stings
Vamp
@the-vampiire
Mar 25 2017 02:52
@ronnieg1988 yep. how does substr() work?
@ronnieg1988 what arguments do you pass to the subst() method?
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:52
substr(start, length)
Vamp
@the-vampiire
Mar 25 2017 02:52
close
substr(start,end)
Rick
@r7uaz0n
Mar 25 2017 02:53
I am doing the Stand in Line challenge.
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:53
so i need to pass target in to substr()
Vamp
@the-vampiire
Mar 25 2017 02:53
@ronnieg1988 my pup is whining we have to go for a walk. I will help when I get back. use what werve discussed so far it should be enough to solve the problem
close
substr does not take strings as parameters
Rick
@r7uaz0n
Mar 25 2017 02:54
"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."
Vamp
@the-vampiire
Mar 25 2017 02:54
substr takes integer values, such as lengths of strings. try passing target.length instead
Rick
@r7uaz0n
Mar 25 2017 02:54

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

return item; // Change this line
}

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

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

Vamp
@the-vampiire
Mar 25 2017 02:54
@ronnieg1988 Ill be back in about an hour. shout me if you still cant get it by then ill help when im back
Rick
@r7uaz0n
Mar 25 2017 02:54
A bit confused at this.
Ronald Johnson
@ronnieg1988
Mar 25 2017 02:55
@the-vampiire k thank you
CamperBot
@camperbot
Mar 25 2017 02:55
ronnieg1988 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Rick
@r7uaz0n
Mar 25 2017 02:57
any hints?
Manish Giri
@Manish-Giri
Mar 25 2017 02:58
@b00kwheat okay, your function gets two arguments - arr and item, yes?
Joseph
@revisualize
Mar 25 2017 03:02
Hi.
Riadh
@KWFE
Mar 25 2017 03:02
hey my friend i have a problem in this puzzle

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line



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

// Change this value to test
caseInSwitch(1);
who knows how to solve it at least help me not with the solution but at least to understand what i have to do
Joseph
@revisualize
Mar 25 2017 03:04
How do you write a switch?
Rick
@r7uaz0n
Mar 25 2017 03:05
@Manish-Giri Yes.
c0d0er
@c0d0er
Mar 25 2017 03:05
@alpox thanks
CamperBot
@camperbot
Mar 25 2017 03:05
c0d0er sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 880 | @alpox |http://www.freecodecamp.com/alpox
Riadh
@KWFE
Mar 25 2017 03:05
 switch(answer);
    case :
but i can't undestand what i have to put in the statement after the case
Saboor Malik
@MathematicsCoding
Mar 25 2017 03:06
break
Riadh
@KWFE
Mar 25 2017 03:06
@revisualize :)
Vered Rekanati
@veredrec
Mar 25 2017 03:06
Saboor Malik
@MathematicsCoding
Mar 25 2017 03:06
You need that if you want to write another case
break;
Im gonna netflix & chill..
Cya
Riadh
@KWFE
Mar 25 2017 03:07
@MathematicsCoding i did a break but it doesnt accept it
Joseph
@revisualize
Mar 25 2017 03:07
@KWFE why did you put answer as a variable in your switch? What is the value of answer?
Vamp
@the-vampiire
Mar 25 2017 03:08
@ronnieg1988 for now think about this. Subst() takes start and end arguments. If you put a start but no end it will automatically go to the end of the string. You know you want to match the end of the string. So where would you put this target.length? Start? End? Both? Neither?
Riadh
@KWFE
Mar 25 2017 03:09
@revisualize i guess its a string and the val defined in the function is a number
Jordan
@jl-code1721
Mar 25 2017 03:11
I really need help with 'Profile Lookup' because I took about a few months break from coding and now am trying to get back into it but i need some help to get back into the flow of it.
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:11
var start1= start.substr(target.length)
right? because you want it to go to the end of targets length
Jordan
@jl-code1721
Mar 25 2017 03:11
So I would really appreciate some help if anyone would be nice enough to
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:12
function confirmEnding(str, target) {
  var start= str;
  var start1= start.substring(target.length, target.length);
  if (start1 === target){
    return true;
  } else if (start1 !== target){
    return false;
  }
}

confirmEnding("Bastian", "n");
Vamp
@the-vampiire
Mar 25 2017 03:13
@ronnieg1988 very close
Riadh
@KWFE
Mar 25 2017 03:13

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
    case 1 :
      console.log("alpha");
      break;
  }
if anyone knows where is the problem !
Manish Giri
@Manish-Giri
Mar 25 2017 03:13
@KWFE you're logging stuff..
Vamp
@the-vampiire
Mar 25 2017 03:14
You need to rethink how substr works. Also take out the other else if you can just write return False because if your condition fails it will leave that block and go to return False
Manish Giri
@Manish-Giri
Mar 25 2017 03:14
assign to answer instead.
@KWFE
Madeleine Westerstrom
@madwester
Mar 25 2017 03:14
Hey you all! I'm new here and have a problem with the word blanks

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

// Your code above this line
return result;
}

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

Riadh
@KWFE
Mar 25 2017 03:14
@Manish-Giri i did it but it didnt work
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:14
@the-vampiire k
Madeleine Westerstrom
@madwester
Mar 25 2017 03:14
don't even now and to paste in the console :(
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:16
function confirmEnding(str, target) {
  var start= str;
  var start1= start.substr(target.length);

    return start1;

}

confirmEnding("Bastian", "n");
Vamp
@the-vampiire
Mar 25 2017 03:16
@ronnieg1988 the way you have it written now you are essentially saying start = end right? That's not going to do much
Manish Giri
@Manish-Giri
Mar 25 2017 03:16
@KWFE show code.
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:17
that returns astian of bastian
Riadh
@KWFE
Mar 25 2017 03:17
@madwester ALTGr+7 in the keyboard two time
```
@Manish-Giri
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:17
so it sees target as 1 and takes first letter from str
Riadh
@KWFE
Mar 25 2017 03:17

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


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

// Change this value to test
caseInSwitch(1);
Vamp
@the-vampiire
Mar 25 2017 03:18
yep
So you're getting much closer
Now what other length do you have to play with? Str.length right?
Manish Giri
@Manish-Giri
Mar 25 2017 03:19

@KWFE

assign to answer instead.

Ronald Johnson
@ronnieg1988
Mar 25 2017 03:20
so i need it to get the last letters of the str
Vamp
@the-vampiire
Mar 25 2017 03:20
Yep but in particular you need to get the last x letters of the string. Where x is the length of the target
How you gonna pull that off?
Riadh
@KWFE
Mar 25 2017 03:20
@Manish-Giri assign what !!
Manish Giri
@Manish-Giri
Mar 25 2017 03:21
@KWFE the right string, as per the instructions, for instance in case 1, you would assign alpha to answer.
read the instructions.
Sourabh Rangdal
@sourabhrangdal
Mar 25 2017 03:22
@Manish-Giri Hi Manish
Manish Giri
@Manish-Giri
Mar 25 2017 03:22
@sourabhrangdal hello
Kaeleb Rocha
@Kralleb
Mar 25 2017 03:22
I'm having trouble getting the console to output this code. am i doing something wrong? ""var myStr = "FirstLine \n \SecondLine\ \r ThirdLine";""
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:22
substring() can return the last letters of the str @the-vampiire
Riadh
@KWFE
Mar 25 2017 03:23
@Manish-Giri
 switch(answer){
    case 1 :
      answer ="alpha";
do you mean like this !
Manish Giri
@Manish-Giri
Mar 25 2017 03:23
yes
@KWFE
switch(answer)
Riadh
@KWFE
Mar 25 2017 03:23
i did it but it didnt work
Manish Giri
@Manish-Giri
Mar 25 2017 03:23
but this is wrong
you need to switch on val
Sourabh Rangdal
@sourabhrangdal
Mar 25 2017 03:23
@Kralleb no space at all
Vamp
@the-vampiire
Mar 25 2017 03:23
@ronnieg1988 think of it in terms of numbers it will be easier for you to see. You have 'Bastian' and 'n'. Lengths of str = 7, target = 1. You want to match how many letters of the str? Target = 1. So you need to start at which letter of the string (using substr)? 7-1 = 6. From character 6 to the end of the string.
Kaeleb Rocha
@Kralleb
Mar 25 2017 03:24
Oh. okay then thanks
It worked i appreciate that.
Sourabh Rangdal
@sourabhrangdal
Mar 25 2017 03:24
@Kralleb :thumbsup:
Riadh
@KWFE
Mar 25 2017 03:24
@Manish-Giri thanks man i think i did it
CamperBot
@camperbot
Mar 25 2017 03:24
kwfe sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4911 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 25 2017 03:24
@KWFE :+1:
Sourabh Rangdal
@sourabhrangdal
Mar 25 2017 03:26
@Manish-Giri Manish, i'm working on fcc js algorithm challenge and have a quick question, the algorithm challenge are based on all previous challenges, right
Manish Giri
@Manish-Giri
Mar 25 2017 03:26
@sourabhrangdal some of them yeah
Vamp
@the-vampiire
Mar 25 2017 03:26
@sourabhrangdal yes
Sourabh Rangdal
@sourabhrangdal
Mar 25 2017 03:27
@Manish-Giri ok :thumbsup: my concern is how to connect || with while loop or if / esle but i'm trying, sometime it works sometime it doesn't, any suggestions
@the-vampiire :thumbsup:
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:27
@the-vampiire so need to specify in substr() where to start
Vamp
@the-vampiire
Mar 25 2017 03:28
Yea
Manish Giri
@Manish-Giri
Mar 25 2017 03:28
@sourabhrangdal um, depends on your code, but it should work
if(a > 10 || b < 5) {
...
}
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:28
so should be substr(6, target.length)?
Sourabh Rangdal
@sourabhrangdal
Mar 25 2017 03:31
@Manish-Giri ok, how to understand and practice when to use when . right now i am re-reading previous challenges again and again and practice it on paper so that way i understand how it works
Vamp
@the-vampiire
Mar 25 2017 03:32
No
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:32
oh wait
Manish Giri
@Manish-Giri
Mar 25 2017 03:32
@sourabhrangdal generally I use for instead of while.
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:33
substr(target.length-6, target.length)
Vamp
@the-vampiire
Mar 25 2017 03:33
When you write a specific number in you have created a static code. This will only work for a specific case. You want dynamic code that can change depending on the arguments to your function. Use variables which are dynamic not specific values which are static
No
Plug in values there for one case you will see why that's wrong. Substr(1-6,1) --> subst(-5,1) this is invalid
Sourabh Rangdal
@sourabhrangdal
Mar 25 2017 03:34
@Manish-Giri :thumbsup:
Riadh
@KWFE
Mar 25 2017 03:34
@Manish-Giri

function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
    case 1 :
      answer = "apple";
      break;
    case 2 == "b":
      answer = "bird";
      break;
    case 3:
      answer ="cat";
      break;
  default:
      answer = "stuff";
  }


  // Only change code above this line  

}

// Change this value to test
switchOfStuff(1);
man what do you think about this one
Manish Giri
@Manish-Giri
Mar 25 2017 03:34
@KWFE your return statement is missing..
Riadh
@KWFE
Mar 25 2017 03:35
i deleted it
Manish Giri
@Manish-Giri
Mar 25 2017 03:35
case 2 == "b":
this syntax is wrong
Riadh
@KWFE
Mar 25 2017 03:37
yes i know just wanted to show you the many different things i v done
but i think i find the solution
thanks again @Manish-Giri
CamperBot
@camperbot
Mar 25 2017 03:37
kwfe sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: kwfe already gave manish-giri points
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:38
@the-vampiire so i need to make the target give str a certain start amount like is target = 4 str needs to start at 4th letter from end
Vamp
@the-vampiire
Mar 25 2017 03:38
Ya
But how can you accomplish this using the knowledge of str.length and target.length?
The example I gave you with the numbers. It wasn't the numbers that were important it was the approach to getting those numbers that you need to focus on. Using the two variables I just stated
Ronald Johnson
@ronnieg1988
Mar 25 2017 03:50
function confirmEnding(str, target) {
  var start= str;
  var start1= start.substring(str.length-target.length);
  if (start1==target) {
    return true;
  }else{
    return false;
  }


}

confirmEnding("sesame", "n");
@the-vampiire got it thank you
CamperBot
@camperbot
Mar 25 2017 03:50
ronnieg1988 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: ronnieg1988 already gave the-vampiire points
Vamp
@the-vampiire
Mar 25 2017 03:59
Hell ya man good job
Venpot
@VenPot
Mar 25 2017 04:01
Hey gang!
did anyone get their head around "closures" in javascript. I am having a tough time understanding the concept
any help?
Moisés Man
@moigithub
Mar 25 2017 04:03
why u keep posting ur code ? spamming ? @tuanhung9293 @tuanhung9293 @tuanhung9293 @tuanhung9293 @tuanhung9293
tuanhung9293
@tuanhung9293
Mar 25 2017 04:03
sorry
heroiczero
@heroiczero
Mar 25 2017 04:04
@tuanhung9293 try if the str===reverseStr
@tuanhung9293 use the reverse() method you did in an earlier exercise
tuanhung9293
@tuanhung9293
Mar 25 2017 04:04
I'm trying to comment by black backround
Joseph
@revisualize
Mar 25 2017 04:04
@tuanhung9293 Why not just ask how to do that instead of spamming?
heroiczero
@heroiczero
Mar 25 2017 04:04
@tuanhung9293 use ''' :point_down:
CamperBot
@camperbot
Mar 25 2017 04:04
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Mar 25 2017 04:04

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

var code = undefined;

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

Venpot
@VenPot
Mar 25 2017 04:05
did anyone get their head around "closures" in javascript. I am having a tough time understanding the concept. help would be appreciated. thank you!
tuanhung9293
@tuanhung9293
Mar 25 2017 04:07
function palindrome(str) {
  var str1 = str.replace(/[^0-9a-z]/gi,'').toLowerCase();
  for (var i=0; i<str1.length/2; i++)  {
    if(str1[i] !== str1[str1.length-i-1])  {return false}
  }
  return true;
}
palindrome("eye");
oh, thanks for the help
Venpot
@VenPot
Mar 25 2017 04:07
@tuanhung9293 chat with camperbot to try all these formatting gimmicks. once you learn it then post it in the main window.
tuanhung9293
@tuanhung9293
Mar 25 2017 04:08
I see :)
I think use reverse function is more Powerful
Venpot
@VenPot
Mar 25 2017 04:09
@tuanhung9293 thats the knowledge from my own mistakes :)
Joseph
@revisualize
Mar 25 2017 04:09
@tuanhung9293 You can also edit and DELETE post within 10 minutes.
Venpot
@VenPot
Mar 25 2017 04:10
one more time : did anyone get their head around "closures" in javascript. I am having a tough time understanding the concept. help would be appreciated. thank you!
tuanhung9293
@tuanhung9293
Mar 25 2017 04:11
@revisualize thanks you
CamperBot
@camperbot
Mar 25 2017 04:11
tuanhung9293 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3582 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 25 2017 04:12
@VenPot What kind of information are you looking for?
tuanhung9293
@tuanhung9293
Mar 25 2017 04:12
@heroiczero thank u
CamperBot
@camperbot
Mar 25 2017 04:12
tuanhung9293 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1035 | @heroiczero |http://www.freecodecamp.com/heroiczero
c0d0er
@c0d0er
Mar 25 2017 04:13
does anybody know how to remove the single top grid line and single right grid line from my pen? my grid line code is in 89-117; http://codepen.io/c0d0er/pen/LWmQpN?editors=0010
Venpot
@VenPot
Mar 25 2017 04:13
@revisualize thank you ! here is the link https://jsfiddle.net/v7gjv/?utm_source=website&utm_medium=embed&utm_campaign=v7gjv not able to figure out why its not working
CamperBot
@camperbot
Mar 25 2017 04:13
venpot sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3583 | @revisualize |http://www.freecodecamp.com/revisualize
Venpot
@VenPot
Mar 25 2017 04:14
@revisualize everytime the help tip defaults to "you must be over 16"
@VenPot Did you PM me?
@VenPot I don't read PMs.
Venpot
@VenPot
Mar 25 2017 04:17
@revisualize yeah i did
Joseph
@revisualize
Mar 25 2017 04:17
I don't read them.
I instantly hide them.
Venpot
@VenPot
Mar 25 2017 04:17
okay , np. I already read a lot on closures. I am stuck on that piece of code
in the js fiddle, any chance you can take a look?
Joseph
@revisualize
Mar 25 2017 04:18
@VenPot I honestly have no idea what you're trying to do with the code nor do I really see where the closure is.
Venpot
@VenPot
Mar 25 2017 04:19
:) that code is a straight use case from the mozilla javascript docs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
the article shows this code and says that to avoid the problem we need closures. but i dont see the problem
Joseph
@revisualize
Mar 25 2017 04:20
I guess I don't know what closures are then.
@VenPot Wait.
@VenPot That code is under "Creating closures in loops: A common mistake"
@VenPot You're trying to use mistake code to understand Closures.
Venpot
@VenPot
Mar 25 2017 04:21
exactly, i dont see what the mistake is in the code? unless i understand the mistake i can't move forward and understand why closures need to be applied
Joseph
@revisualize
Mar 25 2017 04:21
@VenPot How about you don't use code that doesn't work to try to understand closures.
@VenPot If someone tells you that something smells like shit .. Do you say let me smell it?
No ...
You take their word for it.
Don't use code that is a mistake to try to understand Closures.
@VenPot Watch the three videos that I linked.
Venpot
@VenPot
Mar 25 2017 04:24
@revisualize if i have not known closures, I would have written the code just like it was mentioned . which means somewhere i am 100% not clear in my JS concept
Joseph
@revisualize
Mar 25 2017 04:24
Watch the videos.
Venpot
@VenPot
Mar 25 2017 04:24
@revisualize just tell me why it fails, I promise i shall watch those videos
Joseph
@revisualize
Mar 25 2017 04:24
@VenPot Like I said. I was confused when I was looking at your example as well.
I have no freaking idea.
Venpot
@VenPot
Mar 25 2017 04:26
@revisualize ahh! thank you for spending the time. I will continue to chase it down and if i figure it out i shall let you know. Thanks again for the videos! appreciate it!
CamperBot
@camperbot
Mar 25 2017 04:26
venpot sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: venpot already gave revisualize points
Rebeca
@rgarn3r
Mar 25 2017 04:36
codecamp.png
someone help me in this challenge plz
heroiczero
@heroiczero
Mar 25 2017 04:38
@rgarn3r just gotta use celsius parameter to convert the temperature to fahrenheit
Mraru
@Mraru
Mar 25 2017 04:39
function palindrome(str) {
  // Good luck!
  if (reverseString(str.replace(/[^a-zA-Z0-9]/g,'').toLowerCase()) == del){
      return true;
      }
  else
    return false;
}

function reverseString(str) {
  var arr = str.split('');
  arr = arr.reverse();
  str = arr.join('');
  return str;
}

palindrome("1 eye for of 1 eye.");
I try to judge if the string is a palindrome but when I debug I found two strings can't pass successfully. They are "A man, a plan, a canal. Panama" and "My age is 0, 0 si ega ym." So I wonder how can I correct my code...
Rebeca
@rgarn3r
Mar 25 2017 04:40
@heroiczero Celsius parameter 9/5 + 32?
@heroiczero celsius = farenheit?
fahrenheit*
Venpot
@VenPot
Mar 25 2017 04:42
@revisualize figured it out man!! Its pretty simple. once the loop ends (item.help will always be "you must be over 16") thats why it never changes on focus
heroiczero
@heroiczero
Mar 25 2017 04:43
@rgarn3r no fahrenheit=celsius*9/5+32
Venpot
@VenPot
Mar 25 2017 04:43
here is the full explanation mentioned later in the article "The reason for this is that the functions assigned to onfocus are closures; they consist of the function definition and the captured environment from the setupHelp function's scope. Three closures have been created by the loop, but each one shares the same single lexical environment, which has a variable with changing values (item.help). The value of item.help is determined when the onfocus callbacks are executed. Because the loop has already run its course by that time, the item variable object (shared by all three closures) has been left pointing to the last entry in the helpText list."
Joseph
@revisualize
Mar 25 2017 04:43
@VenPot i actually took a little time to look at it.
@VenPot I'm taking part in an event this weekend.
Venpot
@VenPot
Mar 25 2017 04:46
@revisualize thats cool! Happy learnings over the weekend!
Javier Reinoso
@JavoFrola
Mar 25 2017 04:48
Hi guys! I am having problems with the Card Counting excercise :(
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
return "Bet";
break;
case 7:
case 8:
case 9:
count+=0;
break;
default:
count-=1;
return "Hold";
break;
}
return "Change Me";
How could I relate the strings bet r hold with the card number ??:S
Joseph
@revisualize
Mar 25 2017 04:49
@JavoFrola You're returning too early.
@JavoFrola 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.
Rebeca
@rgarn3r
Mar 25 2017 04:50
@heroiczero convertToF(-30);
var fahrenheit;
fahrenheit = celsius *9/5 + 32;
celsius = -22;
Am I in the right way?
I'm trying different ways to run
Javier Reinoso
@JavoFrola
Mar 25 2017 04:56
@revisualize something like that (just the first part)switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1 "Bet";
break;
I think I understand what to do bit not where to put the strings xd
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
break;
case 7:
case 8:
case 9:
count =0;
break;
default:
count-= 1;
}
return "Change Me";
need help with this

var myVar = 87;

// Only change code below
myVar ++

my solution
Trevor
@Tdance
Mar 25 2017 05:01
what does out of stack space mean?
Javier Reinoso
@JavoFrola
Mar 25 2017 05:03
@dineshpabbi10 I think it is without space myVar++
???
Trevor
@Tdance
Mar 25 2017 05:04
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. this is the instruction but it doesn't tell me what its supposed to look like at all.
Conor Murphy
@cmurphy580
Mar 25 2017 05:04

I have this function,

function almostIncreasingSequence(sequence) {
    var count = 0;
    var x = sequence.length-1;

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

        if (sequence[i] >= sequence[i+1]){
            count++;
        } else if (sequence[i] >= sequence[i+2]){
            count++;
        } else if(sequence[i] === sequence[i+1]){
            count++; 
        } else if(sequence[i] === sequence[i+2]){
            count++; 
        } 
    }
    return count; 
}

for this sequence,

 sequence: [1, 2, 3, 4, 3, 6]

why is the count = 2, and how can i get it equal to one?

Joseph
@revisualize
Mar 25 2017 05:09
@JavoFrola You need to have two logic blocks. One for changing the value of the count variable based upon the value of the card.
Sergey Lukin
@not-a-cylon
Mar 25 2017 05:09
@cmurphy580 it looks like it's doing what it's supposed to, bc 3===3 and 4>=3, so count++ happens twice.
Joseph
@revisualize
Mar 25 2017 05:09
This message was deleted
@JavoFrola THEN!
You need to return based on the value of count.

@Tdance Gist by revisualize / FreeCodeCamp - Stand in Line.js

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

You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

You just need to add a number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).
But, there is another part of this challenge. You need to know What the methods that do those two things return.

Rebeca
@rgarn3r
Mar 25 2017 05:23
convertToF(30);
var fahrenheit;
fahrenheit = celsius 9/5 + 32;
fahrenheit = -32
5/9;
fahrenheint = celsius;
?????
Ayush Bahuguna
@relentless-coder
Mar 25 2017 05:23
hey, how do I load a specific css file based on a specific browser??
Joseph
@revisualize
Mar 25 2017 05:25
@rgarn3r Okay.
Javier Reinoso
@JavoFrola
Mar 25 2017 05:25
function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
break;
case 7:
case 8:
case 9:
count=0;
break;
default:
count-= 1;
}
if(count>0){
return count + " Bet";
}else{
return count + " Hold";
}
// Only change code above this line
}
Joseph
@revisualize
Mar 25 2017 05:25
@rgarn3r Let's walk through this.
@rgarn3r Are you here?
Javier Reinoso
@JavoFrola
Mar 25 2017 05:25
Just one condition f the excercise does not meet
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Joseph
@revisualize
Mar 25 2017 05:26

@JavoFrola
case 7:
case 8:
case 9:
count=0;

This is overwriting count.

Rebeca
@rgarn3r
Mar 25 2017 05:26
@revisualize yes
Joseph
@revisualize
Mar 25 2017 05:26
@rgarn3r Okay let's walk through something.

@rgarn3r If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

@rgarn3r Let me know when you've read through that. I have a few questions.
Javier Reinoso
@JavoFrola
Mar 25 2017 05:28
I erased the cunt =0 and works @revisualize but why
affected if count =0 supposes to neither add and rest??
Joseph
@revisualize
Mar 25 2017 05:29
@JavoFrola But, that isn't what it does.
= is assignment
You're not doing += 0
You're doing a straight overwrite of count = 0
Javier Reinoso
@JavoFrola
Mar 25 2017 05:30
e
thank you so much @revisualize
CamperBot
@camperbot
Mar 25 2017 05:30
javofrola sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3584 | @revisualize |http://www.freecodecamp.com/revisualize
Javier Reinoso
@JavoFrola
Mar 25 2017 05:30
thanks @revisualize
CamperBot
@camperbot
Mar 25 2017 05:30
javofrola sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: javofrola already gave revisualize points
Javier Reinoso
@JavoFrola
Mar 25 2017 05:30
ahhahahahahah you derserves a whole package of brownies lol :D
Joseph
@revisualize
Mar 25 2017 05:30
@rgarn3r ?
Rebeca
@rgarn3r
Mar 25 2017 05:31
ok, keep goin'
Joseph
@revisualize
Mar 25 2017 05:33
@rgarn3r So. With the code of function addThree (num) { } when I do a addThree(7); what is the value of num?
Rebeca
@rgarn3r
Mar 25 2017 05:33
I did it
function addThree (7) {
var result;
result = 7 + 3;
return result;
}
result = 10
Joseph
@revisualize
Mar 25 2017 05:36
@rgarn3r That isn't what I asked.
But, okay.
Rebeca
@rgarn3r
Mar 25 2017 05:36
num = 7
Joseph
@revisualize
Mar 25 2017 05:37
@rgarn3r So. With the code of function addThree (num) { } when I do a addThree(-22); what is the value of num?
Rebeca
@rgarn3r
Mar 25 2017 05:37
right?
Joseph
@revisualize
Mar 25 2017 05:37
@rgarn3r Correct.
Rebeca
@rgarn3r
Mar 25 2017 05:37
-22
Joseph
@revisualize
Mar 25 2017 05:37
@rgarn3r Okay. That's step 1
@rgarn3r
There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
Rebeca
@rgarn3r
Mar 25 2017 05:38

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = (celsius * (9/5)) + 32;
if ( typeof fahrenheit !== 'undefined' ) {
} else {
return 'fahrenheit not defined';
}

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

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

I did it
Joseph
@revisualize
Mar 25 2017 05:39
@rgarn3r Umm
Rebeca
@rgarn3r
Mar 25 2017 05:39
I was putting the code on the wrong places
Joseph
@revisualize
Mar 25 2017 05:39

@rgarn3r all of this:

if ( typeof fahrenheit !== 'undefined' ) {
} else {
return 'fahrenheit not defined';
}

can be deleted

Rebeca
@rgarn3r
Mar 25 2017 05:39
ah ok! thanks
I will need more tips later
Joseph
@revisualize
Mar 25 2017 05:40
@rgarn3r You will really need to understand parameters as you progress.
Rebeca
@rgarn3r
Mar 25 2017 05:44
@revisualize yes, my native language isn't english, so I can understand a lot of this. But the assigments have another meaning...it's confuse me sometimes
JAPerera
@JAPerera
Mar 25 2017 05:44

Hey guys! So I'm a little stuck with the "Word Blanks" JS challenge. Here's the code that's provided:

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

// Your code above this line
return result;
}

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

Joseph
@revisualize
Mar 25 2017 05:45

@JAPerera Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Jim
@JLOSS1
Mar 25 2017 05:45
hey @revisualize , there was a while ago, you mentioned people should download some free book or something off of a site. I had forgotten to write it down. All I remember was it was a coding book. With my, albeit, vague explanation, would you happen to remember what it was? I want to see what else I can grab from there.
Jim
@JLOSS1
Mar 25 2017 05:46
Awesome! Thanks a bunch @revisualize
CamperBot
@camperbot
Mar 25 2017 05:46
jloss1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3585 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 25 2017 05:47
@JLOSS1 They do a free book every day.
Jim
@JLOSS1
Mar 25 2017 05:47
Wait, really?
that's crazy
Joseph
@revisualize
Mar 25 2017 05:47
Jim
@JLOSS1
Mar 25 2017 05:48
@revisualize wow, this is great. holy crap
Joseph
@revisualize
Mar 25 2017 05:48
@JLOSS1 Depends on what book you're really looking for.
kailasa8055
@kailasa8055
Mar 25 2017 05:48
Screenshot (6).png
what's wrong with my code :(?
Joseph
@revisualize
Mar 25 2017 05:48
This message was deleted
@kailasa8055 Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Jim
@JLOSS1
Mar 25 2017 05:49
@revisualize I guess I have to look out for things related to JS>JSON>API's. I'm having trouble grasping how they all go together.
Vamp
@the-vampiire
Mar 25 2017 05:50
Caesar’s Cypher. Maybe I’m insane…maybe it’s magic…
function rot13(str) {
// setup to build a decoder

// alphabet + repeating 13 characters for spillover in loop
// produces 'undefined' artifacts but those will be dealt with
    var alphabet = 'abcdefghijklmnopqrstuvwxyzabcdefghijklm';

    // lazily type it out in lowercase...make JS do the work...
    var caps_alpha = alphabet.toUpperCase();

// alphabet in caps and split into an array for looping purposes
    var alpha_arr = caps_alpha.split('');

// array to capture the shifted alphabet, shifted by 13 places in the alphabet
    var decoder = [];

// loop to populate the decoder array, takes alphabet character and pushes the letter 13 letters after it
    for(var i = 0; i < alpha_arr.length; i++){
        decoder.push(alpha_arr[i+13]);
    }

// clean up the decoder array by filtering for undefined elements
    decoder = decoder.filter(undefined_filter);

// function to filter undefined elements from decoder array, artifacts of a lazy loop
    function undefined_filter(val){
        if(val === undefined){
            return false;
        }
        return true;
    }

// decoding occurs below this line

// clean alphabet without spillover characters - used for matching
    var clean_alpha = 'abcdefghijklmnopqrstuvwxyz';
    var clean_alpha_caps_arr = clean_alpha.toUpperCase().split('');

// define two variables, alpha_index will store the index of the matching letter from the string
// the other will hold the decoded string
    var alpha_index;
    var decoded_str = '';
// loop through the string and determine the index of the matching letter from the string to the alphabet
// build the decoded_str by running the same index through the decoder array

    for(i = 0; i < str.length; i++){
        alpha_index = clean_alpha_caps_arr.indexOf(str[i]);

        // correct for spaces / characters not found in alphabet
        switch(str[i]){
            case ' ':
                console.log('called');
                decoded_str += ' ';
                break;
            case '.':
                decoded_str += '.';
                break;
            case '!':
                decoded_str += '!';
                break;
            case '?':
                decoded_str += '?';
                break;
            default:
                decoded_str += decoder[alpha_index];

        }

    }

    return decoded_str;

// Shia_Lebouf_magic.gif
    // the vampiire
}
kailasa8055
@kailasa8055
Mar 25 2017 05:50
@revisualize thanks a lot got it :)
CamperBot
@camperbot
Mar 25 2017 05:50
kailasa8055 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3586 | @revisualize |http://www.freecodecamp.com/revisualize
JAPerera
@JAPerera
Mar 25 2017 05:52
@revisualize Thanks for the quick response - I'm still a bit confused. My first instinct was to modify the value of the variable result - but it's telling me not to modify the code on that line. Not sure what I'm missing.
CamperBot
@camperbot
Mar 25 2017 05:52
japerera sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3587 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 25 2017 05:53
@JAPerera You're supposed to modify the variable result
JAPerera
@JAPerera
Mar 25 2017 05:53
Alright let me try that now.
Bryan Reese
@breese8009
Mar 25 2017 05:54
anyone of see this before? https://github.com/arsood/handlejs
Joseph
@revisualize
Mar 25 2017 05:55
Nope
Jim
@JLOSS1
Mar 25 2017 05:56
interesting
JAPerera
@JAPerera
Mar 25 2017 05:59
@revisualize Thanks for the clarification! Apparently I wasn't meeting the other requirements of the challenge (I was supposed to make a complete sentence).
CamperBot
@camperbot
Mar 25 2017 05:59
japerera sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: japerera already gave revisualize points
Bryan Reese
@breese8009
Mar 25 2017 05:59
@revisualize works amazingly
JAPerera
@JAPerera
Mar 25 2017 05:59
^^and quickly.
Bryan Reese
@breese8009
Mar 25 2017 06:00
@JAPerera u have seen it?
redoz94
@redoz94
Mar 25 2017 06:02
hi guys i am trying to make this using javscript

# #

# #

# #

# #

# #

# #

# #

# #

8x8 grid
so far ive got this

// Your code here.
var a=" ";
var b="#";

while(){
}

but i cant figure out what to put into the loop
Joseph
@revisualize
Mar 25 2017 06:04
@breese8009 Look. You asked me if I had ever seen something before. I haven't seen it before so.. I responded accordingly. I don't really care how well it works. I'm not focused on learning any other frameworks or libraries beyond Vanilla JS.
Sandip Shrestha
@saninmersion
Mar 25 2017 06:06
@redoz94 you basically need two loops. one for rows another for cols
Joseph
@revisualize
Mar 25 2017 06:09
@saninmersion Not really.
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:09
@revisualize :laughing: ...... Morning
Sandip Shrestha
@saninmersion
Mar 25 2017 06:09
@revisualize it would be easier to understand with two of them. won't it?
Ollie
@Hubss
Mar 25 2017 06:11

var studlyCapVar;
var properCamelCase;
var titleCaseOver;

studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;

Joseph
@revisualize
Mar 25 2017 06:11
.repeat()
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:11
@Hubss any question?
Ollie
@Hubss
Mar 25 2017 06:12
Hey guys I cant seem to find the error in that both declaration and assignment should be in camelcase :/
for properCamelCase
Bryan Reese
@breese8009
Mar 25 2017 06:13
@revisualize dude, relax, i was just askin if u seen it...not askin u to go learn anything
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:13
:laughing:
redoz94
@redoz94
Mar 25 2017 06:13
@saninmersion sorry but how am i gunna go about doing that though?
@saninmersion mind if i dm you?
Jor
@joreyesl
Mar 25 2017 06:14
@Hubss try refreshing the page, sometimes challenges get bugged
Manish Giri
@Manish-Giri
Mar 25 2017 06:15
@Lumexralph good morning bro :wave:
Joseph
@revisualize
Mar 25 2017 06:18
@breese8009 What makes you think I'm not relaxed?
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:18
@redoz94 are you permitted to do this?
var a=" ";
var b="#";
var l = 8;
while(l > 0){
  a = b.repeat(8);
  console.log(a);
  l--;
}
Bryan Reese
@breese8009
Mar 25 2017 06:18
@revisualize i donno ur post came off like u didnt like what i asked
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:18
@Manish-Giri Hey Buddy! good morning, tell me you had like 4hrs :sleeping:
Manish Giri
@Manish-Giri
Mar 25 2017 06:19
@Lumexralph lol, none yet..
Bryan Reese
@breese8009
Mar 25 2017 06:19
but its the internet, so maybe i just took it wrong
:)
Manish Giri
@Manish-Giri
Mar 25 2017 06:19
2:18 am, too early to sleep.
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:20
@Manish-Giri :smile: okay
Joseph
@revisualize
Mar 25 2017 06:20
var a = "";
var b = "#";
var num = 8;
for (let i = 0; i < num; i++) {
    a += b.repeat(num) + "\n";
}
Jor
@joreyesl
Mar 25 2017 06:21
@redoz94 do you need spaces/tabs between the #s?
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:21
@Manish-Giri what's up?
redoz94
@redoz94
Mar 25 2017 06:22
@Lumexralph can you possibly explain what you've done there?
@joreyesl spaces\
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:22
@redoz94 you understand how a while loop works, right?
Manish Giri
@Manish-Giri
Mar 25 2017 06:23
@Lumexralph finishing up on the hackreactor challenges..
redoz94
@redoz94
Mar 25 2017 06:23
@Lumexralph yup
ohhhhh @Lumexralph
@Lumexralph i think im kind of getting i
whats the .repeat for though?
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:24
@redoz94 you know how string.repeat() works too?
@Manish-Giri cool....... maybe when am done with my Python stuff i'll look it up...is it cool?
Manish Giri
@Manish-Giri
Mar 25 2017 06:25
@Lumexralph it's very very basic(so far)
most are one liner challenges.
Jor
@joreyesl
Mar 25 2017 06:25
@Manish-Giri one liner for you ;)
Manish Giri
@Manish-Giri
Mar 25 2017 06:26
lol
Joseph
@revisualize
Mar 25 2017 06:26
@redoz94
var a = "";
var b = "#";
var num = 8;
for (let i = 0; i < num; i++) {
    a += b.repeat(num) + "\n";
}
console.log(a);
Manish Giri
@Manish-Giri
Mar 25 2017 06:26
haha @joreyesl
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:26
@joreyesl I agree with that
@Manish-Giri what's the link?
Manish Giri
@Manish-Giri
Mar 25 2017 06:26
@Lumexralph prep.hackreactor.com
Jor
@joreyesl
Mar 25 2017 06:27
@Manish-Giri do you have to pay? I though I saw a price somewhere
Manish Giri
@Manish-Giri
Mar 25 2017 06:27
@joreyesl yeah there's a paid version for $495 something..I'm doing the basic prep, which is free..
not quite sure what's the difference.
redoz94
@redoz94
Mar 25 2017 06:28
@revisualize that doesnt work. Its giving me 8 "#" on each line
@Lumexralph that doesnt work bro
Manish Giri
@Manish-Giri
Mar 25 2017 06:29
@redoz94 try using two for loops, as @saninmersion suggested.
Jor
@joreyesl
Mar 25 2017 06:30
@redoz94 aren't you supposed to do an 8x8 grid? is it the spaces that are missing?
redoz94
@redoz94
Mar 25 2017 06:30
@Manish-Giri how?
@joreyesl yup
Jor
@joreyesl
Mar 25 2017 06:30
@redoz94
let num = 8;
while(num--) {
  console.log("# ".repeat(8).trim());
}
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:31
@redoz94 i gave you the foundation, you can adjust it to what you want
Manish Giri
@Manish-Giri
Mar 25 2017 06:33
433.png
@redoz94 did you want something like this?
redoz94
@redoz94
Mar 25 2017 06:34
@Manish-Giri nope. something like this;

# # # # # #

# # # # # # #

and so on
with spaces in between
Manish Giri
@Manish-Giri
Mar 25 2017 06:34
what's the pattern?
how many # per line?
redoz94
@redoz94
Mar 25 2017 06:35
8
Manish Giri
@Manish-Giri
Mar 25 2017 06:35
there are 6 on your first line
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:35
@redoz94 you misled us with your question, you said 8 x 8 grid
redoz94
@redoz94
Mar 25 2017 06:35
yeah my bad
sorry
Manish Giri
@Manish-Giri
Mar 25 2017 06:35
lol
redoz94
@redoz94
Mar 25 2017 06:35
8x8 is what i want
the pattern up there isnt exactly correct
let me make it for you again
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:35
@Manish-Giri :smile:
Jor
@joreyesl
Mar 25 2017 06:36
@redoz94 so it starts at 1 # then 2 # ... until 8 #?
redoz94
@redoz94
Mar 25 2017 06:36

# # # # # #

aaaarghhhhh
one sec
Manish Giri
@Manish-Giri
Mar 25 2017 06:36
Untitled.png
@redoz94 like that?
redoz94
@redoz94
Mar 25 2017 06:37
no there should be 4 "#" and 4 spaces on each line
Manish Giri
@Manish-Giri
Mar 25 2017 06:37
ugh
I give up
Jor
@joreyesl
Mar 25 2017 06:37
8, 6, 4? which is it??!!!
Manish Giri
@Manish-Giri
Mar 25 2017 06:37
just now you said 8 # on each line
make up your mind
Jor
@joreyesl
Mar 25 2017 06:37
OOOOOHHHHH I think I got it
Manish Giri
@Manish-Giri
Mar 25 2017 06:38
anyway..i'm off to other things..
redoz94
@redoz94
Mar 25 2017 06:38
@joreyesl Write a program that creates a string that represents an 8×8 grid, using newline characters to separate lines. At each position of the grid there is either a space or a “#” character. The characters should form a chess board.
Jor
@joreyesl
Mar 25 2017 06:38
ok so start with a 1v1 grind, then 2x2, then 3x3... until 8x3 grid?
redoz94
@redoz94
Mar 25 2017 06:38
@joreyesl @Manish-Giri sorry guys. i just cant type it out properly
let me send you a screenshot
Sam
@dvlprsam
Mar 25 2017 06:40
Hey all! Having trouble with the following. Some help would be greatly appreciated

Instructions
Assign the value 7 to variable a.

Assign the contents of a to variable b.

//Keep going. One line of code at a time :)
// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;

redoz94
@redoz94
Mar 25 2017 06:41
blob
blob
@joreyesl @Manish-Giri
like this
@dvlprsam
a==b
i suppose
var a=7;
var b=7;
a==b
@dvlprsam
anushkaduck
@anushkaduck
Mar 25 2017 06:46

Can anyone please tell me what is wrong with my code?
function mutation(arr) {
var x=arr[0].toLowerCase();
var y=arr[1].toLowerCase();

return x.indexOf(y) !== -1;
}

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

Joseph
@revisualize
Mar 25 2017 06:47
@redoz94 So.. You didn't give me all of the requirements. Now you're telling me it doesn't work? hmmm.
Manish Giri
@Manish-Giri
Mar 25 2017 06:47
wew.png
@redoz94 does this look right?
Joseph
@revisualize
Mar 25 2017 06:47
It does work based upon the requirements that I had
redoz94
@redoz94
Mar 25 2017 06:48
@revisualize didnt mean to put you down or anything bro, im just bad with windows and couldnt figure out how to print the screen
Joseph
@revisualize
Mar 25 2017 06:48
Welp.
I'm out.
:v:
Jor
@joreyesl
Mar 25 2017 06:48
@redoz94 ok so you are gonna need a var for size. You will need to use a loop to make each row. Now since they stagger, you will need to have an if statement to decide if start with a space or a #. Then its just concatenate each row to a str and add "\n" at the end.
redoz94
@redoz94
Mar 25 2017 06:49
@Manish-Giri that DOES work. Thanks. Could you send the code for that
CamperBot
@camperbot
Mar 25 2017 06:49
redoz94 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4913 | @manish-giri |http://www.freecodecamp.com/manish-giri
redoz94
@redoz94
Mar 25 2017 06:49
@revisualize @joreyesl thanks guys
CamperBot
@camperbot
Mar 25 2017 06:49
redoz94 sends brownie points to @revisualize and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 663 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 3588 | @revisualize |http://www.freecodecamp.com/revisualize
Manish Giri
@Manish-Giri
Mar 25 2017 06:51
@redoz94
function showSequence(isStartingSpace) {
  if(isStartingSpace) {
    console.log((" #").repeat(4));
  }
  else {
    console.log(("# ").repeat(4));
  }
}

for(var i = 0; i < 8; i++) {
  if(i % 2 === 0) {
    showSequence(false);
  }
  else {
    showSequence(true);
  }
}
there are two parts to it -
  1. a function to print each of the two patterns in the string - space before, space second
  2. alternate each pattern
part 1 is pretty straightforward
for part 2, if you think about it, between 0 and 7, each number is either odd or even, and it alternates
so you can use that to your benefit, to alternate each pattern.
redoz94
@redoz94
Mar 25 2017 06:55
@Manish-Giri ok the book im using hasnt gotten to functions yet so its gotta be without using functions
@Manish-Giri thats a good solution though hmmm
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:56
@redoz94 just use loop in the function he provided
Jor
@joreyesl
Mar 25 2017 06:57
@redoz94 you can just move the code from the function to the appropriate place in the loop/ifelse
Kaue Rodrigo Pacheco
@kauepacheco
Mar 25 2017 06:58

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

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

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

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

var Bike = function() {

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

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

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


};

var myCar = new Car();

var myBike = new Bike();
can someone help me?
Make Object Properties Private
Ogundele Olumide
@Lumexralph
Mar 25 2017 06:59
@kauepacheco setGear method should assign it's parameter to gear using = not +=
anushkaduck
@anushkaduck
Mar 25 2017 06:59
I need help in mutation code please
redoz94
@redoz94
Mar 25 2017 07:00
is there a way i could brush up on programmingjargon?
Jor
@joreyesl
Mar 25 2017 07:00
@kauepacheco in their example they have accelerate and decelerate, which would make sense using += and -=. But usually for getters/setters, you only do return and assignment. So for the setGear you will not want to use +=. Set implies you are assigning, not incrementing a value.
Kaue Rodrigo Pacheco
@kauepacheco
Mar 25 2017 07:00
@Lumexralph thank you, it worked. but can you explain why?
CamperBot
@camperbot
Mar 25 2017 07:00
kauepacheco sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1376 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Mar 25 2017 07:00
@redoz94 i'll suggest you take it step by step, they build on each other
Kaue Rodrigo Pacheco
@kauepacheco
Mar 25 2017 07:01
@joreyesl oh got it... if I use += I am going to be adding, so if they pass 5 then 4 it would be 9...
@joreyesl thank you
CamperBot
@camperbot
Mar 25 2017 07:01
kauepacheco sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 664 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Mar 25 2017 07:02
@kauepacheco yea, you want to set the value to 5, not increment it by 5. You got it :thumbsup:
Manish Giri
@Manish-Giri
Mar 25 2017 07:05
@joreyesl 2 more and you'll be :smiling_imp:
Jor
@joreyesl
Mar 25 2017 07:05
:scream:
Ogundele Olumide
@Lumexralph
Mar 25 2017 07:05
@Manish-Giri :laughing:
@Manish-Giri should we do it?
Jor
@joreyesl
Mar 25 2017 07:07
@Lumexralph :satisfied:
MatthDuc
@Vagrantin
Mar 25 2017 07:07

Hi guys, I'm doing the escape sequence challenge but i don't understand why my solution doesn't work here is what expected:
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Here is my solution,
var myStr = "firstLine\n\SecondeLine\\n\rthirdLine";

but it's refused any idea why ?

Manish Giri
@Manish-Giri
Mar 25 2017 07:07
@Lumexralph let's :smiling_imp:
Ogundele Olumide
@Lumexralph
Mar 25 2017 07:08
@joreyesl here we go.. thanks
CamperBot
@camperbot
Mar 25 2017 07:08
lumexralph sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 665 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Mar 25 2017 07:08
:scream:
Manish Giri
@Manish-Giri
Mar 25 2017 07:08