These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Nov 2016
Stephen James
@sjames1958gm
Nov 21 2016 00:00
@JackEdwardLyons forEach doesn't return anything.
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:00
yeah, in the html
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:00
it should @sjames1958gm
but my sort function isn't doing anything, im wondering if it's beacause of my output +=
how can i display this to the html in a better fashion?
Stephen James
@sjames1958gm
Nov 21 2016 00:01
@JackEdwardLyons forEach returns undefined
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:01
really, its working for me
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 00:01
Greetings room
it returns a post on the screen
but then when i add another, it doesnt get sorted
Stephen James
@sjames1958gm
Nov 21 2016 00:02
@JackEdwardLyons You are sorting on the output of forEach, and forEach doesn't return anything.
lalith77
@lalith77
Nov 21 2016 00:03
@JohnnyBizzel object. propertyName doesnt seem to be working
Stephen James
@sjames1958gm
Nov 21 2016 00:03
@lalith77 Providing an example would help us help you.
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:03
onmy screen the posts show up on the screen
Stephen James
@sjames1958gm
Nov 21 2016 00:04
@JackEdwardLyons Yes, your forEach is running but the sort is attached to the return from forEach
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:04
ok
lalith77
@lalith77
Nov 21 2016 00:04
i have var skeys= Object.keys(source); where source is the object. now source.skeys doesnt work.
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:04
should i not put the output += in the forEach
?
Stephen James
@sjames1958gm
Nov 21 2016 00:04
@JackEdwardLyons Hit submit and look at the console.
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:05
yeah, theres nothing?
Stephen James
@sjames1958gm
Nov 21 2016 00:05
devtools console?
Steven Bigham
@volv
Nov 21 2016 00:05
@JackEdwardLyons Sort the array first. then run forEach on that. Not the other way around
Stephen James
@sjames1958gm
Nov 21 2016 00:05
What are you trying to sort?
@volv :+1:
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:05
ah ok, ill try that
Moisés Man
@moigithub
Nov 21 2016 00:05
@lalith77 Object.keys return an array
if u want first key.. u need to do sKeys[0]
var myProp = sKeys[0];
source[myProp]
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:05
@sjames1958gm
@volv thanks
CamperBot
@camperbot
Nov 21 2016 00:05
jackedwardlyons sends brownie points to @volv :sparkles: :thumbsup: :sparkles:
:warning: jackedwardlyons already gave volv points
Stephen James
@sjames1958gm
Nov 21 2016 00:06
@JackEdwardLyons You can do sort.forEach because sort returns the array.
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:06
im not really sure how to set this up... i thinkmy sort function is wrong
// Return each post
function returnPost() {
  let blogs = [];
  const postText = document.getElementById("blogText");
  blogs.push(new Blog(postText.value, new Date()));
  // console.log(blogs);
  return blogs.sort((a, b) => {
    // code to sort goes here...
    return new Date(b.date) - new Date(a.date);
}).forEach((blog) => {
    output.innerHTML += `
      <p>${blog.body} </br>
         ${blog.date.toLocaleDateString()}
      </p>
    `
  })
}
its not really sorting, is it?
Stephen James
@sjames1958gm
Nov 21 2016 00:08
@JackEdwardLyons Try b.date.getTime() - a.date.getTime()
Moisés Man
@moigithub
Nov 21 2016 00:08
@JackEdwardLyons new Date() return an object.. no math operation directly on object..
u need to work with numbers
like miliseconds.. hours minutes....
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:09
ah ok.
so Date.toString() ?
Moisés Man
@moigithub
Nov 21 2016 00:09
no math with string... but numbers.. like @sjames1958gm posting
Stephen James
@sjames1958gm
Nov 21 2016 00:09
@JackEdwardLyons getTime() returns the number stored in the date object
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:09
ok.. ill try
function returnPost() {
  let blogs = [];
  const postText = document.getElementById("blogText");
  blogs.push(new Blog(postText.value, new Date()));
  // console.log(blogs);
  return blogs.sort((a, b) => {
    // code to sort goes here...
    new Date(b.date).getTime() - new Date(a.date).getTime();
  }).forEach((blog) => {
    output.innerHTML += `
      <p>${blog.body} </br>
         ${blog.date.toLocaleDateString()}
      </p>
    `
  });
}
still not working :(
Stephen James
@sjames1958gm
Nov 21 2016 00:11
@JackEdwardLyons Without the new Date a stuff
Moisés Man
@moigithub
Nov 21 2016 00:11
since u reinitializing blogs array each time.. it only contains LAST (one ) object added @JackEdwardLyons
all rest are strings output.innerHTML +=
Stephen James
@sjames1958gm
Nov 21 2016 00:11
@JackEdwardLyons return b.date.getTime() - a.date.getTime()
You have to return something as well from the sort function
lalith77
@lalith77
Nov 21 2016 00:11
@moigithub thanks that works. but why does the dot notation like source.myProp; not work?
CamperBot
@camperbot
Nov 21 2016 00:11
lalith77 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2209 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Nov 21 2016 00:12
@lalith77 cuz whatever follow the dot is a string literal... source.myProp is the same as source["myProp"] <-- and source do not contain any prop named "myProp" literally
myProp is a variable.. so NO dot notation
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:13
im confused... still not working :(
function returnPost() {
  let blogs = [];
  const postText = document.getElementById("blogText");
  blogs.push(new Blog(postText.value, new Date()));
  // console.log(blogs);
  return blogs.sort((a, b) => {
    // code to sort goes here...
    b.date.getTime() - a.date.getTime();
  }).forEach((blog) => {
    output.innerHTML += `
      <p>${blog.body} </br>
         ${blog.date.toLocaleDateString()}
      </p>
    `
  });
}
lalith77
@lalith77
Nov 21 2016 00:13
@moigithub ok. thank you
CamperBot
@camperbot
Nov 21 2016 00:13
lalith77 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: lalith77 already gave moigithub points
Moisés Man
@moigithub
Nov 21 2016 00:14
u should move let blogs = []; outside that function... cuz u reinitializing the array everytime u call returnPost function.. so it only contain 1 element
sorting [1] <-- return [1] the same
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:14
ok.. ill try that
Stephen James
@sjames1958gm
Nov 21 2016 00:14
@JackEdwardLyons return the value from inside the sort function
@moigithub Turns out you can subtract date objects.
var x = new Date()


undefined
var y = new Date()


undefined
x - y
-5934
x.getTime() - y.getTime()
-5934
Steven Bigham
@volv
Nov 21 2016 00:14
@JackEdwardLyons The sort worked the way it was before. return new Date(a.date) - new Date(b.date);
Moisés Man
@moigithub
Nov 21 2016 00:14
ahh :) @sjames1958gm
Stephen James
@sjames1958gm
Nov 21 2016 00:15
New learning for me :)
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:15
if I take the blogs [] array out of the function, then it posts too many posts
Steven Bigham
@volv
Nov 21 2016 00:15
@JackEdwardLyons Then take let blogs = []; outside of the function
@JackEdwardLyons and add output.innerHTML = ``; before the sort and output
Moisés Man
@moigithub
Nov 21 2016 00:15
declare a string variable..
and concatenate ur <p>
then outside the loop.. assign to output.innerHTML
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:16
but now it just over rides the blog post
ok
Moisés Man
@moigithub
Nov 21 2016 00:16
or like @volv posting...
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:16
ill try
sorry im a bit lost...
function returnPost() {
  let blogs = [];
  const postText = document.getElementById("blogText");
  blogs.push(new Blog(postText.value, new Date()));
  // console.log(blogs);
  output.innerHTML = '';
  blogs.sort((a, b) => {
    // code to sort goes here...
    new Date(a.date) - new Date(b.date);
  }).forEach((blog) => {
    output += `
      <p>${blog.body} </br>
         ${blog.date.toLocaleDateString()}
      </p>
    `
  });
  return output;
}
Moisés Man
@moigithub
Nov 21 2016 00:18
u actually no need to return anything.. cuz the caller do not do any with its returned value....
Steven Bigham
@volv
Nov 21 2016 00:18
You are still clearing the array with every call. let blogs = []; needs to be outside of the function
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:18
let blogs = [];
// Return each post
function returnPost() {

  const postText = document.getElementById("blogText");
  blogs.push(new Blog(postText.value, new Date()));
  // console.log(blogs);
  output.innerHTML = '';
  blogs.sort((a, b) => {
    // code to sort goes here...
    new Date(a.date) - new Date(b.date);
  }).forEach((blog) => {
    output.innerHTML += `
      <p>${blog.body} </br>
         ${blog.date.toLocaleDateString()}
      </p>
    `
  });
  return output;
}
this still just doesn't sort :(
Moisés Man
@moigithub
Nov 21 2016 00:19
ahh.. u overriding output value... u should use another variable for the string
Jay Kumar
@jaykch
Nov 21 2016 00:19
Either I am blind or you havent defined output anywhere
Steven Bigham
@volv
Nov 21 2016 00:19
I think that is sorting. But the sorted order is the same as you had initially
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:19
sorry, output is defined above this code @jaykch
ive tried both a-b and b-a
Steven Bigham
@volv
Nov 21 2016 00:19
oh and you need to return from that sort
Moisés Man
@moigithub
Nov 21 2016 00:20
function returnPost() {

  const postText = document.getElementById("blogText");
  blogs.push(new Blog(postText.value, new Date()));
  // console.log(blogs);

var html ='';  //////////////////////////////

  blogs.sort((a, b) => {
    // code to sort goes here...
     return    new Date(a.date) - new Date(b.date);
  }).forEach((blog) => {
   html+= `
      <p>${blog.body} </br>
         ${blog.date.toLocaleDateString()}
      </p>
    `
  });
   output.innerHTML = html;  ///////////
}
Steven Bigham
@volv
Nov 21 2016 00:20
return new Date(b.date) - new Date(a.date);
REAPERkato
@REAPERkato
Nov 21 2016 00:20

Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:21
THANK YOU :)
haha im sorry for being such a noob
thanks @volv @moigithub
CamperBot
@camperbot
Nov 21 2016 00:21
jackedwardlyons sends brownie points to @volv and @moigithub :sparkles: :thumbsup: :sparkles:
:warning: jackedwardlyons already gave volv points
:star2: 2210 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Nov 21 2016 00:22
...we all learning here :)
Jack Lyons
@JackEdwardLyons
Nov 21 2016 00:22
heres the final code
const output = document.getElementById('app');

// Create blog schema
class Blog {
  constructor (body, date) {
    this.body = body;
    this.date = date;
  }
  toSentence() {
    return `${this.body}, ${this.date}`;
  }

}
let blogs = [];
// Return each post
function returnPost() {

  const postText = document.getElementById("blogText");
  blogs.push(new Blog(postText.value, new Date()));
  // console.log(blogs);
  output.innerHTML = '';
var html ='';  //////////////////////////////
  blogs.sort((a, b) => {
    // code to sort goes here...
return    new Date(b.date) - new Date(a.date);
  }).forEach((blog) => {
   html+= `
      <p>${blog.body} </br>
         ${blog.date.toLocaleDateString()}
      </p>
    `
  });
   output.innerHTML = html;
}

// Sort posts by Date
REAPERkato
@REAPERkato
Nov 21 2016 00:22

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

im still stuck on this...

peith
@peith
Nov 21 2016 00:23
@Sharifdesigns22 surrounded your code with "```" those at the top and the bottom
lalith77
@lalith77
Nov 21 2016 00:27
@REAPERkato are you supposed to concatenate the arguments? whats the question?
Moisés Man
@moigithub
Nov 21 2016 00:27
@REAPERkato function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { this is ur function header... it accept 4 values..
here is how u passing those values wordBlanks("dog", "big", "ran", "quickly");
soo myNoun variable/argument will contain "dog"
myAdjective will have "big" etc..
what u need to do inside ur function is concatenate all those words.. and form/return a phrase, with a proper spacing/separator
Data Detective
@WCoaster77
Nov 21 2016 00:30
Hey Gang,
Stuck on Seek and Destroy
REAPERkato
@REAPERkato
Nov 21 2016 00:30
im not supposed to change the function though
lol.
Data Detective
@WCoaster77
Nov 21 2016 00:30
'''
CamperBot
@camperbot
Nov 21 2016 00:30
:bulb: to format code use backticks! ``` more info
REAPERkato
@REAPERkato
Nov 21 2016 00:30
idk why this part is confusing me so much
irritating
Data Detective
@WCoaster77
Nov 21 2016 00:31

'''
function destroyer(arr) // Remove all the values
{

var arg = arr.slice.apply(arguments);
var get = arg.slice(1);

for (i = 0; i < get.length; i++) {
    arr = arg[0].filter(remove, get[i]);
}


function remove(value)
{
    console.log(get[i]);
    return value !== get;
}

return arr;

}

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

CamperBot
@camperbot
Nov 21 2016 00:31
:bulb: to format code use backticks! ``` more info
Data Detective
@WCoaster77
Nov 21 2016 00:33

'''
jsfunction destroyer(arr) // Remove all the values
{

var arg = arr.slice.apply(arguments);
var get = arg.slice(1);

for (i = 0; i < get.length; i++) {
    arr = arg[0].filter(remove, get[i]);
}


function remove(value)
{
    console.log(get[i]);
    return value !== get;
}

return arr;

}

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

CamperBot
@camperbot
Nov 21 2016 00:33
:bulb: to format code use backticks! ``` more info
Data Detective
@WCoaster77
Nov 21 2016 00:34
sorry for double post trying to figure out how to post code here to. :smile:
function destroyer(arr) // Remove all the values
{

    var arg = arr.slice.apply(arguments);
    var get = arg.slice(1);

    for (i = 0; i < get.length; i++) {
        arr = arg[0].filter(remove, get[i]);
    }


    function remove(value)
    {
        console.log(get[i]);
        return value !== get;
    }

    return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
there we go
zack
@acting2332
Nov 21 2016 00:36
hi friends i may need some help i know i am close but i am not sure what i mee
messed up!

// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.

if (wasThatTrue) {

return "yes, that was true";
}
return "no, that was false";

// Only change code above this line.

}

// Change this value to test
trueOrFalse(true);

Data Detective
@WCoaster77
Nov 21 2016 00:37
@acting2332 what challenge are you working on?
zack
@acting2332
Nov 21 2016 00:38
use condsitional logic with if statements
@WCoaster77
Moisés Man
@moigithub
Nov 21 2016 00:38
@REAPERkato u NOT changing the function.. u should WORK with the arguments provided.. n assign result variable a new value (its a string concatenation exercise )
ie:
function salute(name){   // name is argument/variable
  var result = '';
  result = 'hello '+ name;  /// <-- string concatenation
  return result;
}
//calling
salute('Joe');    /// return hello Joe
Joseph
@revisualize
Nov 21 2016 00:41
@moigithub Incorrect.
Moisés Man
@moigithub
Nov 21 2016 00:41
o.O @revisualize
Joseph
@revisualize
Nov 21 2016 00:42
Not really trying to be an ass but!
ie:
function salute(name){   // name is parameter/variable
  var result = '';
  result = 'hello '+ name;  /// <-- string concatenation
  return result;
}
//calling
salute('Joe');    /// Argument 'Joe' .... return hello Joe
Moisés Man
@moigithub
Nov 21 2016 00:43
pfff ;)
Joseph
@revisualize
Nov 21 2016 00:43
I know I know.
Data Detective
@WCoaster77
Nov 21 2016 00:43
@acting2332 it is just your cpaitals missing in the string. YOur code is good just make sure your sting is exactly as requested.
Joseph
@revisualize
Nov 21 2016 00:44
@moigithub I know it is like being a grammar nazi.. Not cool.
Data Detective
@WCoaster77
Nov 21 2016 00:44
@acting2332
You have: "yes, that was true"
It should be: "Yes, that was true"
Joseph
@revisualize
Nov 21 2016 00:45

Parameters are variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another 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.

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

@moigithub I have a bunch of standardized responses on my super secret gist: revisualize/General Responses to Gitter Secret
Jackson Mihalik
@Gravitah
Nov 21 2016 00:48
i'm confused on what it is im supposed to be doing here https://www.freecodecamp.com/challenges/word-blanks
can anyone clarify
Joseph
@revisualize
Nov 21 2016 00:48
@Gravitah Read that big post that I JUST posted.
@Gravitah First you need to understand a little about parameters.
Jackson Mihalik
@Gravitah
Nov 21 2016 00:49
no like im confused as to the objective.
zack
@acting2332
Nov 21 2016 00:49
@WCoaster77 oh gosh thanks ha i keep doing that
CamperBot
@camperbot
Nov 21 2016 00:49
acting2332 sends brownie points to @wcoaster77 :sparkles: :thumbsup: :sparkles:
:cookie: 258 | @wcoaster77 |http://www.freecodecamp.com/wcoaster77
Joseph
@revisualize
Nov 21 2016 00:49
@Gravitah You just construct a string.
Jackson Mihalik
@Gravitah
Nov 21 2016 00:49
use wordBlanks twice?
Joseph
@revisualize
Nov 21 2016 00:49
@Gravitah No.
Re-read that post above.
You will need to use string operators to build a new string, result,
using the parameters: myNoun, myAdjective, myVerb, and myAdverb.
Jackson Mihalik
@Gravitah
Nov 21 2016 00:50
right
and result is already sort of defined
but what do i define it as
Joseph
@revisualize
Nov 21 2016 00:51
@Gravitah String concatenation with variables.
@Gravitah You use the variables to make a MadLib.
Data Detective
@WCoaster77
Nov 21 2016 00:53
Anyone have any insight into Seek and Destroy?

function destroyer(arr) {
  // Remove all the values
    var arg = arr.slice.apply(arguments);

    for (i = 0; i <= arguments.length; i++)
    {
        arr = arg[0].filter(remove);
    }

    function remove(value)
    {
        return value !== arg[1];
    }

    return arr;
}


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

or

```js


function destroyer(arr) // Remove all the values
{

    var arg = arr.slice.apply(arguments);
    var get = arg.slice(1);

    for (i = 0; i < get.length; i++) {
        arr = arg[0].filter(remove, get[i]);
    }


    function remove(value)
    {
        return value !== get;
    }

    return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Johnny
@JohnnyBizzel
Nov 21 2016 00:57
@WCoaster77 The way I did it was to filter the items from the first array, like you are doing
Data Detective
@WCoaster77
Nov 21 2016 00:58
@JohnnyBizzel you mean break the second part of the array into a separate variable or something else?
Joseph
@revisualize
Nov 21 2016 00:59
@Gravitah Still there? How's it coming along? Confused? Still need help?
Data Detective
@WCoaster77
Nov 21 2016 01:00
OK, I can't understand why the filter function won't loop through the items. It will only filter the first element out of the array.
Jay Kumar
@jaykch
Nov 21 2016 01:00
@WCoaster77 copy the arguments into another array and use that one instead? thats how I solved it, for some reason filter wasnt working directly with arguments
Johnny
@JohnnyBizzel
Nov 21 2016 01:01
@WCoaster77 var args = Array.from(arguments); and then you can deal with all 3 args.
Data Detective
@WCoaster77
Nov 21 2016 01:01
@jaykch so you did not use filter in your solution? That I can figure out I am sure but I have been trying to get filter to work
Jay Kumar
@jaykch
Nov 21 2016 01:02
@WCoaster77 NO I just copied the arguments into another array and used that array to filter and it worked
Data Detective
@WCoaster77
Nov 21 2016 01:03
@JohnnyBizzel is that different than blockquote var arg = arr.slice.apply(arguments);
Johnny
@JohnnyBizzel
Nov 21 2016 01:04
@WCoaster77 I had to google how to use filter. In the callback function I used
function removeValue(val) {
     if (val != this)
        return val;
}

@JohnnyBizzel is that different than var arg = arr.slice.apply(arguments);

This code is fine

Moisés Man
@moigithub
Nov 21 2016 01:05
@WCoaster77 add some console.log.. n paste ur code here https://repl.it/languages/javascript to test (or any other online editor )
Data Detective
@WCoaster77
Nov 21 2016 01:06
@JohnnyBizzel your this refers to the end of the original array?
Moisés Man
@moigithub
Nov 21 2016 01:07
ie: console.log(arg);
console.log(arg[0]);
console.log(arg1);
console.log(this);
to make sure what data u comparing to...
Johnny
@JohnnyBizzel
Nov 21 2016 01:07
@WCoaster77 I believe that this is the item being tested against val passed in by the filter function.
But I have been know to be wrong! It works anyway!! :D
Data Detective
@WCoaster77
Nov 21 2016 01:07
thanks @jaykch @JohnnyBizzel
CamperBot
@camperbot
Nov 21 2016 01:07
wcoaster77 sends brownie points to @jaykch and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @jaykch |http://www.freecodecamp.com/jaykch
:cookie: 838 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Data Detective
@WCoaster77
Nov 21 2016 01:07
OK I will work on it some more.
Johnny
@JohnnyBizzel
Nov 21 2016 01:08
@WCoaster77 Good luck and have fun!
Data Detective
@WCoaster77
Nov 21 2016 01:08
Thanks @moigithub I do that a lot. I removed the log calls here for ease of reading for others
CamperBot
@camperbot
Nov 21 2016 01:08
wcoaster77 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2211 | @moigithub |http://www.freecodecamp.com/moigithub
Data Detective
@WCoaster77
Nov 21 2016 01:09
@JohnnyBizzel it has been. Was tearing it up doing two or three of these algorithms a day and have been on this one for over days.
peith
@peith
Nov 21 2016 01:11
```

I'm not sure how to solve this one. The challenge says the following:

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.


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));
Steven Bigham
@volv
Nov 21 2016 01:14

@peith push the supplied item onto the array. Then read about array.shift()
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift

Specifically about its return value

peith
@peith
Nov 21 2016 01:18
@volv Thanks for putting me on the right track, Steve.
CamperBot
@camperbot
Nov 21 2016 01:18
peith sends brownie points to @volv :sparkles: :thumbsup: :sparkles:
:cookie: 341 | @volv |http://www.freecodecamp.com/volv
Steven Bigham
@volv
Nov 21 2016 01:20
@peith np. Glad it helped :)
Andre Alayon
@Meseta22
Nov 21 2016 01:27
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++){
if(contacts[i].firstName === firstName){
  if( contacts[i].hasOwnProperty(prop) ){
     return contacts[i].firstName;
  }
  else {
    return "No such property";
  }
}
  else {
    return "No such contact";
  }
}
}
Could someone tell me where I'm going wrong with the Property Lookup task?
Steven Bigham
@volv
Nov 21 2016 01:30
you are returning the name instead of the property asked for
Andre Alayon
@Meseta22
Nov 21 2016 01:30
I swapped it to contacts[i][prop] and I'm still having the same issues
Steven Bigham
@volv
Nov 21 2016 01:31
You also will exit early if its not the first item in the array
Jay Kumar
@jaykch
Nov 21 2016 01:31
first run the if statement with prop then the one with firstname
Steven Bigham
@volv
Nov 21 2016 01:33
Easier to see reformatted
function lookUpProfile(firstName, prop) {
  // Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) { // If item 0 matches name
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i].firstName;
      } else {
        return "No such property";
      }
    } else { // item 0 didn't match. Function ends
      return "No such contact";
    }
  }
}
Andre Alayon
@Meseta22
Nov 21 2016 01:36
Thank you @volv as soon as you mentioned that it was exiting early I saw the issue.
CamperBot
@camperbot
Nov 21 2016 01:36
meseta22 sends brownie points to @volv :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @volv |http://www.freecodecamp.com/volv
Steven Bigham
@volv
Nov 21 2016 01:37
@Meseta22 np. :)
Andre Alayon
@Meseta22
Nov 21 2016 01:38
I removed the no contacts else statement and placed the return right after the for loop.
Gotta keep track of those curly brackets.
Steven Bigham
@volv
Nov 21 2016 01:39
wait..
That was the old one :)
function lookUpProfile(firstName, prop) {
  for (i = 0; i < contacts.length; i++) { // Check each entry
    if (contacts[i].firstName === firstName) { 
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop]
      } else {
        return "No such property";
      }
    } 
  }

  // None of them matched
  return "No such contact";
}
comaeternal
@comaeternal
Nov 21 2016 01:42
Can someone check this out. Am I going the right direction with this?

function destroyer(arr) {
  for ( var i=0; i < arr[0].length; i++) {
    if (arr[i] === arr[1])  
      return x;
  }

  return x;
}


    var filtered = arr.filter(isBigEnough);

//pick arr[1]. and See if it matches any of the numbers in array[0]. If there is a match then we want to delete that number in the array. 
//pick[2]. and see if it matches any of the numbers in array[0]. If there is a match then we want to delete that number in the array. Bring the numbers that were left over from that. 


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Stephen James
@sjames1958gm
Nov 21 2016 01:44
@comaeternal You need to review the arguments object link - arr is the array to seek in, but you need to use arguments to get to the additional values
comaeternal
@comaeternal
Nov 21 2016 01:47
@sjames1958gm To get the additional values? Can you explain what you mean?
Walid Ashri
@walidashri
Nov 21 2016 01:47

two rabbits running in same direction giving each speed v1 and v2 with the distance between g
return array of time needed for 2nd to catch 1st , the array is [hh,mm,ss]
this fails with the flooring the result expected [18,20,0] got [18,19,0]

function race(v1, v2, g) {
    // your code
    let t=g/(v2-v1);
    return t>0? [t>=1?Math.floor(t):0,t<1?Math.floor(t*60/1):Math.floor(((t%1)*60)),t<1?Math.floor(((t*60)%1)*60):Math.floor(((t*60)%1)*60)]:null

}

Any help Please

Steven Bigham
@volv
Nov 21 2016 01:50
@comaeternal At the moment you only have the arr value. Which corresponds to the passed array ([1, 2, 3, 1, 2, 3]). You need to look into the arguments object to end up with an array of all of the passed arguments. [[1, 2, 3, 1, 2, 3], 2, 3]. And work from there
Karuru Wamahiu
@freecodegaku
Nov 21 2016 01:52
@comaeternal there is an "[arguments]"(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments) object that you need to use inorder to access the extra parameters.
initzer0
@initzer0
Nov 21 2016 01:54
Hello, I am having trouble with the Record Collection challenge. This is what I have so far, if anyone could correct me or lead me the right direction.
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if(prop !== "tracks" && value !== ""){
    collection[id][prop]=value;
  } else if (prop === "tracks" &&  prop.hasOwnProperty("tracks")){
    collection[id].tracks = [];
  } else if (prop === "tracks" && value !== ""){
    collection[id].push(value);
  } else if (value !== ""){
    delete collection[id].prop;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Stephen James
@sjames1958gm
Nov 21 2016 02:01

@initzer0 Check the property on collection[id] and you need to put value in the []

  } else if (prop === "tracks" &&  prop.hasOwnProperty("tracks")){
    collection[id].tracks = [];

Also you are using . on prop in the delete

Fahd Almdbl
@fahadmdbl
Nov 21 2016 02:20
hi guys ,
how can I use JSON , and what is it use for ?!!
Alan Barr
@alanmbarr
Nov 21 2016 02:24
{"key":"value"} is the simplest kind of JSON. It is used to hold and send data in a simple structure to be parsed
many API services use either JSON or XML to send data about weather, user stats, and many more things
Ken Haduch
@khaduch
Nov 21 2016 02:25
@fahadmdbl - yes, basically a string encoding of a javascript object - JavaScript Object Notation is where the letters come from. There are rules about what you can use in the string, you can google that.
initzer0
@initzer0
Nov 21 2016 02:29

@sjames1958gm Thank you! I also found that I was using !== instead of === in the last else if statement. This is my updated code. Also, it asks to return an empty array, so just want to make sure if i really need to put a value in the []
```function updateRecords(id, prop, value) {
if(prop !== "tracks" && value !== ""){
collection[id][prop]=value;
} else if (prop === "tracks" && collection[id][prop].hasOwnProperty("tracks")){
collection[id].tracks = [];
} else if (prop === "tracks" && value !== ""){
collection[id].tracks.push(value);
} else if (value === ""){
delete collection[id][prop];
}

return collection;
}
```

CamperBot
@camperbot
Nov 21 2016 02:29
initzer0 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4451 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Vikrant Singh
@VikrantSingh13
Nov 21 2016 02:35
why are we learning react instead of angular2? why not both?
Fahd Almdbl
@fahadmdbl
Nov 21 2016 02:43
@alanmbarr @khaduch thank you so mach :smile:
CamperBot
@camperbot
Nov 21 2016 02:43
fahadmdbl sends brownie points to @alanmbarr and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 347 | @alanmbarr |http://www.freecodecamp.com/alanmbarr
:star2: 1954 | @khaduch |http://www.freecodecamp.com/khaduch
tommy
@tommygebru
Nov 21 2016 02:44
LOL many of us have been yearning to try angular but when the time finally comes to learn a Frontend Framework, React drops in and wows everyone
Alan Barr
@alanmbarr
Nov 21 2016 02:45
angular 2 is still in significant development. there would be a lot of churn to keep the tutorials up to date
tommy
@tommygebru
Nov 21 2016 02:49
I am having a lot of trouble with the algorithm Sorted Union
I looked for a solution to learn from
found one and tried to worked that angle, but then I lost the link
so now I need some advice LOL
Paulo Tokimatu
@paulotokimatu
Nov 21 2016 02:50
@tommygebru in what part are you having problems?
tommy
@tommygebru
Nov 21 2016 02:51
function uniteUnique(arr) {
    var argued = Array.prototype.slice.call(arguments);
    var united = argued[0];
    var newArr = [];
    for (var i = 1; i < argued.length; i++) {
        united = united.concat(argued[i]);
    }
    //united is now the enitre contents of sub-arrays 
    for (var n = 0; n < united.length; n++) {
        if (newArr.indexOf(united[i]) === -1) {
            newArr = newArr.push(united[i]);
        } //if
        else {
            continue;
        } //else
    } //for
} //end
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

Running the challenge I get

TypeError: newArr.indexOf is not a function

Paulo Tokimatu
@paulotokimatu
Nov 21 2016 02:54
I do not know if indexOf works with arrays
tommy
@tommygebru
Nov 21 2016 02:54
@paulotokimatu no its also for arrays
Will
@Will-is-Coding
Nov 21 2016 02:55
@tommygebru You're using i when it's out of scope
tommy
@tommygebru
Nov 21 2016 02:56
@tommygebru You're using i when it's out of scope
Will
@Will-is-Coding
Nov 21 2016 02:56
Once you exited/finished the previous for loop, your i variable ceased to exist
tommy
@tommygebru
Nov 21 2016 02:56
@Will-is-Coding :satisfied: thanks!
CamperBot
@camperbot
Nov 21 2016 02:56
tommygebru sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 479 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
tommy
@tommygebru
Nov 21 2016 02:56
@paulotokimatu thanks!
CamperBot
@camperbot
Nov 21 2016 02:56
tommygebru sends brownie points to @paulotokimatu :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @paulotokimatu |http://www.freecodecamp.com/paulotokimatu
Paulo Tokimatu
@paulotokimatu
Nov 21 2016 02:56
@tommygebru Ahh, sorry man :P
tommy
@tommygebru
Nov 21 2016 02:56
@alanmbarr thanks!
CamperBot
@camperbot
Nov 21 2016 02:56
tommygebru sends brownie points to @alanmbarr :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @alanmbarr |http://www.freecodecamp.com/alanmbarr
Will
@Will-is-Coding
Nov 21 2016 02:57
So you need to use n not i @tommygebru
tommy
@tommygebru
Nov 21 2016 02:58
yep
tommy
@tommygebru
Nov 21 2016 03:06
LOL its funny I actually forgot to use console.log() for this challenge because I sought out a solution :wink:
it should pass now i think
Moisés Man
@moigithub
Nov 21 2016 03:07
var z= [].concat.apply([], arguments);
return z.filter((e,i,a)=>a.indexOf(e)==a.lastIndexOf(e));
tommy
@tommygebru
Nov 21 2016 03:11
here is the solution :sparkles:
https://repl.it/E3Cm/6
@moigithub is the editor already accepting es6 ?
Moisés Man
@moigithub
Nov 21 2016 03:12
dunno :P
Walid Ashri
@walidashri
Nov 21 2016 03:12
@moigithub lol
tommy
@tommygebru
Nov 21 2016 03:12
:smile:
cant wait for new feature updates to FCC its gonna be sick
Sam
@Sambit153
Nov 21 2016 03:13

@Will-is-Coding @alanmbarr I am having some error in this code. Sending the code below: ```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 = 3;

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

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

var myCar = new Car();

var myBike = new Bike();```

'''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 = 3;

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

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

var myCar = new Car();

var myBike = new Bike();'''

CamperBot
@camperbot
Nov 21 2016 03:14
:bulb: to format code use backticks! ``` more info
zack
@acting2332
Nov 21 2016 03:17
heyy guys what am i missing here i am not to sure its says switchofstuff(4) should have value of "stuff"

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val){
case "a":
return"apple";
break;
case "b":
return"bird";
break;
case "c":
return"cat";
break;
case "d":
return"stuff";
break;
}

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

// Change this value to test
switchOfStuff(1);

Moisés Man
@moigithub
Nov 21 2016 03:17
@Sambit153 setGear should only SET the new value.. not increase it
Sergey Lukin
@not-a-cylon
Nov 21 2016 03:18
@acting2332 try adding a default clause?
Moisés Man
@moigithub
Nov 21 2016 03:18
@acting2332 probvably shouldnt be a,b,c,d but 1,2,3,4 ?? re-read the instructions (im not sure) :)
Sam
@Sambit153
Nov 21 2016 03:19
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 = 3;

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

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

var myCar = new Car();

var myBike = new Bike();
Moisés Man
@moigithub
Nov 21 2016 03:19
this.setGear = function(){
gear += 1;
};
shoulnt increase.. but set a new value...
ur function should accept 1 argument ie: newGear
Sam
@Sambit153
Nov 21 2016 03:19
@moigithub so what changes should be done in the code?
@moigithub sorry didn't get you
Moisés Man
@moigithub
Nov 21 2016 03:21
similar to this but without increasing.. only SET
  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };
no + (math)
grdseime
@grdseime
Nov 21 2016 03:22
@acting2332 try changing your value to test at the bottom to "a" (with the quotation marks as well) and see if that works
zack
@acting2332
Nov 21 2016 03:24
@moigithub not really sure how the default clase is supposed to look like at end!
@grdseime tried that no go :(
Moisés Man
@moigithub
Nov 21 2016 03:24
Instructions
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
switch (variable){
case "a": .... something
..... more lines
default:
answer = "stuff";
}
__mifflin__
@cdrainxv
Nov 21 2016 03:25

@acting2332: You should set answer to the values for the cases.

set answer for the following conditions

case "a":
 answer = "apple";
 break;
grdseime
@grdseime
Nov 21 2016 03:25
^^^^
if those returns are changed to answer then i think you should be good
Joseph
@revisualize
Nov 21 2016 03:27
Hello.
zack
@acting2332
Nov 21 2016 03:28
@grdseime @cdrainxv i just had to add default:
answer ="stuff";
thanks a bunch guys
Ken Haduch
@khaduch
Nov 21 2016 03:29
@revisualize :wave:
grdseime
@grdseime
Nov 21 2016 03:30
Anyone on the Counting Cards assignment?
Winter S. Ndolo
@xulenvirp
Nov 21 2016 03:31
its morning here, have a nice day for all who are at dawn and goodnight to those who will be asleepin a few hours
tommy
@tommygebru
Nov 21 2016 03:31
If looking for help just share your code/progress and a link to exercise :smile:
Paul
@paulvandreves
Nov 21 2016 03:32
Thanks @leftynaut @DarrenJansen for your help with Checkpoint: Record Collection
CamperBot
@camperbot
Nov 21 2016 03:32
paulvandreves sends brownie points to @leftynaut and @darrenjansen :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @darrenjansen |http://www.freecodecamp.com/darrenjansen
:cookie: 581 | @leftynaut |http://www.freecodecamp.com/leftynaut
kylin
@D-kylin
Nov 21 2016 03:32
somebody can help me for the "Stand in Line"?
grdseime
@grdseime
Nov 21 2016 03:33
@D-kylin sure. Have you started it yet?
kylin
@D-kylin
Nov 21 2016 03:33
yes
but i can`t do it
grdseime
@grdseime
Nov 21 2016 03:33
@D-kylin can you post what you have so far?
kylin
@D-kylin
Nov 21 2016 03:34
pardon?
Sam
@Sambit153
Nov 21 2016 03:34
@moigithub it was really helpful. Thanks.
CamperBot
@camperbot
Nov 21 2016 03:34
sambit153 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2212 | @moigithub |http://www.freecodecamp.com/moigithub
grdseime
@grdseime
Nov 21 2016 03:34
@D-kylin can you post your code into chat so I can see where to help you out
like this??
grdseime
@grdseime
Nov 21 2016 03:36
@D-kylin no but i can work with it
kylin
@D-kylin
Nov 21 2016 03:38
thanks
grdseime
@grdseime
Nov 21 2016 03:38
@D-kylin your first line is mixed up a bit. It should read: arr.push(item);
kylin
@D-kylin
Nov 21 2016 03:39
just like this?
and what is queue
grdseime
@grdseime
Nov 21 2016 03:39
@D-kylin yes that will correct the first line for you. That is not the whole answer yet though
kylin
@D-kylin
Nov 21 2016 03:39
i will
i will try to do it
grdseime
@grdseime
Nov 21 2016 03:40
queue is the order items are kept in
like a line
@D-kylin let me know if you need anymore help!
kylin
@D-kylin
Nov 21 2016 03:41
thankyou
thankyou
grdseime
@grdseime
Nov 21 2016 03:41
np
kylin
@D-kylin
Nov 21 2016 03:43
@grdseime may i be a friend with you
grdseime
@grdseime
Nov 21 2016 03:45
@D-kylin Of course! Do you mean like add me on a friends list? Cause i actually dont know anything about that on FCC
kylin
@D-kylin
Nov 21 2016 03:45
if you have facebook ID?
grdseime
@grdseime
Nov 21 2016 03:46
No I dont use facebook : /
Johnny Vineyard
@javineya
Nov 21 2016 03:46
Can anyone explain Stand in Line to me? The JavaScript section isn't going as smoothly as the HTML side did.
Dannia Guzman
@danniaguzman
Nov 21 2016 03:47
Hi everyone. Anyone with 5 minutes that can help me with "Record Collection". When I run my code it passes 4 of the 6 test. For the last two tests I cannot figure out what Im doing wrong.
kylin
@D-kylin
Nov 21 2016 03:47
@grdseime that a pity
grdseime
@grdseime
Nov 21 2016 03:47
@javineya yeah I can help you with that one. Do you have any code you have tried yet?
Johnny Vineyard
@javineya
Nov 21 2016 03:48

function nextInLine(arr, item) {
testArr.push(item);
testArr.shift(0);
// Your code here

return item; // Change this line
}

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

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

It passes 2 of the tests, but I'm honestly not sure how, heh.
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.
That's the instruction.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 03:48
@danniaguzman Have you ever used the JS debugger? I just discovered its use last week.. and it's amazing! It really helps to be able to step through your code and find out exactly where it makes the wrong turn!
kylin
@D-kylin
Nov 21 2016 03:48
@grdseime thankyou for all~_~
CamperBot
@camperbot
Nov 21 2016 03:48
:cookie: 194 | @grdseime |http://www.freecodecamp.com/grdseime
d-kylin sends brownie points to @grdseime :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Nov 21 2016 03:49
@javineya you need to work with the array arr, not testArr
Dannia Guzman
@danniaguzman
Nov 21 2016 03:49
@JeffGreenlee42 Never heard of it. I'll look it up
grdseime
@grdseime
Nov 21 2016 03:49
@javineya what manish just said
Johnny Vineyard
@javineya
Nov 21 2016 03:49
So I need to create an array?
grdseime
@grdseime
Nov 21 2016 03:49
@javineya you also need to change your return
Manish Giri
@Manish-Giri
Nov 21 2016 03:50
@javineya also, using .shift() on an array will remove and return the first element by default, so you don’t need to pass anything in to .shift() -
testArr.shift(0);
@javineya nope, look at your function call, you’re being passed two arguments - arr and item. This is the array you need to use.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 03:50
@danniaguzman do you use Atom? and if you do an ctrl-shift-I on Windows or maybe it's Command-Shift-I on Mac.. it will bring up the debugger!
grdseime
@grdseime
Nov 21 2016 03:51
@javineya manish is typing it out faster than I haha
Manish Giri
@Manish-Giri
Nov 21 2016 03:51
@grdseime lol, haha
@grdseime you can explain the part about return!
Joseph
@revisualize
Nov 21 2016 03:51
Hello.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 03:51
@danniaguzman Then you just paste in your code to the debugger console and hit enter!
Johnny Vineyard
@javineya
Nov 21 2016 03:51
@grdseime @Manish-Giri Thanks! Let me fiddle with this a bit and see if I can figure it out. I'll bother you again if I can't :P
CamperBot
@camperbot
Nov 21 2016 03:51
javineya sends brownie points to @grdseime and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 195 | @grdseime |http://www.freecodecamp.com/grdseime
:star2: 2361 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Nov 21 2016 03:52
@javineya good luck!
Joseph
@revisualize
Nov 21 2016 03:52
@JeffGreenlee42 Hello from Seattle. :D
grdseime
@grdseime
Nov 21 2016 03:52
@javineya sounds good
kylin
@D-kylin
Nov 21 2016 03:52
may be can do like this:
item = arr.shift();
Joseph
@revisualize
Nov 21 2016 03:53
@D-kylin Nope.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 03:53
@revisualize Howdy! Nice to know there are some local campers! I tried seeing if there were any meetups recently.. Nothing!!! :)
Joseph
@revisualize
Nov 21 2016 03:53
@JeffGreenlee42 I was trying to host meetups through the facebook events page for the Seattle FCC group.
But, with the holiday's. I'm going to hold out. I may do a few weekends in December.
Dannia Guzman
@danniaguzman
Nov 21 2016 03:53
@JeffGreenlee42 I am doing exercises on chrome. Is Atom an editor or browser?
Joseph
@revisualize
Nov 21 2016 03:54
@D-kylin You really shouldn't overwrite a parameter or really a variable if you don't have to. There's a reason it was passed to the function.
kylin
@D-kylin
Nov 21 2016 03:54
my answer is nope?
Joseph
@revisualize
Nov 21 2016 03:54
@D-kylin In this case there is no reason to overwrite the variable.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 03:55
@danniaguzman Yes! Atom is a FREE editor.. it's really nice to use once you have it set up! Sublime is nice too! I use both.. but I have been using Atom more often lately.
Joseph
@revisualize
Nov 21 2016 03:55
@danniaguzman I did all of my FCC lessons using Chrome.
@danniaguzman I would bounce back and forth between my work computer and personal computer.
kylin
@D-kylin
Nov 21 2016 03:55
the key is i should not change the variable??
Joseph
@revisualize
Nov 21 2016 03:56
@D-kylin You should not.
kylin
@D-kylin
Nov 21 2016 03:56
ok
Joseph
@revisualize
Nov 21 2016 03:56
@D-kylin In this case that is.. There are other cases where the variable should change.
@D-kylin Can I give you an example?
Dannia Guzman
@danniaguzman
Nov 21 2016 03:56
@JeffGreenlee42 Got it! Thanks so much. Going to check it out. I know that is some small thing I am overlooking. Let me see if I can figure it out
CamperBot
@camperbot
Nov 21 2016 03:56
danniaguzman sends brownie points to @jeffgreenlee42 :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @jeffgreenlee42 |http://www.freecodecamp.com/jeffgreenlee42
kylin
@D-kylin
Nov 21 2016 03:56
i try to do it for other method
Jenky W. Nolasco
@jenkynolasco11
Nov 21 2016 03:56
Hola mundo! o//
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 03:57
@danniaguzman I did find though that trying to use the debugger directly from chrome is a LOT more confusing then doing it from a local editor... The debugger is the same.. its just that from the browser .. weeding out your code from the rest of the browser page is more ... errr.. problematic!
Joseph
@revisualize
Nov 21 2016 03:57
function sweetFunction (name) {
      var result = name;
       return "Hello " + result;
}

VS

function sweetFunction (name) {
      return "Hello " + name;
}

What's the difference?

Same result with less code and less confusion.
kylin
@D-kylin
Nov 21 2016 03:58
the argument
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 03:58
@revisualize I think I visited that page! but it didn't look like anything has happened for a fairly long time!
Joseph
@revisualize
Nov 21 2016 03:58
@JeffGreenlee42 It's slow.
@javineya You're not returning the element that was removed.
Dannia Guzman
@danniaguzman
Nov 21 2016 03:59
@revisualize @JeffGreenlee42 I tried to use chrome debugger and print to console but found it confusing. I'll check out Atom editor and see if I can figure out the issue with code. Thanks so much for your help!
CamperBot
@camperbot
Nov 21 2016 03:59
danniaguzman sends brownie points to @revisualize and @jeffgreenlee42 :sparkles: :thumbsup: :sparkles:
:warning: danniaguzman already gave jeffgreenlee42 points
Johnny Vineyard
@javineya
Nov 21 2016 03:59
@revisualize I have no idea how. JavaScript is eating me alive.
CamperBot
@camperbot
Nov 21 2016 03:59
:star2: 2379 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Nov 21 2016 03:59

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

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

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

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

Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:00
@revisualize of course.. even if I did find one.. I have a little problem.. I don't have a laptop! Still it would be nice to actually breath the same air .. look into human pupils! :)
Joseph
@revisualize
Nov 21 2016 04:00
@javineya The .shift() gives you the element that was removed.. Just return it.
@JeffGreenlee42 I go to meetup events all the time. I hardly ever break out my computer.
Darth Skywalker
@adityaparab
Nov 21 2016 04:00

@abhisekp

@adityaparab :point_up: November 20, 2016 6:53 PM
cough...showoff...cough :D

haha :D

Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:01
:D
kylin
@D-kylin
Nov 21 2016 04:01
in the"Stand in Line"
hongwutian
@hongwutian
Nov 21 2016 04:01
blob
Joseph
@revisualize
Nov 21 2016 04:01
@hongwutian Where is your switch?
kylin
@D-kylin
Nov 21 2016 04:02
my code:
arr.push(item);
return arr.shift();
Joseph
@revisualize
Nov 21 2016 04:02
@D-kylin That's correct.
Johnny Vineyard
@javineya
Nov 21 2016 04:02
@D-kylin Thanks!
CamperBot
@camperbot
Nov 21 2016 04:02
javineya sends brownie points to @d-kylin :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for d-kylin
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:02
@danniaguzman Sure thing! I just recently went through the process of figuring it out! so if you have questions I am happy to help! It really makes a difference! for me at least.. I love being able to step through my code logic! Helps me understand so much better!
Johnny Vineyard
@javineya
Nov 21 2016 04:02
@revisualize Thanks. I just didn't realize that I could return a shift. Maybe I did that a few days ago in another challenge...
CamperBot
@camperbot
Nov 21 2016 04:02
javineya sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2380 | @revisualize |http://www.freecodecamp.com/revisualize
kylin
@D-kylin
Nov 21 2016 04:02
thanks!everybody
Joseph
@revisualize
Nov 21 2016 04:02
@javineya Sorry, I don't like directly giving away answers. I think people really need to learn this stuff.
Johnny Vineyard
@javineya
Nov 21 2016 04:03
@revisualize No, I understand completely. I appreciate that. Sometimes I need to see the code to make sense of what to do.
Deconstruction is a great way to learn, too.
Manish Giri
@Manish-Giri
Nov 21 2016 04:03
@JeffGreenlee42 do you have any good resources for using a debugger on an IDE/editor? I’ve always used the chrome debugger.
hongwutian
@hongwutian
Nov 21 2016 04:04
thanks. that's why it doesn't work
i for got switch
kylin
@D-kylin
Nov 21 2016 04:04
i an learning REACT by myself.that difficult for me.if somebody want to learn together
Terryd12345
@Terryd12345
Nov 21 2016 04:05

function smallestCommons(arr) {
arr.sort(function(a,b){
return a - b;
});
var flag = true;
var iter = 0;
while(flag){
iter += 1;
// check if both indexs are multiples of iter
if (iter%arr[0] === 0 && iter%arr1 === 0){
// loop through arr[0] to check if all preceeding nums are multiples also
// if a number is not then break
for(var i=1; i<=arr[0]; i++){
if(iter%i !== 0){
break;
} else {
// Do same with second index
for (var j=1; j<=arr1; j++){
if(iter%j !== 0){
break;
}
}
}
}
flag = false;
return iter;
}
}
}

smallestCommons([2,4]);
hey guys any clue why this doesnt work for the tests? It works for inputs like 4,5 and 3,2, not sure whats wrong with it

grdseime
@grdseime
Nov 21 2016 04:05
doesnt FCC lessons eventually include react?
I may be totally wrong.
silver537
@silver537
Nov 21 2016 04:05
yea
Darth Skywalker
@adityaparab
Nov 21 2016 04:05
I think they also need to include Angular
silver537
@silver537
Nov 21 2016 04:06
screw angular :P
kylin
@D-kylin
Nov 21 2016 04:06
that lesson is not in FFC
Ken Haduch
@khaduch
Nov 21 2016 04:06
@grdseime - there are some "Learn React Challenges" on the map, but it says something like "coming soon", there are some projects to do using SASS and React (the SASS) lessons are also TBD.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:06
@revisualize That's good to know! I guess I think about that.. because I imagine sometime doing the "pair" thing .. It would help tremendously to have something portable for that.. I'm seriously considering splurging on Mac.. I have a Mac Mini, but it's not exactly.. errrr. like a laptop!
Darth Skywalker
@adityaparab
Nov 21 2016 04:06
Majority of people using react tend to go back to that dirty jQuery like path lol

@silver537

screw angular :P

Why the hatred mate? :P

grdseime
@grdseime
Nov 21 2016 04:06
@khaduch oh okay. Ty for checking that out.
CamperBot
@camperbot
Nov 21 2016 04:06
grdseime sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1955 | @khaduch |http://www.freecodecamp.com/khaduch
silver537
@silver537
Nov 21 2016 04:06
those challenges will be available in the next FCC update
@adityaparab cause it's too confusing
kylin
@D-kylin
Nov 21 2016 04:08
i am look forward the update
Darth Skywalker
@adityaparab
Nov 21 2016 04:08
@JeffGreenlee42 : I prefer doing things lying around on couch/bed whatever :D
A luxury that no form of desktop can ever offer :D
Stanley Davis
@de-facto
Nov 21 2016 04:08
@mstellaluna meet me in my study.
Darth Skywalker
@adityaparab
Nov 21 2016 04:09
@silver537 : Angular is more of a philosophy than a framework :)
silver537
@silver537
Nov 21 2016 04:09
how?
kylin
@D-kylin
Nov 21 2016 04:09
@de-facto how to do it?
iceveda06
@iceveda06
Nov 21 2016 04:09
hello, i'm a bit lost here. anyone help?
function sumAll(arr) {
 var c = 0;
  if (arr[0] < arr[1]) {
    for (var i= arr[0]; i <= arr[1]; i++) {
      c = i + c;
      } return c;
  } else {for (var j = arr[0]; j <= arr[1]; j--) 
    c = j + c;
    console.log(c);
  } return c;
   // return c;
} 


sumAll([4,1]);
Darth Skywalker
@adityaparab
Nov 21 2016 04:10

@silver537

how?

I'm writing a Medium article for that.. Wait a while. You'll see that on FCC medium page soon :)

iceveda06
@iceveda06
Nov 21 2016 04:10
my else part doesn't seem to work, it seems right, i get 0 as result
silver537
@silver537
Nov 21 2016 04:10
@adityaparab link it when it's done :P
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:10
@Manish-Giri Not a dedicated IDE per se.. unless you consider Sublime or Atom an IDE.. I'm not sure where the definition begins or ends. .. I use Atom.. and am quite happy with it (though Sublime has been around longer with a few more bells and whistles) The chrome debugger is just a keystroke away! and then all you have to do is Paste your JS code into it and hit enter.. If you put in a statement "debugger;" The debugger will stop at that point and then you can step, add watchs and further breakpoints from there.
Joseph Parkton
@hippybear
Nov 21 2016 04:10
@iceveda06 you are missing an opening { after your for()
Darth Skywalker
@adityaparab
Nov 21 2016 04:11
@silver537 Sure
Joseph
@revisualize
Nov 21 2016 04:11
@JeffGreenlee42 I try to do weekend Coffee and Code's.
@JeffGreenlee42 I've done 2 of them.
@hippybear Long time no see. How's the Spoke?
Darth Skywalker
@adityaparab
Nov 21 2016 04:11
@iceveda06 : Just a suggestion, proper indentation helps you debug the code much easier. Let me take a look at your problem
Joseph
@revisualize
Nov 21 2016 04:11
@hippybear Got snow yet?
Joseph Parkton
@hippybear
Nov 21 2016 04:12
getting ready for snow season
only a couple light falls
nothing decent
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:12
Formerly lived in Montana.. I miss snow!!! :(
Joseph
@revisualize
Nov 21 2016 04:12
@hippybear I <3 <3 <3 my kahtoola microspikes
silver537
@silver537
Nov 21 2016 04:13
@iceveda06 when you start writting larger code, indentation will be a major factor in debugging.
@revisualize wtf
Joseph
@revisualize
Nov 21 2016 04:13
WTF!?
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:13
@revisualize What's the Seattle camper scene like?
silver537
@silver537
Nov 21 2016 04:13
WTFF
Joseph Parkton
@hippybear
Nov 21 2016 04:13
@iceveda06
else {
  for (var j = arr[0]; j <= arr[1]; j--) {
    c = j + c;
    console.log(c);
  }
}
silver537
@silver537
Nov 21 2016 04:13
wat the fuckity fuck
Joseph
@revisualize
Nov 21 2016 04:13
@hippybear corrected.
@silver537 What did I do? Did I say something wrong?
Joseph Parkton
@hippybear
Nov 21 2016 04:14
missed that ending bracket
silver537
@silver537
Nov 21 2016 04:14
EVERYTHING
Joseph
@revisualize
Nov 21 2016 04:14
@JeffGreenlee42 Depends do you have a car?
@silver537 I don't believe you.
silver537
@silver537
Nov 21 2016 04:15
ill prove it to you
just wait
Darth Skywalker
@adityaparab
Nov 21 2016 04:15
@iceveda06 : You're missing curly braces. That's first error.
mstellaluna
@mstellaluna
Nov 21 2016 04:16
@de-facto check your IM
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:16
@adityaparab Yes! I hear that! And.. so far I just don't seeing "tablets" satisfying the Coding requirements..
iceveda06
@iceveda06
Nov 21 2016 04:16
tried to fix it..how about now
Darth Skywalker
@adityaparab
Nov 21 2016 04:16
@iceveda06 : 2nd, you're for loop in else part should start from arr1 and run to arr[0]. You got it reversed.
iceveda06
@iceveda06
Nov 21 2016 04:16
function sumAll(arr) {
 var c = 0;
  if (arr[0] < arr[1]) {
    for (var i= arr[0]; i <= arr[1]; i++) {
      c = i + c;
      } return c;
  } else {
      for (var j = arr[0]; j <= arr[1]; j--) {
        c = j + c;
        console.log(c);  
         } return c;

} 
}

sumAll([4,1]);
silver537
@silver537
Nov 21 2016 04:16
this guy just pocketed the 8 ball in his second turn T_T
Joseph
@revisualize
Nov 21 2016 04:16
@silver537 What? What are you watching?
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:16
@revisualize yes.. have a car.. errr. truck actually.. Live in Downtown Seattle.. near R.E.I.
Darth Skywalker
@adityaparab
Nov 21 2016 04:16
Also, you need to do j++ in 2nd loop, you're having j-- which causes infinite loop
Joseph
@revisualize
Nov 21 2016 04:17
@JeffGreenlee42 The camping around Seattle is pretty good. There's a LOT of it. If you have a car. I don't so... Yeah.
silver537
@silver537
Nov 21 2016 04:17
@revisualize iom playing 8 ball pool on my phone
iceveda06
@iceveda06
Nov 21 2016 04:17
@adityaparab thanks dude, that was my mistake
CamperBot
@camperbot
Nov 21 2016 04:17
iceveda06 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 715 | @adityaparab |http://www.freecodecamp.com/adityaparab
Joseph
@revisualize
Nov 21 2016 04:18
@silver537 HEHE.. I don't like playing pool on my phone. I like grabbing a cue and touching a table.
Darth Skywalker
@adityaparab
Nov 21 2016 04:18
@iceveda06 :
function sumAll(arr) {
  var c = 0;
  if (arr[0] < arr[1]) {
    for (var i= arr[0]; i <= arr[1]; i++) {
      c = i + c;
    }
    return c;
  } else {
    for (var j = arr[1]; j <= arr[0]; j++) {
      c = j + c;
      console.log(c);
    }
    return c;
  }
}
sumAll([4,1]);
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:18
@revisualize it's funny.. I tried looking up Seattle camping info on the FCC website.. but the trail is a bit cold... .. maybe it just hasn't been updated recently.
silver537
@silver537
Nov 21 2016 04:19
@revisualize same here but it passes the time
Joseph Parkton
@hippybear
Nov 21 2016 04:19
so does coding
Joseph
@revisualize
Nov 21 2016 04:20
@silver537 You know.. I have a facebook photo album of table runs and 8 ball breaks.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:20
@revisualize of course.. errr.. being seattle.. I could take you literally! :) there are lots of ummm. .. "campers" in weird areas living in tents! :)
Darth Skywalker
@adityaparab
Nov 21 2016 04:20

@iceveda06 : Additionally, it's always advisable to have your loop boundaries determined preemptively.

You can use Math.min and Math.max to find out min and max from your array.

so your code will be like

function sumAll(arr) {
  var min = Math.min.apply(null, arr);
  var max = Math.max.apply(null, arr);
  var total = 0;

  for(var i=min; i <= max; i++){
    total += i;
  }

  return total;
}
sumAll([4,1]);
Daniel
@danphibian
Nov 21 2016 04:30
Good evening everyone!
Joseph
@revisualize
Nov 21 2016 04:30
@JeffGreenlee42 I have a bunch of those "campers" living across the street from my apartment.
Daniel
@danphibian
Nov 21 2016 04:30
I was hoping someone can help me out with an issue...

function mutation(arr1,arr2) {
var arrLowA = arr1.toLowerCase();
var arrLowB = arr2.toLowerCase();
var num = arrLow1.indexOf(arrLow2, 0);

if (num >= 0){
return true;
}
else {
return false;
}
}

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

but it reads .toLowerCase is not a function...
am I using the toLowerCase function incorrectly?
Tomekp
@tomaszp84
Nov 21 2016 04:32

hello to all campers, I have a problem I can't jump. It is about :Make Object Properties Private.
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 myBike= new myBike();
var gear;
this.getGear = function(){
return gear;
};
this.setGear = function(){
return gear;
};
};

I am trying to solve it myself but I really stack

Joseph Parkton
@hippybear
Nov 21 2016 04:32
@dyanagi its named arrLowB and you are passing in arrLow2
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:33
@dyanagi Yes, I beleive .toLowerCase() only works on strings... You may need to convert the array's to a string first.
Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:40
@iceveda06 you may use Arithmetic Progression to find the sum much faster :zap:
:point_right: https://en.wikipedia.org/wiki/Arithmetic_progression#Sum
Joseph Parkton
@hippybear
Nov 21 2016 04:42
you can even do it in one line :)
WhiteLeaf1103
@WhiteLeaf1103
Nov 21 2016 04:42
@abhisekp I did not solve it. I havent moved on since the lesson! :( javascript is just kick my butt.
Joseph Parkton
@hippybear
Nov 21 2016 04:43
private static int sum; :P
jk
Daniel
@danphibian
Nov 21 2016 04:43
@hippybear Oh yea! Thanks! But even after I corrected the variables, it still says .toLowerCase is not a function
CamperBot
@camperbot
Nov 21 2016 04:43
dyanagi sends brownie points to @hippybear :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @hippybear |http://www.freecodecamp.com/hippybear
Joseph Parkton
@hippybear
Nov 21 2016 04:43
@dyanagi you will need to convert those to strings in order to use toLowerCase
Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:44
@WhiteLeaf1103 which one?
:question:
:confused:
Joseph Parkton
@hippybear
Nov 21 2016 04:44
toLowerCase is not a function available to arrays
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:44
@dyanagi Are you passing your function a string or an array??? You need to be clear on that! toLowerCase does NOT know what to do with an array!
Joseph Parkton
@hippybear
Nov 21 2016 04:44
@abhisekp why no Java room prabhu??
Its being closed :(
Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:44
:(
It's encouraged to use Forum or General chat room.
Joseph Parkton
@hippybear
Nov 21 2016 04:45
ah
Johnny Vineyard
@javineya
Nov 21 2016 04:45
I don't like arrays...
Daniel
@danphibian
Nov 21 2016 04:45
@JeffGreenlee42 Hmm.. Does the variable turn into number value if the parameter name has a number?
Joseph Parkton
@hippybear
Nov 21 2016 04:46
only if you cast it as such
@dyanagi use arrLow.toString().toLowerCase();
also this CMS is a pain :( keeps erasing code!!
Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:47
@adityaparab
function sumAll(arr) {
  const [firstNum, lastNum] = arr.sort((a,b) => a-b);
  return (lastNum - firstNum + 1) * (firstNum + lastNum) / 2;
}
:sunglasses:
Joseph Parkton
@hippybear
Nov 21 2016 04:48
you and your dang es6
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:48
@dyanagi yes.. and there are couple of fuctions for converting back and forth between string and array.. split() and ohhh.. can't remember the other one .. join() ??
silver537
@silver537
Nov 21 2016 04:48
@abhisekp cheaqter
Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:49
:(
i no cheat
Joseph Parkton
@hippybear
Nov 21 2016 04:50
array.split() wont work
split is a string method
splice() could or slice()
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:51
Yeah.. slice() that's the one!
get 'em mixed up!
silver537
@silver537
Nov 21 2016 04:51
splice combines replace and slice. soooooooo its more efficient :P
Joseph Parkton
@hippybear
Nov 21 2016 04:52
its also better to use since it doesnt destroy your orignal
Tomekp
@tomaszp84
Nov 21 2016 04:52
is here anybody free to help with my issue??
Joseph Parkton
@hippybear
Nov 21 2016 04:52
whats the issue
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:52
We are all free!!! ;P
Darth Skywalker
@adityaparab
Nov 21 2016 04:52
@abhisekp Yes. I like Arithmetic Progression. :)
Joseph Parkton
@hippybear
Nov 21 2016 04:54
man java is freakin intense
Darth Skywalker
@adityaparab
Nov 21 2016 04:54
const sumAll = (arr) => {return (Math.max.apply(null, arr) - Math.min.apply(null, arr) + 1) * (Math.min.apply(null, arr) + Math.max.apply(null, arr)) / 2;}
Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:54
that's crazy!
Joseph Parkton
@hippybear
Nov 21 2016 04:55
boom
one line ftw
Abhisek Pattnaik
@abhisekp
Nov 21 2016 04:55
@JeffGreenlee42 I'm Function#bind. I'm not free!
Joseph
@revisualize
Nov 21 2016 04:55
@adityaparab I have a one liner for that lesson too.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:55
speaking of Java.. It think its time to go brew some!
Darth Skywalker
@adityaparab
Nov 21 2016 04:55
or even
const sumAll = arr => (Math.max.apply(null, arr) - Math.min.apply(null, arr) + 1) * (Math.min.apply(null, arr) + Math.max.apply(null, arr)) / 2;
Joseph
@revisualize
Nov 21 2016 04:55
@adityaparab const sumAll = ([x, y]) => (x + y) * (Math.abs(x - y) + 1) / 2;
Joseph Parkton
@hippybear
Nov 21 2016 04:55
but dat aint even js
so null
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:56
@abhisekp what is Function#bind?
Darth Skywalker
@adityaparab
Nov 21 2016 04:56
@revisualize : Pretty sweet! Didn't think of using Math.abs.. Good one :)
Joseph Parkton
@hippybear
Nov 21 2016 04:56
show us some code
what have you got so far
Darth Skywalker
@adityaparab
Nov 21 2016 04:57
I hate Java for some reason. Not because it's Java but because it's devout followers
Tomekp
@tomaszp84
Nov 21 2016 04:57
@hippybear I read instructions many times and cannot figure it out how to assemble all together to make it work properly
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:58
@tomaszp84 do you know how to post your code here?
Joseph Parkton
@hippybear
Nov 21 2016 04:58
@adityaparab pretty much my hatred of Christianity in a nutshell
Joseph
@revisualize
Nov 21 2016 04:58
Okay. I need to jet.
Darth Skywalker
@adityaparab
Nov 21 2016 04:58
@tomaszp84 : You declare private properties using var (or let or const) keyword
Joseph
@revisualize
Nov 21 2016 04:58
I have a bunch of laundry to hang up and a suitcase to wash.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:58
@revisualize noice to chat! :)
Joseph Parkton
@hippybear
Nov 21 2016 04:58
harsh
Darth Skywalker
@adityaparab
Nov 21 2016 04:59
@hippybear : I would have to whole heartedly agree with you on that one.
Joseph
@revisualize
Nov 21 2016 04:59
@JeffGreenlee42 :v: I'm in here quite a bit.
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 04:59
@revisualize good! I'm sure I'll be pestering with future challenges!
Joseph Parkton
@hippybear
Nov 21 2016 04:59
I do like the built in testers in java
thats a good thing js could use more of
testing in js is a pita
need an array, have an int instead. Js doesnt even care
lol
Tomekp
@tomaszp84
Nov 21 2016 05:01
@adityaparab so what about var myBike=new Bike()?
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:01
Yup.. typed vs. non typed languages..
Tomekp
@tomaszp84
Nov 21 2016 05:02
is't it private?
Elifaz Filho
@Elifaz
Nov 21 2016 05:02
Hey everyone, I have a quick question
Daniel
@danphibian
Nov 21 2016 05:02
@JeffGreenlee42 Oh yea. I understand that it needs to be a string. So I tried this...
Elifaz Filho
@Elifaz
Nov 21 2016 05:02
do I have to hide the app key from external api’s on the client?
Daniel
@danphibian
Nov 21 2016 05:02

function mutation(arrA,arrB) {
var arrLowA = arrA.toString().toLowerCase();
var arrLowB = arrB.toString().toLowerCase();
var num = arrLowA.indexOf(arrLowB, 0);

if (num >= 0){
return true;
}
else {
return false;
}
}

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

Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:03
@tomaszp84 the function Bike() ? no.. its a constructor!
Elifaz Filho
@Elifaz
Nov 21 2016 05:03
I wonder if I actually have to hide it, since I’m not using directly the app secret
Daniel
@danphibian
Nov 21 2016 05:03
and also tried the .join method at the end to try and make it a string.
but now it says .toString is undefined
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:04
@JeffGreenlee42
const JeffGreenlee42 = {
  name: 'Jeff', 
  getName() {
    return this.name;
  }
}

const getName = JeffGreenlee42.getName;
const getName2 = JeffGreenlee42.getName.bind(JeffGreenlee42);

console.log( 
  getName(JeffGreenlee42), // boom!
  getName2(JeffGreenlee42); // 'Jeff'
)
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:06
@abhisekp the point?
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:07
@revisualize nice one :point_up: November 21, 2016 10:25 AM
Tomekp
@tomaszp84
Nov 21 2016 05:07
@JeffGreenlee42 so how should I start writing the code below var Bike=function() if var myBike=new Bike () is not correct
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:07
@JeffGreenlee42 Function#bind ;P
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:08
@abhisekp oh! ok... :) .. to Be ... Free .. or not to Be .... Free? :P
Vidhi patel
@VidhiPatel5151
Nov 21 2016 05:08
can you help me for create one function which store user signup data?
Darth Skywalker
@adityaparab
Nov 21 2016 05:08

@tomaszp84

@adityaparab so what about var myBike=new Bike()?

That var is not private here.

Take a look at

function foo(){
  var _bar = 'I am private';
  this.bar = 'I am public';
}

var f = new foo();

console.log(f._bar); // undefined
console.log(f.bar); // I am public
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:09

@abhisekp oh! ok... :) .. to Be ... Free .. or not to Be .... Free? :P

@JeffGreenlee42 is that the only question? ;P

Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:10
@abhisekp perhaps.. the most profound?
Darth Skywalker
@adityaparab
Nov 21 2016 05:10
But you can still get value of _bar like
function foo(){
  var _bar = 'I am private';
  this.bar = 'I am public';
  this.get_bar = function(){
    return _bar;
  }
}

var f = new foo();

console.log(f.get_bar()); // I am private
console.log(f.bar); // I am public
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:10
i'm_a_snake :snake:
silver537
@silver537
Nov 21 2016 05:11
IM A GHOST
:ghost:
Darth Skywalker
@adityaparab
Nov 21 2016 05:11
I am a Jedi. I am a Sith. I am a Force Wielder!
silver537
@silver537
Nov 21 2016 05:12
im also a shadow
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:12
I'm a minature donkey.
Darth Skywalker
@adityaparab
Nov 21 2016 05:12
@abhisekp being Bihari? :P
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:12
racism
Darth Skywalker
@adityaparab
Nov 21 2016 05:13

@abhisekp

racism

If you haven't noticed, India is THE MOST racist country this world has ever seen. Not the UK or USA or AUS :D

silver537
@silver537
Nov 21 2016 05:13
how?
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:14
true
Darth Skywalker
@adityaparab
Nov 21 2016 05:14
For Maharashtrian people like me, everything north of Maharashtra is Bihar :P
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:14
Gulp.. hey guys.. is the world politics or HelpJavaScript?
Darth Skywalker
@adityaparab
Nov 21 2016 05:14
@JeffGreenlee42 : Everything is connected mate :P
JackVizl
@JackVizl
Nov 21 2016 05:14
  var testStr="01101001";

  var decimalVal=0;

for(var b=0;b<8;b++){

  if(testStr[b]==1){

    decimalVal+=Math.pow(2,b);

  }


}
  return decimalVal;
someone explain why im not getting 105?
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:15
@adityaparab maybe so.. is this the appropriate forum?
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:15
umm.... i think we should drop the topic
Darth Skywalker
@adityaparab
Nov 21 2016 05:15
@JeffGreenlee42 : Okay, I won't say anything anymore :D
silver537
@silver537
Nov 21 2016 05:15
it's only appropriate when people feel like it.
gabi
@gikwu1
Nov 21 2016 05:15
i'll come back tomoro
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:16
@gikwu1 why?
silver537
@silver537
Nov 21 2016 05:16
like casual chatting isnt appropriate because it's not javascript.
Darth Skywalker
@adityaparab
Nov 21 2016 05:16

@abhisekp

umm.... i think we should drop the topic

No worries mate, had we been talking about western racism, these people would gladly have joined. :P They just don't understand or know indian flavor of racism D:

Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:16
@gikwu1 Please ask your questions
@adityaparab ok... later..
Darth Skywalker
@adityaparab
Nov 21 2016 05:17
Yes
Abhisek Pattnaik
@abhisekp
Nov 21 2016 05:18
@VidhiPatel5151 where do you want to store user sign up data?
Andre Morise
@AndreMorise
Nov 21 2016 05:18
enableCasualChat();
gabi
@gikwu1
Nov 21 2016 05:18
i guess this forum in not talking java tonight
Darth Skywalker
@adityaparab
Nov 21 2016 05:18
@gikwu1 : Things are back on topic now. You may stay
silver537
@silver537
Nov 21 2016 05:18

@gikwu1 it would be if this was a java forum.

javaSCRIPT

Darth Skywalker
@adityaparab
Nov 21 2016 05:19
Your question is very vast. Can you elaborate a bit more on where and how you want to store the data? @gikwu1
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:19
Ha! yes.. I AM grateful this is NOT a Java forum!
Darth Skywalker
@adityaparab
Nov 21 2016 05:19
@JeffGreenlee42 : disableShitTalk(true);
gabi
@gikwu1
Nov 21 2016 05:20
JavaSript forum @JeffGreenlee42 and @silver537
like i said, the too know guys are here tonight so i'm just gonna come bk tomoro when u guys have left so i can ask my question to people who are open to helping....good night
Vidhi patel
@VidhiPatel5151
Nov 21 2016 05:21
@abhisekp i want to store that data in sql database temporary stored in javascript after i wlii do it in sql code
silver537
@silver537
Nov 21 2016 05:21
you never asked a question
im looking up and there's no question. :expressionless:
jamesmillerho
@jamesmillerho
Nov 21 2016 05:22
@VidhiPatel5151 ?
Vidhi patel
@VidhiPatel5151
Nov 21 2016 05:23
@jamesmillerho what?
Jeff Greenlee
@JeffGreenlee42
Nov 21 2016 05:23
"Yes Master..... What is the meaning of life? " :P
Diego Mayer
@Chrono79
Nov 21 2016 05:23
@JackVizl try decimalVal+=Math.pow(2,7-b);
JackVizl
@JackVizl
Nov 21 2016 05:24
@Chrono79 worked, but could you please explain why?
Diego Mayer
@Chrono79
Nov 21 2016 05:25
@JackVizl binary numbers start from right to left, the rightmost is the one you should elevate to 0 and such
JackVizl
@JackVizl
Nov 21 2016 05:25
oh
wow
im an idiot
thanks @Chrono79
CamperBot
@camperbot
Nov 21 2016 05:25
jackvizl sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2585 | @chrono79 |http://www.freecodecamp.com/chrono79
Patthamawadee Honetwichit
@puppyplub
Nov 21 2016 05:28
I don't understand about the madlib -> The Word Blanks I put the words in function and I also use if and else for check the "" , cat and dog but it doesn't work. Could you help me about this. Maybe you could give me some more clue please help.
grdseime
@grdseime
Nov 21 2016 05:30
@puppyplub idk if you need if or else statements. I think its mostly using the "+" symbol
Sharmilakg
@Sharmilakg
Nov 21 2016 05:34
hi
what does the "Do not change code above the line" mean?
Darth Skywalker
@adityaparab
Nov 21 2016 05:34
@Sharmilakg : It means do not change the code above that line
including that line
Patthamawadee Honetwichit
@puppyplub
Nov 21 2016 05:35

@grdseime ​thx for your reply ;)

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
if(myNoun === "" && myAdjective === "" && myVerb === "" && myAdverb === ""){
result = "Oh!No!";
}
if(myNoun == "dog"){
result = "As you can see, The " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + "." + " So, I need to stay away from him.";
}
if(myNoun == "cat"){
result = " " + myAdjective + " " +myNoun + " " + myVerb + " " + myAdverb + ".";
}
else{
result = "default";
}
// Your code above this line
return result;
}

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

Sharmilakg
@Sharmilakg
Nov 21 2016 05:35

Assign the value 7 to variable a.

Assign the contents of a to variable b....i typed var a=7 and var b=a

Darth Skywalker
@adityaparab
Nov 21 2016 05:35
that is correct. @Sharmilakg
SoteroX
@SoteroX
Nov 21 2016 05:35
golfScore is not define?
JackVizl
@JackVizl
Nov 21 2016 05:47

function truthCheck(collection, pre) {


  for(var i in collection){

    if(!collection[i].hasOwnProperty(pre)){

     return false;

    }

     switch(collection[i][pre]){
          case(undefined):
          case(""):
         case(NaN):
          case(null):
           return false;

        default:
          break;

      }

  }

 return true;

}

truthCheck([{"single": "double"}, {"single": NaN}], "single");
why is this not returning false pls
Alexandro Pequeno
@Argestis
Nov 21 2016 05:52
Hi guys, anyone here good with interval functions? :D
I have some questions...
Burak
@BurakAy
Nov 21 2016 05:53
in the Record Collection section, what do they mean with this, "After updateRecords(2548, "artist", ""), artist should not be set."? Haven't been able to get it to pass. I've tried simply assigning the value to empty string, assigning it undefined, and no luck.
Ryan Ledford
@rledford
Nov 21 2016 05:53
@Argestis whats your question
grdseime
@grdseime
Nov 21 2016 05:56
@puppyplub Your code seems to be more extensive then necessary. The variables myNoun, myVerb, myAdjective, and myAdverb are already declared for you so you dont need to change them. The challenge wants you to use "+"
c0d0er
@c0d0er
Nov 21 2016 05:57
this is my tic tac toe, could anybody find the way to win with this game? http://codepen.io/c0d0er/pen/QGNNXz?editors=0110
Alexandro Pequeno
@Argestis
Nov 21 2016 05:58

So I'm doing the SimonSays game and I'm creating a function to change the color of divs depending on the sequence. Everything is working fine. but sometime the intervals run faster than normal and we can barely see when it changes the color,

this is the function:

function litSequence(){
 var intervalColor;
 var intervalId = setInterval(function () {    
                console.log("I been at lit sequence, the count of game.count, " + game.count.length +" counter: " + game.counter);
       if(game.count[game.counter]  === 1){
        console.log("I were at blue lit")
           game.blue.css("background-color", "cyan");
          intervalColor = setInterval(function(){game.blue.css("background-color", "blue");}, 1500);

       }     

       else if(game.count[game.counter]  === 2){
        console.log("I were at red lit")
           game.red.css("background-color", "pink");
          intervalColor = setInterval(function(){  game.red.css("background-color", "red");}, 1500);

       }         
       else if(game.count[game.counter]  === 3){
        console.log("I were at green lit")
            game.green.css("background-color", "#33ff33");
           intervalColor = setInterval(function(){  game.green.css("background-color", "green");}, 1500);

       }         
       else if(game.count[game.counter] === 4){
        console.log("I were at yellow lit")
            game.yellow.css("background-color", "orange");
            intervalColor = setInterval(function(){  game.yellow.css("background-color", "yellow");}, 1500);

       }                 


      game.counter++;                    
      if (game.counter < game.count.length) {   
         clearInterval(intervalColor);         
         litSquence();           
      }      
      else{clearInterval(intervalId)}




   }, 2000 )



};
@rledford whoops, message was for you xD
Vidhi patel
@VidhiPatel5151
Nov 21 2016 06:00
can help me out
Steven Bigham
@volv
Nov 21 2016 06:00
@c0d0er Ran about 10 or 12 games. Couldn't beat it. Even using the ways that used to beat mine :)
jamesmillerho
@jamesmillerho
Nov 21 2016 06:00
help what
CamperBot
@camperbot
Nov 21 2016 06:00
no wiki entry for: what
c0d0er
@c0d0er
Nov 21 2016 06:01
@volv thanks, maybe try more, really want to find the way to win this tic tac toe
CamperBot
@camperbot
Nov 21 2016 06:01
c0d0er sends brownie points to @volv :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @volv |http://www.freecodecamp.com/volv
jamesmillerho
@jamesmillerho
Nov 21 2016 06:02
@Argestis because you set interval in an interval
Ryan Ledford
@rledford
Nov 21 2016 06:02
@Argestis what may be happening is that you're not sequencing your interval. So you know you're going to play each step for seconds so you need to stagger your intervals when creating the play sequence by setting up a delay with setTimeout instead of setInterval
jamesmillerho
@jamesmillerho
Nov 21 2016 06:03
@Argestis The problem is the outer interval won't wait the inner interval to finish
@Argestis What you want is, you have a function, set interval in that function, and call that function in that interval
Ryan Ledford
@rledford
Nov 21 2016 06:04
@rledford setTimeout(function(){}, i*playSpeed) if you're using a for loop with i incrementing each time
Alexandro Pequeno
@Argestis
Nov 21 2016 06:08
@rledford Let me try it, thank you for your time! brb
CamperBot
@camperbot
Nov 21 2016 06:08
argestis sends brownie points to @rledford :sparkles: :thumbsup: :sparkles:
:cookie: 396 | @rledford |http://www.freecodecamp.com/rledford
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:14

@abhisekp i want to store that data in sql database temporary stored in javascript after i wlii do it in sql code

@VidhiPatel5151 sorry! Power cut. I'm unable to follow your question.

@VidhiPatel5151 You may use knex.js library to talk to sql db
@VidhiPatel5151 btw, for backend questions, you may ask in **`FreeCodeCamp/HelpBackend`** room
Markus Kiili
@Masd925
Nov 21 2016 06:25
@abhisekp Are there any security problems with that kind of library?
Chris
@Cbhansen
Nov 21 2016 06:29
need help!
Markus Kiili
@Masd925
Nov 21 2016 06:31
@abhisekp Seems to be mainly for Node.js environment. Composing SQL queries in the browser for execution on the server is highly discouraged, as this can be the cause of serious security vulnerabilities., says the knex.js website.
Darth Skywalker
@adityaparab
Nov 21 2016 06:32
Having your queries displayed to the user reveals your database structure :)
This could be of great help in dev environment. Should be avoided in production
andry91959
@andry91959
Nov 21 2016 06:35
Capture43.PNG
Hi, can someone help me. I'm stuck at exercise make object properties private
Darth Skywalker
@adityaparab
Nov 21 2016 06:38
@andry91959 You haven't defined your Car class
Markus Kiili
@Masd925
Nov 21 2016 06:38
@adityaparab Yes, hard to imagine any reason to do it that way really.
Ayush Bahuguna
@relentless-coder
Nov 21 2016 06:38
I am stuck at "where do I belong" challenge.
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var index;
  arr.sort();
  for(var i = 0; i < arr.length; i++) {
    if(arr[i] < num) {
      index = i + 1;
    }  
  }
  return index;
}
Markus Kiili
@Masd925
Nov 21 2016 06:39
@relentless-coder The default sort is not numerical sort.
Ayush Bahuguna
@relentless-coder
Nov 21 2016 06:39
this code is failing against the following tests
andry91959
@andry91959
Nov 21 2016 06:39
@GeneralSkywalker I thought the question is only for bike no?
Ayush Bahuguna
@relentless-coder
Nov 21 2016 06:39
getIndexToIns([3, 10, 5], 3) and getIndexToIns([5, 3, 20, 3], 5)
Markus Kiili
@Masd925
Nov 21 2016 06:39
@relentless-coder The solution is much simpler if you first push num into arr and then sort.
Ayush Bahuguna
@relentless-coder
Nov 21 2016 06:40
okay.
Darth Skywalker
@adityaparab
Nov 21 2016 06:40
@Masd925 : As a full stack dev, I find this kinda tools very handy. It's way easier to debug in browser than on backend. For node, you need to install node-inspector. So that spanws another instance of chrome dev tools alongside your browser. It becomes very confusing what window represents what. So If I can do it all at once place, it becomes much productive.
Markus Kiili
@Masd925
Nov 21 2016 06:40
@relentless-coder You need to pass a suitable callback function to sort that defines the numerical sorting.
Darth Skywalker
@adityaparab
Nov 21 2016 06:40
That's the only scenario I find this to be useful.
andry91959
@andry91959
Nov 21 2016 06:41
@adityaparab its still not working, I dont know why
@adityaparab its not working I dont know why

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 = 10;

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

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

var myCar = new Car();
myCar.accelerate();
myCar.decelerate();
myCar.getSpeed();
var myBike = new Bike();
myBike.getGear();
myBike.setGear(4);

Darth Skywalker
@adityaparab
Nov 21 2016 06:41
@andry91959 hold on
Markus Kiili
@Masd925
Nov 21 2016 06:41
@adityaparab ok
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:42
@Masd925 idk if there is any security issues using the lib but at least it is much easier to work with a wrapper instead of the sql directly. Moreover, i really like how easy it is to migrate db or switch between DBMS.
Darth Skywalker
@adityaparab
Nov 21 2016 06:43
@andry91959
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.getGear = function(){
    return gear;
  };

  this.setGear = function(g){
    gear = g;
  };

};
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:45
@Masd925 and i don't understand why would anyone compose SQL queries and pass it to the db from client side other than for demo purposes :D
andry91959
@andry91959
Nov 21 2016 06:45
@adityaparab it worked but, what is this this? setGear = function(g){
gear=g;?
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:46
@adityaparab i noticed you're giving out answers.... highly discouraged
Darth Skywalker
@adityaparab
Nov 21 2016 06:46
@andry91959 It will assign the value of g to your private variable, gear.
@abhisekp : Sorry. Noted down.
Markus Kiili
@Masd925
Nov 21 2016 06:47
@abhisekp Yes. I think the original @VidhiPatel5151 question here was about doing something like that (connecting to db from browser js).
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:47
hmm... thoughtful :thought_balloon:
the first query i would pass is DROP DATABASE USERS;
:D
Darth Skywalker
@adityaparab
Nov 21 2016 06:49
:D
In reference to current demonitization drive in India, I'd deposit 4000000000 INR in @abhisekp 's account ;)
andry91959
@andry91959
Nov 21 2016 06:49
@adityaparab alright thank you
CamperBot
@camperbot
Nov 21 2016 06:49
andry91959 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 716 | @adityaparab |http://www.freecodecamp.com/adityaparab
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:50
:expressionless: :gun: :cop: :police_car:
Darth Skywalker
@adityaparab
Nov 21 2016 06:50
ha
:D
Joseph
@revisualize
Nov 21 2016 06:55

Look, I'm going to post this again. If you're on Facebook, you should really join this group: https://www.facebook.com/groups/1594816820775537/

Darth Skywalker
@adityaparab
Nov 21 2016 06:56
@revisualize Whats that group about?
facebook blocked at werk! :disappointed:
Markus Kiili
@Masd925
Nov 21 2016 06:56
@abhisekp When I made my first db using software (online pizzeria) at school a couple of years ago, the first thing I did was trying to inject stuff into the database. Is it so nice to be naughty or what?
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:57
@Masd925 The first i did when our lab teacher taught us DBMS is drop table employee;
Darth Skywalker
@adityaparab
Nov 21 2016 06:57
Santa's gonna have runs!
Joseph
@revisualize
Nov 21 2016 06:57
@adityaparab It's the Newbie Coder Warehouse.
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:57
@Masd925 and no one could learn database using the default employee table that day :D
Darth Skywalker
@adityaparab
Nov 21 2016 06:58
:D
Abhisek Pattnaik
@abhisekp
Nov 21 2016 06:58
it really feels nice :innocent:
Darth Skywalker
@adityaparab
Nov 21 2016 06:58
#FeelsNiceToBeNaughty
#HashTag
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:00
@revisualize what to do in the group? It's not related to FCC. Is it?
Markus Kiili
@Masd925
Nov 21 2016 07:02
@abhisekp They say that breaking things is very important for developing mind.
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:02
:D
Markus Kiili
@Masd925
Nov 21 2016 07:02
Or is it developer's mind.
Ayush Bahuguna
@relentless-coder
Nov 21 2016 07:04
the replace statement is not working.
function rot13(str) { // LBH QVQ VG!
  var arr = str.split(' ');
  console.log(arr);
  for(var i = 0; i < arr.length; i++) {
    for(var j = 0; j < arr[i].length; j++) {
      var charCode = arr[i].charCodeAt(j);
      var newCharCode = charCode - 13;
      console.log(charCode);
      arr[i].replace(arr[i].charAt(j), String.fromCharCode(newCharCode));

      console.log("new" + newCharCode);
    }
  }
  return arr.join(' ');
}
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:04
http://codepen.io/jeff-shapiro/live/BQzBRR my new random quote machine :)
Joseph
@revisualize
Nov 21 2016 07:06
@abhisekp It isn't related to FCC. It is a general coding group for Newbie Coders.
@abhisekp I just find the information that people share in the group to be useful. So, I figure I would recommend the group to people.
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:08
hmm code pen has a bug :(
Joseph
@revisualize
Nov 21 2016 07:08
@Jeff-Shapiro Why does it say Hello World?
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:08
@revisualize it shouldn't
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:08
lol
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:08
well i put that as a placeholder early on
Joseph
@revisualize
Nov 21 2016 07:08
@Jeff-Shapiro This kind of sucks.
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:08
But look this is my code
kirbyedy
@kirbyedy
Nov 21 2016 07:09
why does it refresh by itself ?
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:09
its the same one but code pen in live view sucks
Dan Couper
@DanCouper
Nov 21 2016 07:09

Given I have two sequences of numbers, like

var seqY = [0,1,2];
var seX =   [0,1,2];

And it’s important that they stay as this, I can’t change them - I want

[[0,0,0],
 [1,1,1],
 [2,2,2]]

But I can’t figure out why this doesn’t work:

> seqY.map(y => seqX.fill(y));
// it generates this:
[[2,2,2],
 [2,2,2],
 [2,2,2]]

I can’t figure out why it’s filling every sub-array with the exact same value. [0,1,2].fill(0) is [0,0,0], [0,1,2].fill(1) is [1,1,1], and [0,1,2].fill(2) is [2,2,2]. But [0,1,2].map(y => [0,1,2].fill(y)) is not [[0,0,0],[1,1,1],[2,2,2]]

Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:10
So code pen official sucks
Joseph
@revisualize
Nov 21 2016 07:10
@Jeff-Shapiro I really don't like quote box jumping around nor do I like the poor choice in colors. Nor do I like the fact that the page refreshes itself.
Dan Couper
@DanCouper
Nov 21 2016 07:11
you can turn off the refresh
UI does suck though
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:11
JSBin :heartpulse:
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:11
the colours are completely random
Steven Bigham
@volv
Nov 21 2016 07:11
I quite liked it. Make it cycle itself and its like a screensaver
Joseph
@revisualize
Nov 21 2016 07:11
@Jeff-Shapiro They're horrible. They don't even contrast.
ANYHOW!
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:12
@revisualize the do contrast infact it is tested to pass requirements
Joseph
@revisualize
Nov 21 2016 07:12
@Jeff-Shapiro Not from what I'm seeing.
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:13
@revisualize anyway nil html or css predefined :)
Dan Couper
@DanCouper
Nov 21 2016 07:13
Yeah, it’s built so that the colours it generates should always be accessible, just runs a contrast function
Joseph
@revisualize
Nov 21 2016 07:13
blob
This all looks pink to me.
blob
Blue on Blue Green?
Dan Couper
@DanCouper
Nov 21 2016 07:14
AH, I was looking at the wrong thing there
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:15
that looks like white on pink and purple on blue green
Dan Couper
@DanCouper
Nov 21 2016 07:15
yeah, contrast is borked
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:15
I can't define it as they're random
Joseph
@revisualize
Nov 21 2016 07:15
@Jeff-Shapiro That is not contrast. The colors blur together.
blob
Hard to read.
ANYHOW!
:v:
Dan Couper
@DanCouper
Nov 21 2016 07:19
@Jeff-Shapiro If you’re interested, look for a colour contrast library - I know there are a few floating round that will generate you colour pairs that always contrast.
Screenshot 2016-11-21 07.16.32.png
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:20
@DanCouper meh those two colours are comlpetely random
@DanCouper I was more interested in the backend and not using any html or css
Dan Couper
@DanCouper
Nov 21 2016 07:20
Yeah, I get that
It’s fine, it’s just if you were interested, there are tiny JS libraries that
sort out the contrast
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:21
it does do some testing using the tinycolor library but I am not sure how well its coded
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:21
@revisualize How about this Color Pattern Generator I created some years ago
Refresh to see new pattern
Markus Kiili
@Masd925
Nov 21 2016 07:21
@DanCouper That is weird because the map callback returns [0,0,0], [1,1,1] and [2,2,2], but the result is [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ].
Dan Couper
@DanCouper
Nov 21 2016 07:22
Yeah, I can’t figure out why it isn’t working, I can’t see anything wrong with the code
I you manually write out each one it works, but the mapping fails
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:23
why is it weird? It is referring to the same array everytime
so the result is obvious
all those elements are the same array! :D
Dan Couper
@DanCouper
Nov 21 2016 07:24
[1,2,3].map(v =>) - v is either 1, 2, or 3. [1,2,3].map(v => [1,2,3].fill(v)) so [1,2,3].fill(1), then [1,2,3].fill(2), then [1,2,3].fill(3)
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:24
i.e. result[0] === result[1] === result[2]
Dan Couper
@DanCouper
Nov 21 2016 07:25
so each mapping should be [1,1,1], then [2,2,2] then [3,3,3]
but it is not
Markus Kiili
@Masd925
Nov 21 2016 07:25
@abhisekp Yes, each element is ===seqX because fill is a mutator method.
Dan Couper
@DanCouper
Nov 21 2016 07:25
ah crap
I forgot it mutated
Markus Kiili
@Masd925
Nov 21 2016 07:26
I have never used fill so did't notice it first.
Dan Couper
@DanCouper
Nov 21 2016 07:26
thanks @abhisekp and @Masd925
CamperBot
@camperbot
Nov 21 2016 07:26
dancouper sends brownie points to @abhisekp and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3174 | @abhisekp |http://www.freecodecamp.com/abhisekp
:star2: 2962 | @masd925 |http://www.freecodecamp.com/masd925
Dan Couper
@DanCouper
Nov 21 2016 07:28
sorry, extreme frustrations, edited
Patthamawadee Honetwichit
@puppyplub
Nov 21 2016 07:37
@grdseime Thank you for your reply. :) I reset my code and use "+" :+1: :sparkles:
CamperBot
@camperbot
Nov 21 2016 07:37
puppyplub sends brownie points to @grdseime :sparkles: :thumbsup: :sparkles:
:cookie: 196 | @grdseime |http://www.freecodecamp.com/grdseime
MoaadGit
@MoaadGit
Nov 21 2016 07:39

`
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort();

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

if(arr[i]<=num&&arr[i]+1>=num)
    return i+1;

}
return ;
}

getIndexToIns([40, 60], 50); `

what i'm missing here?
i need to return the index of the number when it should be placed
grdseime
@grdseime
Nov 21 2016 07:40
@puppyplub Thats great to hear!
MoaadGit
@MoaadGit
Nov 21 2016 07:40
update : return i;
@Masd925
Vidhi patel
@VidhiPatel5151
Nov 21 2016 07:47
@abhisekp no m talking about javascript i want to stored value in javascript
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:47
use an object @VidhiPatel5151
Markus Kiili
@Masd925
Nov 21 2016 07:47
@MoaadGit The default sort in not numerical sort.
devpaaji
@devpaaji
Nov 21 2016 07:47
var a = 1; 
function b() { 
    a = 10; 
    return; 
    function a() {} 
} 
b(); 
console.log(a);     // why 1 and not 10?
@Masd925 appreciate your reply
Ryan Ledford
@rledford
Nov 21 2016 07:48
@MoaadGit arr[i]+1 should be arr[i+1]
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:48
coz a is a function in the inner scope @devpaaji
devpaaji
@devpaaji
Nov 21 2016 07:49
ok so can you elaborate
when i change the return function to c
it logs 10
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:49
yes
Are you aware about hoisting? :flags:
devpaaji
@devpaaji
Nov 21 2016 07:49
yes but if you can explain here
it will be clearer
all functions and vars are taken to the top
before function execution
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:50
lets see what happens step by step
devpaaji
@devpaaji
Nov 21 2016 07:50
thanks
Ayush Bahuguna
@relentless-coder
Nov 21 2016 07:51
okay, going to ask again, I need help with this code, the replace statement is not working
function rot13(str) { // LBH QVQ VG!
  var arr = str.split(' ');
  console.log(arr);
  for(var i = 0; i < arr.length; i++) {
    for(var j = 0; j < arr[i].length; j++) {
      var charCode = arr[i].charCodeAt(j);
      var newCharCode = charCode - 13;
      console.log(charCode);
      arr[i].replace(arr[i].charAt(j), String.fromCharCode(newCharCode));

      console.log("new" + newCharCode);
    }
  }
  return arr.join(' ');
}
I can see in the console that the charCodes have changed, I even removed fromCharCode and instead used "A", but replace is not working.
Sonu kumar singh
@singhsonukumar6
Nov 21 2016 07:52
hey...i need a help....
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:53
@devpaaji In the global scope, first the compiler checks for any variable declarations and function declarations and remembers it in the global scope
ie. var a and function b are noted down
Sonu kumar singh
@singhsonukumar6
Nov 21 2016 07:53
i am not able to pass comparisons-with-the-logical-and-operator
devpaaji
@devpaaji
Nov 21 2016 07:54
@abhisekp so function b and var a are global
correct?
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:54
@devpaaji then in the line 1, a is assigned a value of 1
@devpaaji yes
devpaaji
@devpaaji
Nov 21 2016 07:55
ok
next
Sonu kumar singh
@singhsonukumar6
Nov 21 2016 07:55
function testLogicalAnd(val) {
  // Only change code below this line



  if (val<=50 && val>=25 ) {
    return "yes";
  }

  // Only change code above this line
  return "No";
}

// Change this value to test
testLogicalAnd(10);
this code seems right but it is giving error
Jeff Shapiro
@Jeff-Shapiro
Nov 21 2016 07:56
@abhisekp get join.me :)
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:56
@devpaaji then in line 7, function b is called.
But before execution, in the scope of function b, the compiler checks for any variables or function declared in the that scope and remembers it
devpaaji
@devpaaji
Nov 21 2016 07:57
you mean line 2
Abhisek Pattnaik
@abhisekp
Nov 21 2016 07:57
i.e. function a is declared in the scope of function b. Hence, it is noted
devpaaji
@devpaaji
Nov 21 2016 07:57
ok so before execution of b