These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Nov 2016
Aaron Bell
@awb715
Nov 17 2016 00:01
anyone up to twitch project?
Jay Kumar
@jaykch
Nov 17 2016 00:02
@awb715 what stage are you on? they suggest saving a json file instead of using the api so that your api key is not public
Diego Mayer
@Chrono79
Nov 17 2016 00:07
@ehutchllew Don't know if you still need an explanation on how that works, but that line call the function itself with a different argument each time (recursion) to go to the next nested level, I suggest you use the link I told you so you can see (it lets you run the program step by step)
Zaurbek Zhakupov
@zzhakupov
Nov 17 2016 00:08
Can someone pls explain how to solve
XMLHttpRequest cannot load https://wind-bow.hyperdev.space/twitch-api/streams/brunofin. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
this issue
Jay Kumar
@jaykch
Nov 17 2016 00:13
@Zooll8 you can only access the twitch API using jasonp
Somia ♡
@somiajagadish
Nov 17 2016 00:14
Help? ♡
Jay Kumar
@jaykch
Nov 17 2016 00:14
@somiajagadish with what?
Somia ♡
@somiajagadish
Nov 17 2016 00:14

Variables which are declared within a function, as well as the function parameters have local scope. That means, they are only visible within that function.

Here is a function myTest with a local variable called loc.

function myTest() {
  var loc = "foo";
  console.log(loc);
}
myTest(); // "foo"
console.log(loc); // "undefined"

loc is not defined outside of the function.
Instructions

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

Hint
Refreshing the page may help if you get stuck.

Aaron
@apalm1341
Nov 17 2016 00:14
Someone who is really good with using Gimp plz send me private message thx
Somia ♡
@somiajagadish
Nov 17 2016 00:15

function myLocalScope() {
'use strict';

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

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

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

Stephen James
@sjames1958gm
Nov 17 2016 00:15
@somiajagadish define myVar inside the function using var similar to loc in the example
Jay Kumar
@jaykch
Nov 17 2016 00:16
@somiajagadish use strict should be in global scope outside your function and what ^ guy said
Aaron Bell
@awb715
Nov 17 2016 00:16
working on my twitch.tv
design is horrible but functionality is coming along
Somia ♡
@somiajagadish
Nov 17 2016 00:18
I domnt Understand
*dont
Jan
@burning-monk
Nov 17 2016 00:19
what do you mean you don't understand
Somia ♡
@somiajagadish
Nov 17 2016 00:19
I dont understad what they are telling me
Jay Kumar
@jaykch
Nov 17 2016 00:19

@somiajagadish function myLocalScope() {
'use strict';
// you need to define a variable here

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

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

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

Caden Damiano
@cdomiano
Nov 17 2016 00:19
'''
CamperBot
@camperbot
Nov 17 2016 00:20
:bulb: to format code use backticks! ``` more info
Ryan Doner
@rdoner
Nov 17 2016 00:20

I'm totally stuck on a simple challenge. Will someone tell me what I'm doing wrong? // Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

Ardis Petermans
@Ardis101
Nov 17 2016 00:20

whats wrong here? // Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var myTotal =0;

for (var i = 0; i < myArr.length; i++) {
myTotal += myArr[i];
}

Caden Damiano
@cdomiano
Nov 17 2016 00:21
function repeatStringNumTimes(str, num) {
  if (num > 0) {
    str.repeat(num);
    return str;
  }
  else if (num < 0){
    return '';
  }

  //return str;
}

repeatStringNumTimes("abc", 3);
I'm using the right method to repeat abc but it doesn't do it. Looking for a second opinion.
Somia ♡
@somiajagadish
Nov 17 2016 00:21
did u add the myStr = "Hello World" @rdoner
Caden Damiano
@cdomiano
Nov 17 2016 00:21
The idea is that you return a blank string if it is below zero
Somia ♡
@somiajagadish
Nov 17 2016 00:22
I have that @jaykch
Jay Kumar
@jaykch
Nov 17 2016 00:22
@cdomiano str = str.repeat(num);
Ryan Doner
@rdoner
Nov 17 2016 00:22
@somiajagadish yes I did. still won't work :/
Walid Ashri
@walidashri
Nov 17 2016 00:22
@cdomiano this linestr.repeat(num); doesn't modify the str
Somia ♡
@somiajagadish
Nov 17 2016 00:23
Try deleting that part
LydaTech
@lydatech
Nov 17 2016 00:23
Code School is having a free weekend. Be sure to sign up before friday. https://www.codeschool.com/free-weekend
Somia ♡
@somiajagadish
Nov 17 2016 00:23
@rdoner
Jay Kumar
@jaykch
Nov 17 2016 00:23
@cdomiano you need to save the str before returning it
Somia ♡
@somiajagadish
Nov 17 2016 00:23
@rdoner can you copy and paste it again
Walid Ashri
@walidashri
Nov 17 2016 00:24
@lydatech thanks
CamperBot
@camperbot
Nov 17 2016 00:24
walidashri sends brownie points to @lydatech :sparkles: :thumbsup: :sparkles:
Ryan Doner
@rdoner
Nov 17 2016 00:24

@somiajagadish // Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

CamperBot
@camperbot
Nov 17 2016 00:24
:star2: 1463 | @lydatech |http://www.freecodecamp.com/lydatech
Somia ♡
@somiajagadish
Nov 17 2016 00:24
and tell me the name of the challenge
Caden Damiano
@cdomiano
Nov 17 2016 00:24
Thanks @jaykch That worked. SO that was because I need to modify the original string first? So my original line was just a modifier?
CamperBot
@camperbot
Nov 17 2016 00:24
cdomiano sends brownie points to @jaykch :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @jaykch |http://www.freecodecamp.com/jaykch
Ryan Doner
@rdoner
Nov 17 2016 00:24
@somiajagadish Understanding string immutability
Walid Ashri
@walidashri
Nov 17 2016 00:24
@rdoner remove last line
Somia ♡
@somiajagadish
Nov 17 2016 00:24
@rdoner okay let me check mine
Jay Kumar
@jaykch
Nov 17 2016 00:24

@somiajagadish
function myLocalScope() {
var myVar = "test";

}
myLocalScope();

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

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

Ryan Doner
@rdoner
Nov 17 2016 00:25
@walidashri thanks!
CamperBot
@camperbot
Nov 17 2016 00:25
rdoner sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 647 | @walidashri |http://www.freecodecamp.com/walidashri
Ryan Doner
@rdoner
Nov 17 2016 00:25
@somiajagadish thanks for the help too!
CamperBot
@camperbot
Nov 17 2016 00:25
rdoner sends brownie points to @somiajagadish :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for somiajagadish
Somia ♡
@somiajagadish
Nov 17 2016 00:26

@rdoner // Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me

It should look likt this :)
*like
Your welcome :)
Walid Ashri
@walidashri
Nov 17 2016 00:26

@jaykch

function myLocalScope() {
  'use strict';


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

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

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

this is the start code

Jenky W. Nolasco
@jenkynolasco11
Nov 17 2016 00:27
Hello world o/
CamperBot
@camperbot
Nov 17 2016 00:27

welcome to FreeCodeCamp @jenkynolasco11!

Jay Kumar
@jaykch
Nov 17 2016 00:27

@cdomiano in javascript only a certain methods save the variable like shift() pop()
but when you ran str.repeat(x) it returned a string with str repeated x times
but you did not save this new string anywhere so it just disappeared

when you called return str; it exits your function and returns the current value of str which is still the same as before, hence you need to save it before returning it

Johnny
@JohnnyBizzel
Nov 17 2016 00:27
@jenkynolasco11 Hi
Somia ♡
@somiajagadish
Nov 17 2016 00:28
I need help
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.
Jenky W. Nolasco
@jenkynolasco11
Nov 17 2016 00:28
@somiajagadish what do you need help with?
Jay Kumar
@jaykch
Nov 17 2016 00:28
@somiajagadish remove the console log then it will work
Somia ♡
@somiajagadish
Nov 17 2016 00:29

function myLocalScope() {
'use strict';

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

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

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

This is my code :)
Johnny
@JohnnyBizzel
Nov 17 2016 00:30
@somiajagadish where is myVar declared?
Somia ♡
@somiajagadish
Nov 17 2016 00:31
I dont know :(
in the console :/
Johnny
@JohnnyBizzel
Nov 17 2016 00:31
@somiajagadish Does it need declaring? What's the instructions?
Jay Kumar
@jaykch
Nov 17 2016 00:31

@somiajagadish
function myLocalScope() {
var my|Var = 0;

}
myLocalScope();

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

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

@somiajagadish try removing the console log statementsor just paste this
Johnny
@JohnnyBizzel
Nov 17 2016 00:33
@somiajagadish but var my|Var = 0; should be var myVar = 0;
Somia ♡
@somiajagadish
Nov 17 2016 00:35

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

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

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

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

Like this?
Jay Kumar
@jaykch
Nov 17 2016 00:36
@somiajagadish yes but remove the console log statements to complete
Somia ♡
@somiajagadish
Nov 17 2016 00:37
So delte the console
gabi
@gikwu1
Nov 17 2016 00:38
hello everyone
Somia ♡
@somiajagadish
Nov 17 2016 00:38
I did it!! Thank you :)
gabi
@gikwu1
Nov 17 2016 00:38
i'm stuck here

// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line
processArg(7);
Somia ♡
@somiajagadish
Nov 17 2016 00:38
@gikwu1 Hi
gabi
@gikwu1
Nov 17 2016 00:39
can anyone help?
Chris
@cuorediargento
Nov 17 2016 00:39
Hi folks!
gabi
@gikwu1
Nov 17 2016 00:39
how do i assign processArg to processed?
Chris
@cuorediargento
Nov 17 2016 00:39
I'm having an issue with the weather app project. Anyone care to look at my js code?
Walid Ashri
@walidashri
Nov 17 2016 00:40
@gikwu1 do the same as this line changed = change(10);
@cuorediargento what is the issue?
Johnny
@JohnnyBizzel
Nov 17 2016 00:40
@gikwu1 processed = processArg(7);
Jay Kumar
@jaykch
Nov 17 2016 00:40
@gikwu1 processed = processArg(7);
Walid Ashri
@walidashri
Nov 17 2016 00:40
@JohnnyBizzel :clap:
Alwaysonthemove1
@Alwaysonthemove1
Nov 17 2016 00:40
Ok im having problems with return pattern for functions part... Can someone help with that lesson??
Chris
@cuorediargento
Nov 17 2016 00:40
I can't seem to get the API link to populate with geolocation info.
Johnny
@JohnnyBizzel
Nov 17 2016 00:41
@cuorediargento Can't see your code
Walid Ashri
@walidashri
Nov 17 2016 00:41
@cuorediargento CORS
Johnny
@JohnnyBizzel
Nov 17 2016 00:41
@walidashri Morning ;)
Justin Pierson
@jpmitchellpierson
Nov 17 2016 00:41
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.
  Math.floor(Math.random() * 10);
  return Math.floor();
}
trying to generate a whole number between 0 and 9
Chris
@cuorediargento
Nov 17 2016 00:41
jQuery(document).ready(function($) {      
      $.get('http://api.openweathermap.org/data/2.5/weather?zip=87110&APPID=e4e1f6f6a7743da94f54ab3a1970b993')
       .done(function(response) {
          $('#temperature span').html(response.main.temp);
          $('#location span').html(response.name);
          $('#icon span').html(response.weather[0].icon);
          $('#humidity span').html(response.main.humidity);
          $('#wind span').html(response.wind.speed);
          $('#direction span').html(response.wind.deg);
          console.log(response);
       })
       .fail(function() {
          alert('An error occurred while fetching the weather.');
       });
     });
gabi
@gikwu1
Nov 17 2016 00:41
thank u @JohnnyBizzel
CamperBot
@camperbot
Nov 17 2016 00:41
gikwu1 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 827 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 17 2016 00:41
@gikwu1 :)
Chris
@cuorediargento
Nov 17 2016 00:42
I've also tried calling the geolocation and setting variables for lat and lon into the link.
Johnny
@JohnnyBizzel
Nov 17 2016 00:42
@cuorediargento Try using another API to look up the IP address.
J. Victor
@J-Victorsantos
Nov 17 2016 00:42

Why it keeps showing product = 1 in console?

'''

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

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

CamperBot
@camperbot
Nov 17 2016 00:42
:bulb: to format code use backticks! ``` more info
Chris
@cuorediargento
Nov 17 2016 00:43
@JohnnyBizzel I'll give that a try. Thank you!
CamperBot
@camperbot
Nov 17 2016 00:43
cuorediargento sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 828 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Justin Pierson
@jpmitchellpierson
Nov 17 2016 00:43
nvmd I got it
Jenky W. Nolasco
@jenkynolasco11
Nov 17 2016 00:43
@cuorediargento try with https://api.openweathermap.org/data/2.5/weather?zip=87110&APPID=e4e1f6f6a7743da94f54ab3a1970b993
J. Victor
@J-Victorsantos
Nov 17 2016 00:44
Why it keeps showing product = 1 in console?

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Walid Ashri
@walidashri
Nov 17 2016 00:44
@cuorediargento it's working with me
@J-Victorsantos cause arr.length is 0
Chris
@cuorediargento
Nov 17 2016 00:45
@walidashri I keep getting my error message.
Walid Ashri
@walidashri
Nov 17 2016 00:45
@cuorediargento which is?
Johnny
@JohnnyBizzel
Nov 17 2016 00:46
@cuorediargento Buena suerte ;)
J. Victor
@J-Victorsantos
Nov 17 2016 00:46
@walidashri thx
CamperBot
@camperbot
Nov 17 2016 00:46
j-victorsantos sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 648 | @walidashri |http://www.freecodecamp.com/walidashri
Chris
@cuorediargento
Nov 17 2016 00:46
@walidashri Sorry, the one that @jenkynolasco11 suggested I try. I don't get anything from my original link.
Walid Ashri
@walidashri
Nov 17 2016 00:46
@JohnnyBizzel No haplo Mexicas
Johnny
@JohnnyBizzel
Nov 17 2016 00:47
he he
Joe Narvaez
@wordyallen
Nov 17 2016 00:47
jiji
Walid Ashri
@walidashri
Nov 17 2016 00:47
@cuorediargento this link works http://api.openweathermap.org/data/2.5/weather?zip=87110&APPID=e4e1f6f6a7743da94f54ab3a1970b993
Ian Duke
@1andee
Nov 17 2016 00:48
Question regarding practical use of something... NOT a code review.. anyone up for it?
Jay Kumar
@jaykch
Nov 17 2016 00:49
@ianduke what is it?
Chris
@cuorediargento
Nov 17 2016 00:49
@walidashri I'm not getting any weather info back. Is there something aside from the link that I am missing? Did you do any geolocation APIs?
Jay Kumar
@jaykch
Nov 17 2016 00:49
@cuorediargento have you tried putting the link in your browser, if so what data do you get?
DarkPatrick00
@DarkPatrick00
Nov 17 2016 00:50

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

1andee @ianduke 1andee
Walid Ashri
@walidashri
Nov 17 2016 00:50
@cuorediargento just tried ur code in codepen with no modifications works fine
Ian Duke
@1andee
Nov 17 2016 00:51
@jaykch What is the practical use of iterating through an array, via map method?
Chris
@cuorediargento
Nov 17 2016 00:51
@jaykch I just did for the first time. It's giving me the info, but for Albuquerque, which is nowhere near me.
@walidashri Alright, thank you!
CamperBot
@camperbot
Nov 17 2016 00:51
cuorediargento sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 649 | @walidashri |http://www.freecodecamp.com/walidashri
Walid Ashri
@walidashri
Nov 17 2016 00:52
@cuorediargento this is hard coding api call always give info for Albuquerque
Ian Duke
@1andee
Nov 17 2016 00:53
@jaykch it seems purely mathematical?
Chris
@cuorediargento
Nov 17 2016 00:54
@walidashri That's good to know. I'm going to play around with IP APIs and try some more. As long as I know the rest of my code is working. :smile:
Jay Kumar
@jaykch
Nov 17 2016 00:54
@ianduke you can add properties to array elements using map let's say you had IDs in the array from 1-10, you can then make them so 1: "data", 2: "datA" that's the only time I use map
Walid Ashri
@walidashri
Nov 17 2016 00:54
@cuorediargento :+1:
gabi
@gikwu1
Nov 17 2016 00:55

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));
what am i supposed to do here?
DarkPatrick00
@DarkPatrick00
Nov 17 2016 00:55

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

What do I do here? Im so confused
gabi
@gikwu1
Nov 17 2016 00:56
welcome to the club @DarkPatrick00
DarkPatrick00
@DarkPatrick00
Nov 17 2016 00:56
lol
Ian Duke
@1andee
Nov 17 2016 00:56
@jaykch thanks for the explanation Jay. Appreciate it. Here's some brownie points.
CamperBot
@camperbot
Nov 17 2016 00:56
ianduke sends brownie points to @jaykch :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @jaykch |http://www.freecodecamp.com/jaykch
gabi
@gikwu1
Nov 17 2016 00:56
can anyone help us out?
Walid Ashri
@walidashri
Nov 17 2016 00:57
@DarkPatrick00 @gikwu1 push() shift() use those methods :)
DarkPatrick00
@DarkPatrick00
Nov 17 2016 00:57
ty
gabi
@gikwu1
Nov 17 2016 00:57
@DarkPatrick00 do u understand where to use them?
DarkPatrick00
@DarkPatrick00
Nov 17 2016 00:57
going to play with it
gabi
@gikwu1
Nov 17 2016 00:58
ok
Jay Kumar
@jaykch
Nov 17 2016 00:58
@ianduke no worries, you should check the w3schools article about it, but there is not a lot map can do that filter and reduce can't so it's only personal preference
Walid Ashri
@walidashri
Nov 17 2016 00:58
@gikwu1 read the instructions carefully and you'll get it gl
Ian Duke
@1andee
Nov 17 2016 00:58
@jaykch awesome. have it open now. cheers.
gabi
@gikwu1
Nov 17 2016 00:59
@walidashri i did read the instructions but i came here because i didnt understand it well. hence my request for help
DarkPatrick00
@DarkPatrick00
Nov 17 2016 00:59
lol same
ANormalSoundingName
@ANormalSoundingName
Nov 17 2016 01:00

Hi I'm not sure what's going wrong with my code here. I'm doing local scope and functions. ```
function myLocalScope() {
'use strict';

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

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

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

andry91959
@andry91959
Nov 17 2016 01:00
hi Im trying to do the exercise "testing Object for properties" but I'm stuck. Can someone help me this is my current code

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
var hasOwnProperty;
checkProp=myObj.hasOwnProperty("gift");
return hasOwnProperty;
}

// Test your code by modifying these values
checkObj("gift");

ANormalSoundingName
@ANormalSoundingName
Nov 17 2016 01:00
It's still saying myVar is not defined
Jordy weerwag
@TheCodeWriter1
Nov 17 2016 01:00
help plz on my codepen does 1 social link not work is shoed be displaying a logo of codepen but is not there
CamperBot
@camperbot
Nov 17 2016 01:00
no wiki entry for: plz on my codepen does 1 social link not work is shoed be displaying a logo of codepen but is not there
gabi
@gikwu1
Nov 17 2016 01:01
@DarkPatrick00 did u get anything done?
andry91959
@andry91959
Nov 17 2016 01:01
It seems very simple but Im stuck
DarkPatrick00
@DarkPatrick00
Nov 17 2016 01:02
No lol
Im looking at the two lessons again
But not sure where to put it
andry91959
@andry91959
Nov 17 2016 01:03

@andry91959
hi Im trying to do the exercise "testing Object for properties" but I'm stuck. Can someone help me this is my current code
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
var hasOwnProperty;
checkProp=myObj.hasOwnProperty("gift");
return hasOwnProperty;
}

// Test your code by modifying these values
checkObj("gift");

Ian Duke
@1andee
Nov 17 2016 01:04
@TheCodeWriter1 Jordy - You should update your FontAwesome external CSS to the latest version 4.7
@TheCodeWriter1 It works if you use the following FontAwesome link: https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css
Aaron
@apalm1341
Nov 17 2016 01:06
hey al
all
someone who is good with gimp plz send me private message thx
having issues
CamperBot
@camperbot
Nov 17 2016 01:06
sorry apalm1341, you can't send brownie points to yourself! :sparkles: :sparkles:
gabi
@gikwu1
Nov 17 2016 01:07
anyone?
helop?
help
andry91959
@andry91959
Nov 17 2016 01:08
Hi I'm stuch at testing object for properties can someone help

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here

checkProp=myObj.hasOwnProperty();
}

// Test your code by modifying these values
checkObj("gift");

Jordy weerwag
@TheCodeWriter1
Nov 17 2016 01:09
oke thanks @ianduke
CamperBot
@camperbot
Nov 17 2016 01:09
thecodewriter1 sends brownie points to @ianduke :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ianduke
AlphaKevy
@AlphaKevy
Nov 17 2016 01:09

BonFire Challenge: Factorialize a Number

For some reason my code returns the correct value to the console but the answer isn't being marked as correct. Could anyone steer me in the direction as to why that's happening?

Thanks so much,
K

var factorial = [];

function factorialize(num) {
for (i = num; i>0; i--){
  factorial.push(i);
}
  return factorial.reduce(function(a,b){
    return a*b;
  },1);
}

factorialize(5);
CamperBot
@camperbot
Nov 17 2016 01:09
Sorry, can't find a bonfire called challenge factorialize a numberfor some reason my code returns the correct value to the console but the answer isnt being marked as correct could anyone steer me in the direction as to why thats happeningthanks so muchkvar factorial function factorializenum for i num i0 i-- factorialpushi return factorialreducefunctionab return ab 1factorialize5. [ Check the map? ]
Margaret
@Margaret2
Nov 17 2016 01:09
@andry91959 you have to check whether you object has the property "checkProp", not assign a new value to checkProp
Ian Duke
@1andee
Nov 17 2016 01:10
@TheCodeWriter1 You're most welcome!
Walid Ashri
@walidashri
Nov 17 2016 01:10
@gikwu1 @DarkPatrick00
arr.push(item)
var returned= arr.shift()
Lanova
@Lanova
Nov 17 2016 01:11

Hi everyone I have a troble with filters
Use filter to create a new array with all the values from oldArray which are less than 6. The oldArray should not change.

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

oldArray = oldArray.filter(function(val) {
return val <6;
});
var newArray = oldArray;
but You should not change the original array.

Nyan9
@NyanNaing
Nov 17 2016 01:11
Walid Ashri
@walidashri
Nov 17 2016 01:11
@AlphaKevy add factorial inside the function
AlphaKevy
@AlphaKevy
Nov 17 2016 01:12
Gah @walidashri , I knew it had to be something simple! Thanks so much!
CamperBot
@camperbot
Nov 17 2016 01:12
alphakevy sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 650 | @walidashri |http://www.freecodecamp.com/walidashri
andry91959
@andry91959
Nov 17 2016 01:12
@Margaret2 Um how do we know that the object has the property?
Nyan9
@NyanNaing
Nov 17 2016 01:12
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // 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));
so I solved it but I don't know what the hell just happened lol HELP :P
Walid Ashri
@walidashri
Nov 17 2016 01:12
@Lanova var newArray = oldArray.filter(function(val) { return val <6; });
Margaret
@Margaret2
Nov 17 2016 01:13
Object.hasOwnProperty(property) @andry91959
@andry91959 the property you are checking for is checkProp, therefore it should go inside the parentheses
Ian Duke
@1andee
Nov 17 2016 01:13
@NyanNaing You used the shift() method on your array. This removes the first element.
siaxiong
@siaxiong
Nov 17 2016 01:14
@NyanNaing that not how you write the code
the .shift() should be next to return
Aaron
@apalm1341
Nov 17 2016 01:14
hey all
if someone is good with gimp...would appreciate help
andry91959
@andry91959
Nov 17 2016 01:15

@Margaret2 // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here

myObj.hasOwnProperty(checkProp);
}

// Test your code by modifying these values
checkObj("gift");

siaxiong
@siaxiong
Nov 17 2016 01:15
but i understand what you did i did it before
Nyan9
@NyanNaing
Nov 17 2016 01:15
@1andee i see
Aaron
@apalm1341
Nov 17 2016 01:15
no one has been able to figure it out yet
plz
andry91959
@andry91959
Nov 17 2016 01:15
@Margaret2 like that?
Nyan9
@NyanNaing
Nov 17 2016 01:15
@siaxiong oh i can just return it like that ?
siaxiong
@siaxiong
Nov 17 2016 01:15
yeah
Margaret
@Margaret2
Nov 17 2016 01:16
@andry91959 right, and that function will return true or false...
so you have to return the value if it's true, and "Not Found" if it's false
Nicola Scaramuzzo
@muzzotech
Nov 17 2016 01:16
I'm stuck on the Steamroller problem. I don't know where to begin. How do I push each item into a new array without it just transferring everything as is.
Nyan9
@NyanNaing
Nov 17 2016 01:16
@siaxiong
function nextInLine(arr, item) {
  arr.push(item);
  return arr.shift(); 
}
siaxiong
@siaxiong
Nov 17 2016 01:17
did it work?
Nyan9
@NyanNaing
Nov 17 2016 01:17
@siaxiong yes it did. I just wanted to make sure I wrote the code right. THANK YOU SO MUCH!
CamperBot
@camperbot
Nov 17 2016 01:17
nyannaing sends brownie points to @siaxiong :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for siaxiong
andry91959
@andry91959
Nov 17 2016 01:17
@Margaret2 do we need to put variable for the return?
siaxiong
@siaxiong
Nov 17 2016 01:17
@NyanNaing no problem. happy to help
Lanova
@Lanova
Nov 17 2016 01:17
@walidashri thank you
CamperBot
@camperbot
Nov 17 2016 01:17
lanova sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 651 | @walidashri |http://www.freecodecamp.com/walidashri
Caden Damiano
@cdomiano
Nov 17 2016 01:18

function truncateString(str, num) {
  var newStr = '';

  if (str.length > num) {
    newStr = str.slice(0, num-3) + '...';
    return newStr;
  }
    return str;

}

truncateString("A-", 1);
andry91959
@andry91959
Nov 17 2016 01:18
@Margaret2 I am not sure what to put on return
Caden Damiano
@cdomiano
Nov 17 2016 01:18
Something is missing in this code because it isn't passing
Margaret
@Margaret2
Nov 17 2016 01:18
@andry91959 you have to return the value found at the given property
you have to use bracket notation
to get the value out of the object
andry91959
@andry91959
Nov 17 2016 01:19
@Margaret2 so I do this but It doesnt return "true" for the true answer

@Margaret2 // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty(checkProp);
return "Not Found";
}

// Test your code by modifying these values
checkObj("pony");

Nicola Scaramuzzo
@muzzotech
Nov 17 2016 01:19
function steamrollArray(arr) {
  // I'm a steamroller, baby
  var arr2 = [];
  for(var i = 0; i < arr.length; i++){
    if(arr[i]) {
      arr2.push(arr[i]);
    }
  }
  return arr2;
}

steamrollArray([1, [2], [3, [[4]]]]);
Margaret
@Margaret2
Nov 17 2016 01:20
if (myObj.hasOwnProperty(checkProp)) @andry91959 use an if statement, return one thing if true, another if false
Jan
@burning-monk
Nov 17 2016 01:22
@muzzotech which challenge
chunnali
@chunnali
Nov 17 2016 01:22
can anyone that has done the wiki viewer challenge help me out?
gabi
@gikwu1
Nov 17 2016 01:22
hello, can anyonenhelp me, i'm stuck
Aaron
@apalm1341
Nov 17 2016 01:22
hey all
anyone good with gimp here?
need help
plz
siaxiong
@siaxiong
Nov 17 2016 01:23
bruh it nnot the place for gimp
gabi
@gikwu1
Nov 17 2016 01:23
@siaxiong , can u help me , i'm stuck on this challenge

function nextInLine(arr, item) {
  // Your code here
  arr.shift(2);
  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));
Margaret
@Margaret2
Nov 17 2016 01:24
@cdomiano basically all you have is a single option for what happens if the string is longer than num. You need to have other option(s) for what happens when the string is shorter than or equal to num
siaxiong
@siaxiong
Nov 17 2016 01:24
@gikwu1 you forgot the .push()
.shift() should be next to return
Caden Damiano
@cdomiano
Nov 17 2016 01:25

function truncateString(str, num) {
  var newStr = '';

  if (str.length > num) {
    newStr = str.slice(0, num-3) + '...';
    return newStr;
  } else if (str.length <= 3) {
    newStr = str.slice(0,num-1) + '...';
    return newStr;
  }
    return str;

}

truncateString("A-", 1);
Actually I think this better. Any thoughts?
@Margaret2 How does the new one look?
its asking me to return 'a...'
andry91959
@andry91959
Nov 17 2016 01:26
@Margaret2 I think I did it wrong

@Margaret2 // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return "true";
}
else {
return "Not Found";
}
}

// Test your code by modifying these values
checkObj("kitten");

Margaret
@Margaret2
Nov 17 2016 01:26
@cdomiano the structure looks good, just play around with where you're slicing the string
Caden Damiano
@cdomiano
Nov 17 2016 01:27
ok @Margaret2
Margaret
@Margaret2
Nov 17 2016 01:27
@andry91959 you're close! instead of "true" you need to use bracket notation to return the value at the given property
Nicola Scaramuzzo
@muzzotech
Nov 17 2016 01:29
I've tried pushing the elements into a new array, but it doesn't flatten it.
Can anyone help?
function steamrollArray(arr) {
  // I'm a steamroller, baby
  var arr2 = [];
  for(var i = 0; i < arr.length; i++){
    if(arr[i]) {
      arr2.push(arr[i]);
    }
  }
  return arr2;
}

steamrollArray([1, [2], [3, [[4]]]]);
Margaret
@Margaret2
Nov 17 2016 01:33
@cdomiano btw, in my solution, my if statement basically has three options :
if the str is less than the num
else if the num is <= 3
else (everything else)
Vlad Onofrei
@vladonof
Nov 17 2016 01:34
Hello, quick question. Can one convert a chrome extension to safari?
Margaret
@Margaret2
Nov 17 2016 01:35
@muzzotech
  • check if arr[i] is an array
  • if it is, call the steamrollArray() function on it
  • else, push it to arr2
andry91959
@andry91959
Nov 17 2016 01:35

@Margaret2 // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("kitten");

I found it correct
@Margaret2 but I dont understand why do we need to use "return myObj[checkProp];"
Margaret
@Margaret2
Nov 17 2016 01:37
because the instructions say, " If the property is found, return that property's value." and that's how you get the value out of the object @andry91959
Nicola Scaramuzzo
@muzzotech
Nov 17 2016 01:38
@Margaret2 how can I call the steamrollArray function if I don't have one. I mean that if arr[i].isArray, then what can I do to push that value into the new array
Margaret
@Margaret2
Nov 17 2016 01:38
object's are pairs of keys (aka properties) and values, so when you do object[property] it will give you the value @andry91959
@muzzotech you steamrollArray it :D and yes, you use your function inside itself. It is called recursion, that's what they're trying to teach you here :joy: :joy: it's weird, i know
andry91959
@andry91959
Nov 17 2016 01:39
@Margaret2 I think I get it so [] to return the value of the obj which is "true" is that correct?
Margaret
@Margaret2
Nov 17 2016 01:41
yeah - specifically, getting the value is what you do once the if (obj.hasOwnProperty()) returns true
Diane
@106Ch213
Nov 17 2016 01:41
Hello folks! Does anyone know why I get the "array[i].join is not a function" error? I'm trying to return the longest word of a string.
`function findLongestWord(str) {

  var array = [];
  var longestString = "";

  array = array.push(str);
  array = str.split(' ');

  longestString = array[0];
  for (i = 1; i < array.length; i++)
  {    
    if (array[i].length > array[i - 1].length){
      longestString = array[i].join('');
    }
  }

  return longestString.length;
}
Moisés Man
@moigithub
Nov 17 2016 01:42
join is an array method
soo.... probably array[i] doesnt contain an array value
Margaret
@Margaret2
Nov 17 2016 01:43
@106Ch213 right, join has to be used on an array, so unless array[i] is an array, it won't work
Diane
@106Ch213
Nov 17 2016 01:43
Ohh I see, haven't got used to that yet. Thanks @moigithub @Margaret2
CamperBot
@camperbot
Nov 17 2016 01:43
106ch213 sends brownie points to @moigithub and @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 461 | @margaret2 |http://www.freecodecamp.com/margaret2
:star2: 2192 | @moigithub |http://www.freecodecamp.com/moigithub
Margaret
@Margaret2
Nov 17 2016 01:44
@106Ch213 in this situation, you probably do not need join, just get array[i] :)
Moisés Man
@moigithub
Nov 17 2016 01:45
also ur if condition need to fix/change
Diane
@106Ch213
Nov 17 2016 01:46
@Margaret2 Ok I'll try that, I thought I needed to change the array back into a string to get the proper length of the word. Maybe I skipped a step haha
@moigithub what can I improve?
Moisés Man
@moigithub
Nov 17 2016 01:48
u comparing the "current" vs "previous" word ..
but should compare current.. vs the largest/biggest word u previouslly have stored
Diane
@106Ch213
Nov 17 2016 01:48
Oh yes! Thanks !
Caden Damiano
@cdomiano
Nov 17 2016 01:51

function truncateString(str, num) {
  var newStr = '';

  if (str.length > num) {
    newStr = str.slice(0, num-3) + '...';
    return newStr;
  } else if (str.length <= 3) {
    newStr = str.slice(0, -num) + '...';
    return newStr;
  } else{ 
    return str;
  }


}

truncateString("A-", 1);
@Margaret2 So in my else if statement I am trying to take the num argument off the str argument. I'm still tweaking with it but I want to know I have the right idea.
Stephen James
@sjames1958gm
Nov 17 2016 01:53
@cdomiano compare num to 3 not str.length
Margaret
@Margaret2
Nov 17 2016 01:53
^^ what he said, also, I think you can just use num, not -num
Caden Damiano
@cdomiano
Nov 17 2016 01:54

function truncateString(str, num) {
  var newStr = '';

  if (str.length > num) {
    newStr = str.slice(0, num-3) + '...';
    return newStr;
  } else if (num <= 3) {
    newStr = str.slice(0, num) + '...';
    return newStr;
  } else{ 
    return str;
  }


}

truncateString("A-", 1);
Like this?
TheLostWarrior
@TheLostWarrior
Nov 17 2016 01:55
okay i'm stuck on something that should be very basic, i think its just something tedious with the problem but i'm doing the Escape Sequences in Strings and for some reason its not working my code is var myStr = "First\tLine\n\"Second\tLine\"\rThird\tLine";
MoNag1
@MoNag1
Nov 17 2016 01:55
@TheLostWarrior you must escape the \n and \r themselves
Stephen James
@sjames1958gm
Nov 17 2016 01:56
@TheLostWarrior There are only 4 escape sequences in the result as indicated by newline, backslash, backslash and carriage-return
Margaret
@Margaret2
Nov 17 2016 01:57
@cdomiano looks good, does it work
MoNag1
@MoNag1
Nov 17 2016 01:58
when it says newline backlash, they mean new line, which is \n followed by backlash, which is \\. Apply the same logic for the second set @TheLostWarrior
Caden Damiano
@cdomiano
Nov 17 2016 01:58
@Margaret2 not yet, I'm going to double check the instructions...
c0d0er
@c0d0er
Nov 17 2016 01:58
@0x0936 thanks
CamperBot
@camperbot
Nov 17 2016 01:58
c0d0er sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1899 | @0x0936 |http://www.freecodecamp.com/0x0936
Margaret
@Margaret2
Nov 17 2016 01:58
@cdomiano also which specific tests are failing
Caden Damiano
@cdomiano
Nov 17 2016 01:59

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

@Margaret2 I think I have to compare length to num but it doesn't pass still. It fails...
Margaret
@Margaret2
Nov 17 2016 01:59
yeah, i know the instructions, but which examples are failing
Caden Damiano
@cdomiano
Nov 17 2016 02:00
truncateString("A-", 1) should return "A...".
truncateString("Absolutely Longer", 2) should return "Ab...".
Margaret
@Margaret2
Nov 17 2016 02:00
so the problem must be with the num <= 3 section
oh i know, nothing even gets to the num <= 3 section because the string length is still larger than num...
so what you need to do is switch the first and third statements, first check if the string is <= num
@cdomiano
Aaron Bell
@awb715
Nov 17 2016 02:03
anyone working on twtich?
He Liu
@HeLiu
Nov 17 2016 02:04
@awb715 hey aaron
i remember you saying you were at hack reactor
are you going to be there next weds?
the ny campus
Aaron Bell
@awb715
Nov 17 2016 02:05
forthe tour?
@HeLiu
He Liu
@HeLiu
Nov 17 2016 02:05
tour? no they have a free class every now and then
Aaron Bell
@awb715
Nov 17 2016 02:05
ooo
He Liu
@HeLiu
Nov 17 2016 02:05
they already had two
Aaron Bell
@awb715
Nov 17 2016 02:05
gonna be in florida
He Liu
@HeLiu
Nov 17 2016 02:05
but they were on conditionals
and easy stuff
this one is gonna be on higher order functions
so i wanna go
oh
that sucks
Aaron Bell
@awb715
Nov 17 2016 02:06
true
what im working on at the moment is complex
Margaret
@Margaret2
Nov 17 2016 02:06
:sunglasses: :palm_tree: :dolphin: florida is the best
Aaron Bell
@awb715
Nov 17 2016 02:06
im trying to filter online and offline channels
He Liu
@HeLiu
Nov 17 2016 02:06
oh yea ;)?
that is pretty complex
Caden Damiano
@cdomiano
Nov 17 2016 02:06
@Margaret2 Sooo close! truncateString("A-", 1) should return "A..." passed but it failed a couple other tests. Here's the code:
```
Aaron Bell
@awb715
Nov 17 2016 02:07
yea im like filtering while iterating through an array
i cant figure it out but i hope too soon
Caden Damiano
@cdomiano
Nov 17 2016 02:07

function truncateString(str, num) {
  var newStr = '';

 if (str.length <= 3) {
    newStr = str.slice(0, num) + '...';
    return newStr;
  } else if(str.length > num) {
    newStr = str.slice(0, num-3) + '...';
    return newStr;
  }


}

truncateString("A-", 1);
@Margaret2
c0d0er
@c0d0er
Nov 17 2016 02:08
@toianw thanks
CamperBot
@camperbot
Nov 17 2016 02:08
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 424 | @toianw |http://www.freecodecamp.com/toianw
Aaron Bell
@awb715
Nov 17 2016 02:08
im like altering an input dependent upon the outputs
Margaret
@Margaret2
Nov 17 2016 02:09

ok, when str <= 3, you just return the string, right?
then you have this part:

else if (num <= 3) {
      return str.slice(0,num)+"...";
}

@cdomiano

@cdomiano and finally you have this part last
else {
return str.slice(0, num-3) + '...';
}
that's what i meant when i said switch the first and third parts
Zaurbek Zhakupov
@zzhakupov
Nov 17 2016 02:11
Guys can I have some feedback on my TWITCH API https://codepen.io/Zooll/pen/JbXzXR
Aaron Bell
@awb715
Nov 17 2016 02:12
@Zooll8 better design then me!
im working on the online/offline filtering now
Zaurbek Zhakupov
@zzhakupov
Nov 17 2016 02:13
@awb715 Mine one was something like yours at the beginning
I was doing this one about 4 days
Aaron Bell
@awb715
Nov 17 2016 02:14
the online offline part is taking me a while
Stephen James
@sjames1958gm
Nov 17 2016 02:14
@Zooll8 :+1: looks good!
Caden Damiano
@cdomiano
Nov 17 2016 02:14
function truncateString(str, num) {
  var newStr = '';

  if(str.length > num) {
    newStr = str.slice(0, num-3) + '...';
    return newStr;
  } else if (num <= 3) {
      return str.slice(0,num)+"...";
  } else {
   return str.slice(0, num-3) + '...';
}


}

truncateString("A-", 1);
@Margaret2 I'm not sure I'm following, this. It isn't passing. So yo didn't mean switch length>num with the last one?
Zaurbek Zhakupov
@zzhakupov
Nov 17 2016 02:15
@awb715 I want to give you one very important advie for this:
don't try to do everything throught one super extra hard $("#"+value).html(50 lines of code);
I was trying to do this for 2 days
Margaret
@Margaret2
Nov 17 2016 02:15
@cdomiano first part should be
if (str.length <= num) {
return str;
}
Zaurbek Zhakupov
@zzhakupov
Nov 17 2016 02:15
just this like, and failed everytime
so I decided to make small functions for everything, that work rly good
Lila Mohamed
@Lila-Mohamed
Nov 17 2016 02:16
@Margaret2 @J-Victorsantos Thanks y'all. I had to ask someone face to face to understand. I was going in circles.
CamperBot
@camperbot
Nov 17 2016 02:16
lila-mohamed sends brownie points to @margaret2 and @j-victorsantos :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @j-victorsantos |http://www.freecodecamp.com/j-victorsantos
:cookie: 464 | @margaret2 |http://www.freecodecamp.com/margaret2
Aaron Bell
@awb715
Nov 17 2016 02:16
yea jquery does that @Zooll8
Margaret
@Margaret2
Nov 17 2016 02:18
@cdomiano worked?
Caden Damiano
@cdomiano
Nov 17 2016 02:19

```
function truncateString(str, num) {
var newStr = '';

if (str.length <= num) {
return str;
} else if (num <= 3) {
return str.slice(0,num)+"...";
} else {
return str.slice(0, num-3) + '...';
}

}

truncateString("A-", 1);
``` thanks @Margaret2 it worked! So what happens is that when you pass the arguments that are less than the number, it just returns the origional string? then if that doesn't work, we see if the number is less than or equal to 3 if so, chop off that number from the string. Then the last one is for longer strings and you just chop off the last three from the actual number argument to make room for the '...'

CamperBot
@camperbot
Nov 17 2016 02:19
cdomiano sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 465 | @margaret2 |http://www.freecodecamp.com/margaret2
Caden Damiano
@cdomiano
Nov 17 2016 02:19
did I butcher that? @Margaret2
Aaron Bell
@awb715
Nov 17 2016 02:19
im struggling with online, offline filtering @Zooll8
Zaurbek Zhakupov
@zzhakupov
Nov 17 2016 02:19
@awb715 I can give you full filter algorithm
Aaron Bell
@awb715
Nov 17 2016 02:20
i dont want it haha
@Zooll8
@Zooll8
im working in that pen with the filter
Margaret
@Margaret2
Nov 17 2016 02:21
@cdomiano basically yeah, that is how it works :)
the num is how long you want the whole string, including dots, to be
Caden Damiano
@cdomiano
Nov 17 2016 02:21
@Margaret2 that was fun thank you.
CamperBot
@camperbot
Nov 17 2016 02:21
cdomiano sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:warning: cdomiano already gave margaret2 points
Margaret
@Margaret2
Nov 17 2016 02:21
:D
Steve
@marioecg
Nov 17 2016 02:22
Hey guys, can anyone help me with a bonfire. Please?
CamperBot
@camperbot
Nov 17 2016 02:22
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Steve
@marioecg
Nov 17 2016 02:23
bonfire mutations
CamperBot
@camperbot
Nov 17 2016 02:23

:fire:Bonfire: Mutations :link:

function mutation(arr) {
  return arr;
}

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

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

more info:  bf details | bf links | hint

Steve
@marioecg
Nov 17 2016 02:29
Anyone?
MoNag1
@MoNag1
Nov 17 2016 02:29
@marioecg sure what are you trying?
Jan
@burning-monk
Nov 17 2016 02:30
bonfire rom13
CamperBot
@camperbot
Nov 17 2016 02:30
Sorry, can't find a bonfire called rom13. [ Check the map? ]
Aaron Bell
@awb715
Nov 17 2016 02:32
anyone workking on twitch
struggling a lot\
Stephen James
@sjames1958gm
Nov 17 2016 02:37
@marioecg You need to make sure each letter of the second string is in the first, not the second string as a whole
@awb715 You will need to make your offline and online more global and initialize to an array.
http://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example
Also read this SO post about have callbacks inside for loops (your i variable will not be what you think when you get the response)
catokass
@catokass
Nov 17 2016 02:42
function sumPrimes(num) {
  var sum = 0;
  var yes = true;
  for (var x = 0; x <= num; x++) {
    for (var y = x - 1; y > 1; y--) {
      if ((x / y) % 1 === 0 ) {
        yes = false;
        break;

      }

    }
    if (yes === true) {
        sum += x;
    }  
    yes = true;

  }

  return sum - 1;
}

sumPrimes(977);
hi everyone, i've done the 'sum all primes' challenge but i'm not sure why i need to minus 1 at the end
Aaron Bell
@awb715
Nov 17 2016 02:44
this is hurting my head
@sjames1958gm
Aleks
@aleksp9
Nov 17 2016 02:45
Has anyone done the Profile Lookup Challenge?
Stephen James
@sjames1958gm
Nov 17 2016 02:45
@catokass You've included 1 which isn't a prime? Maybe start your loop at 2 the first prime?
@aleksp9 Yes
@awb715 Not sure when your activate function is called but if you move your for loop to where this function is called
and pass in the channel instead of the array - then this issue will go away.
Aleks
@aleksp9
Nov 17 2016 02:48
@sjames1958gm Im having a little trouble wrapping my head around how to return “No such Contact” if the firstName is not found in the list. What im doing right now is finding the length of the object, which is 4, and using a for loop to go through it. But that for loop would find 3/4 times that firstName argument doesnt equal the firstName object
Stephen James
@sjames1958gm
Nov 17 2016 02:48
@aleksp9 If you are looking through a list of contacts when would you declare you didn't have a contact?
Hint: all code doesn't have to be inside the loop
Aaron Bell
@awb715
Nov 17 2016 02:49
@sjames1958gm im seeing it wow
Aleks
@aleksp9
Nov 17 2016 02:49
Right so I was going to declare that outside of the loop, but wouldn’t it hit that everytime? Unless I can break out of the function early. But theres also the challenge of determing if the property isnt found
@sjames1958gm
Aaron Bell
@awb715
Nov 17 2016 02:50
@sjames1958gm thanks, you know you have like hte most brownie points? what do they do
CamperBot
@camperbot
Nov 17 2016 02:50
awb715 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4390 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 02:50
@aleksp9 IF you are returning from inside the loop then you can put it after the loop
catokass
@catokass
Nov 17 2016 02:50
@sjames1958gm thank you that worked :)
CamperBot
@camperbot
Nov 17 2016 02:50
catokass sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4391 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 02:50
@awb715 They make me feel good :) other than that not much
@catokass :+1:
Aaron Bell
@awb715
Nov 17 2016 02:50
haha
they should set you up a call with quincy larson.
its working now to an extent, now i have to configure more
Stephen James
@sjames1958gm
Nov 17 2016 02:51
@awb715 pass channels[i] to the function
Aleks
@aleksp9
Nov 17 2016 02:52
@sjames1958gm right ill add the return to get out of the for loop, but then what IF statement could dtermine if the firstName was missing or the Property? Wouln’t I need to loop again and add some sort of “marker” variable notifying if the firstName or Property object was found?
Stephen James
@sjames1958gm
Nov 17 2016 02:52
function activate(channels) { change this to function activate(channel) { then you can use channel (not channels[i]) inside the function
@aleksp9 If you find the contact inside the loop and return either the property or no such property the only way to exit the loop is to not find the firstName
Remember return leaves the function immediately no more code in the function executes
Aaron Bell
@awb715
Nov 17 2016 02:55
confused @sjames1958gm
Bobby
@heebzstreet
Nov 17 2016 02:56
hey can anybody help me out with an unrelated problem to freecodecamp?
I'm building my own calculator
and I can't figure out how to input more than one number
Stephen James
@sjames1958gm
Nov 17 2016 02:57
@awb715 with the for loop outside the function activate, then activate can operate on only one channel.
You will need to also move the offline and online array variables up to the top of the .ready function so they are available to the rest of the code.
Aleks
@aleksp9
Nov 17 2016 02:59
@sjames1958gm ahh I think I’m getting it now… the only problem im still having is my if statment checks for firstName and property… if the combination is not found, it wont return the value of the property. After that if statment in my loop finishes then I need to individually check if the firstName is present, or if the property is present
Stephen James
@sjames1958gm
Nov 17 2016 02:59
@heebzstreet You mean when you press a second button?
An idea would be to have a variable that is the current value and if another number is pressed += the number to that variable.
That variable would be kept in sync with the display of the calculator
Does this make any sense
Aleks
@aleksp9
Nov 17 2016 02:59
This is what I have so far: function lookUpProfile(firstName, prop) {
// Only change code below this line
var objlen = contacts.length;
for (i = 0; i < objlen; i++) {
if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
}
}
Stephen James
@sjames1958gm
Nov 17 2016 02:59
@aleksp9 Can you post the code? (leaving off the contacts object)
@aleksp9 So you need a second test checking firstName and not having the property?
Bobby
@heebzstreet
Nov 17 2016 03:00
it does but wouldn't that just add the two digits together, instead of making it a whole number? for example: 1 and 2 would be 3 instead of 12 @sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 03:00
@heebzstreet If they are both strings then it would concatenate
Bobby
@heebzstreet
Nov 17 2016 03:01
so I'd have to do number to string?
Stephen James
@sjames1958gm
Nov 17 2016 03:01
@heebzstreet When you need the number you can convert the string
Aleks
@aleksp9
Nov 17 2016 03:01
@sjames1958gm Right so I would need two additional statements, one that returns “No Name found” if the firstName does not match in with any of the contacts and similar for the property
Stephen James
@sjames1958gm
Nov 17 2016 03:01
@heebzstreet Well the content of an HTML element is a string first even a number
@aleksp9 Try doing the no such property one first. see if you can pass all but the no such contact tests
Bobby
@heebzstreet
Nov 17 2016 03:03
ok let me try this out I'll be back. @sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 03:03
@heebzstreet ok, if not too long I'll still be here
Bobby
@heebzstreet
Nov 17 2016 03:06
so I'm going to try num.toString() but I wanted to know how to turn it back into a number before it displays
Stephen James
@sjames1958gm
Nov 17 2016 03:06
You can use parseInt
Aleks
@aleksp9
Nov 17 2016 03:06
@sjames1958gm Would I have to create another loop? and return “no property found" if the property was not found?
Stephen James
@sjames1958gm
Nov 17 2016 03:07
@aleksp9 why not just use else if on your current if ?
Bobby
@heebzstreet
Nov 17 2016 03:08
so should i do a for loop, and when the operation (+,-,*,/) is defined, use parseInt to turn it back into a number?
Aaron Bell
@awb715
Nov 17 2016 03:09
@sjames1958gm i think i am filtering it but it seems my tests foronline isnt right
Stephen James
@sjames1958gm
Nov 17 2016 03:10
@heebzstreet if you are doing a calculator everything should be based on user input events?
HappyMeerkat
@HappyMeerkat
Nov 17 2016 03:11
can anyone explain this to me please i'm doing the passing value to functions with arguments Javascript. it says functionsWithArgs(1,2) should output 3 and functionWithArgs(7,9) should output 16. i found this code online and it passes but i don't get what "hello world" has to do with anything?
function functionWithArgs(param1, param2) {
console.log(param1 + param2);
}
functionWithArgs("Hello", " World");
Aleks
@aleksp9
Nov 17 2016 03:11
@sjames1958gm Im not sure what conditional I would put in that else if…. If i put (property == prop), which it might 2/4 times, I would return nothing, but if i put if (property != prop) that may also happen 2/4 times
Jason
@jasonascott89
Nov 17 2016 03:12
Consider console.log("Hello" + " World")
Aaron Bell
@awb715
Nov 17 2016 03:12
for anyone who did twitch.tv, how did you tell if the channel was online or offline, the api doesnt document it well
Bobby
@heebzstreet
Nov 17 2016 03:12
@sjames1958gm you're right
Stephen James
@sjames1958gm
Nov 17 2016 03:12
@aleksp9 else if contact firstname matches and the contact doesn't have the property return no such property
Bobby
@heebzstreet
Nov 17 2016 03:12

function processOperand(num){

    if(operation===undefined){
        num.toString()=num;
        parseInt(num);
        number=num;
    }
    else{
        if(operation==='+'){
            number+=num;
        }
        else if(operation==='-'){
            number-=num;
        }
        else if(operation==='*'){
            number *=num;
        }
        else if(operation==='/'){
            number/=num;
        }
    }
    document.getElementById('display').value=num;

}
HappyMeerkat
@HappyMeerkat
Nov 17 2016 03:12
or looking at it is it the fact in the function (param1 + param2); would do the somes
Bobby
@heebzstreet
Nov 17 2016 03:12
@sjames1958gm
Jason
@jasonascott89
Nov 17 2016 03:12
If numbers are put in for param1 and param2, they'll be treated as numbers
HappyMeerkat
@HappyMeerkat
Nov 17 2016 03:12
sums*
Jason
@jasonascott89
Nov 17 2016 03:13
Plop some strings in there, get some "string" + "string" action
Stephen James
@sjames1958gm
Nov 17 2016 03:14
if num is a num and you have the existing display as a string then display + num should add the number to the string.
"1223" + 4
"12234"
Bobby
@heebzstreet
Nov 17 2016 03:14
do I need to create an array? @sjames1958gm
Aleks
@aleksp9
Nov 17 2016 03:14
@sjames1958gm AHHHHHHHHHHHHHHHHHHHH THAT make sense. You wouldnt search for other contacts properties. Thanks a lot :D. I shouldn’t have inturpreted the problem so literally
CamperBot
@camperbot
Nov 17 2016 03:14
aleksp9 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4392 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 03:15
@aleksp9 :+1:
@heebzstreet Just a string seems enough - then when you need the number parseInt
Aleks
@aleksp9
Nov 17 2016 03:15
@sjames1958gm Since im new to the chat, how do you also put in your code like you did in the previous message
Bobby
@heebzstreet
Nov 17 2016 03:16
so does this code look correct?
Stephen James
@sjames1958gm
Nov 17 2016 03:16
@aleksp9 start with three then shift-enter then paste then shift-enter then three
Those are not ''' or """ but ```
CamperBot
@camperbot
Nov 17 2016 03:16
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Nov 17 2016 03:16
Also click that more info link for more info (lol)
Bobby
@heebzstreet
Nov 17 2016 03:16
var number=0;

function processOperand(num){

    if(operation===undefined){
        num.toString()=num;
        parseInt(num)=num;
        number=num;
    }
    else{
        if(operation==='+'){
            number+=num;
        }
        else if(operation==='-'){
            number-=num;
        }
        else if(operation==='*'){
            number *=num;
        }
        else if(operation==='/'){
            number/=num;
        }
    }
    document.getElementById('display').value=num;

}
Aaron Bell
@awb715
Nov 17 2016 03:17
has anyone worked on twitch.tv? theres 2 piecesof api documentation and the one with all the info doesnt show it being online or offline
Aleks
@aleksp9
Nov 17 2016 03:18
@sjames1958gm Awesome. Youre the man!
Stephen James
@sjames1958gm
Nov 17 2016 03:18

@heebzstreet this is kind of what I meant

var number = document.getElementById('display').value
number += num;

Then put number back into the display value

@aleksp9 :)
@awb715 I think you need the streams link to tell if offline
https://wind-bow.hyperdev.space/twitch-api/streams/freecodecamp
if stream is null then offline
{
"stream": null,
"_links": {
"self": "https://api.twitch.tv/kraken/streams/freecodecamp",
"channel": "https://api.twitch.tv/kraken/channels/freecodecamp"
}
}
Aaron Bell
@awb715
Nov 17 2016 03:20
okay
Bobby
@heebzstreet
Nov 17 2016 03:20
ohhhh got you. Does that mean I should take out the num.toString() and the parseInt()? @sjames1958gm
Aaron Bell
@awb715
Nov 17 2016 03:20
so thatmeans no display of data relevant to the channel because you get no info from that
ANormalSoundingName
@ANormalSoundingName
Nov 17 2016 03:20

I'm having a hard time with local scope and functions. What should I be doing differently here?
```function myLocalScope() {
'use strict';

var myVar = 10;
console.log(myVar);
}
myLocalScope();

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

//There was a console.log here, which I deleted.

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

Doug Stoeckicht
@dstoeckicht
Nov 17 2016 03:20

Guys...I'm stuck... I just don't get this JavaScript question.. "myStr should have encoded text with the proper escape sequences and no spacing."

var myStr = "FirstLine \n \SecondLine\ \r ThirdLine"; // Change this line

I'm just not grasping this "escape" sequence...

Aaron Bell
@awb715
Nov 17 2016 03:20
@sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 03:20
@awb715 The channels API gives you info about the channel
@dstoeckicht no spacing?
Aaron Bell
@awb715
Nov 17 2016 03:21
so i need to do 2 requests @sjames1958gm ?
ANormalSoundingName
@ANormalSoundingName
Nov 17 2016 03:21
@dstoeckicht the backslashes need to be commented out
Aaron Bell
@awb715
Nov 17 2016 03:21
one for channel and one for streams
ANormalSoundingName
@ANormalSoundingName
Nov 17 2016 03:21
I mean escaped
Stephen James
@sjames1958gm
Nov 17 2016 03:21
@awb715 Yeah, I think people have done that.
Here is what I meant by the for loop
for (i = 0; i < channels.length; i++) {
    activate(channels[i]);
}

function activate(channel) {

  $.getJSON('https://wind-bow.hyperdev.space/twitch-api/channels/' + channel + '?callback=?', function(data) {
@dstoeckicht So you have 6 \ here in chat it will hide some
Aaron Bell
@awb715
Nov 17 2016 03:22
their api is horrible if they dont have both, it seems pointless 2 have 2 calls
Stephen James
@sjames1958gm
Nov 17 2016 03:23
@awb715 Yeah! you should write a letter :)
Aaron Bell
@awb715
Nov 17 2016 03:23
lol
Bobby
@heebzstreet
Nov 17 2016 03:23
@sjames1958gm hey that didnt work, it doubled every input. Do you mind if I send you the full code minus the HTML?
Doug Stoeckicht
@dstoeckicht
Nov 17 2016 03:23
I'm still so confused...
Bobby
@heebzstreet
Nov 17 2016 03:23
To have a better understanding
Stephen James
@sjames1958gm
Nov 17 2016 03:24
@dstoeckicht try removing all the blanks first
@heebzstreet ok
Bobby
@heebzstreet
Nov 17 2016 03:26
var number=0;
var operation;
function proccessOperation(op){    
    if(op==='+'){
        operation='+';
    }
    else if(op==='-'){
        operation='-';
    }
    else if(op==='*'){
        operation='*';
    }
    else if(op==='/'){
        operation='/';
    }

}

function processOperand(num){

    if(operation===undefined){

        number=num;
    }
    else{
        if(operation==='+'){
            number+=num;
        }
        else if(operation==='-'){
            number-=num;
        }
        else if(operation==='*'){
            number *=num;
        }
        else if(operation==='/'){
            number/=num;
        }
    }
    document.getElementById('display').value=num;

}


function processClear(){
    var num=0;
    document.getElementById('display').value=num;
    operation=undefined;
}

function processEqual(){
    document.getElementById('display').value=number;
    operation=undefined;
}
@sjames1958gm
Aaron Bell
@awb715
Nov 17 2016 03:29
@sjames1958gm thanks for the help. going to note down where im at and keep going tomorrow
CamperBot
@camperbot
Nov 17 2016 03:29
awb715 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: awb715 already gave sjames1958gm points
Stephen James
@sjames1958gm
Nov 17 2016 03:30
@heebzstreet So when num comes in you want to add to end of display
Bobby
@heebzstreet
Nov 17 2016 03:30
yes eactly @sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 03:30
so pull the value out of 'display' and then append the num to that and put it back in?
Bobby
@heebzstreet
Nov 17 2016 03:32
If i do that, I will be able to input 64? because right now the 6 will change to a 4 instead of recognizing it as a double digit number
@sjames1958gm
i thought .value was part of the code to append to display
Stephen James
@sjames1958gm
Nov 17 2016 03:32
so 6 goes into the display then you pull the 6 out and concatenate the 4
.value replaces
S7eve
@S7eve
Nov 17 2016 03:33
guys does anyone know the difference between:
var a = $.datepicker.formatDate('d M yy')
and
var a = $(".datepicker").formatDate('d M yy')
Bobby
@heebzstreet
Nov 17 2016 03:35

soo,

document.getElementById('display')=num;

as opposed to

document.getElementById('display').value=num;
@sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 03:36
@heebzstreet YOu have to get the current value out and append it and then replace
The first line will not work.
Bobby
@heebzstreet
Nov 17 2016 03:37
hmmm. I'm stuck on trying to figure out how to do that. num.appendTo(value) ?
Stephen James
@sjames1958gm
Nov 17 2016 03:39

The value in the display is going to be a string.

var display =  document.getElementById('display').value;
display += num;
document.getElementById('display').value = display

Since display will be a string += should concatenate

Bobby
@heebzstreet
Nov 17 2016 03:41
hmmmmmm that makes sense by display is the ID for the text box in HTML
but**
would it work still?
Stephen James
@sjames1958gm
Nov 17 2016 03:42
I think so. throw some console.log in there and experiement
Aarya Bhorra
@aarya1302
Nov 17 2016 03:45
Hey guys I'm having problem with free code camp
Everytime I go to the challenge that I am doing the website crashes
Please help
Bobby
@heebzstreet
Nov 17 2016 03:47
it's allowing multiple integers on the display however it's not recognizing them as an altogether number. For example 366+2 will = 8
Bobby
@heebzstreet
Nov 17 2016 03:47
it only does the math for the integer closet to the operation
Aarya Bhorra
@aarya1302
Nov 17 2016 03:48
@moigithub thanks
CamperBot
@camperbot
Nov 17 2016 03:48
aarya1302 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2193 | @moigithub |http://www.freecodecamp.com/moigithub
Bobby
@heebzstreet
Nov 17 2016 03:49
@heebzstreet
it's allowing multiple integers on the display however it's not recognizing them as an altogether number. For example 366+2 will = 8
it only does the math for the integer closet to the operation
@sjames1958gm
Stephen James
@sjames1958gm
Nov 17 2016 03:49
You can use Regex to split up the string?
@heebzstreet I have to go offline - good luck
Bobby
@heebzstreet
Nov 17 2016 03:53
thanks ! @sjames1958gm
CamperBot
@camperbot
Nov 17 2016 03:53
heebzstreet sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4393 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
jahnellybean
@jahnellybean
Nov 17 2016 03:54

hi! is there something wrong with this code?? $('#searchTerm').keypress(function(e) {
if (e.which == 13) {
$('#searchClick').click();
}

});

it's not working in my wikipedia search :/
c0d0er
@c0d0er
Nov 17 2016 03:56
@toianw thanks!
CamperBot
@camperbot
Nov 17 2016 03:56
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @toianw |http://www.freecodecamp.com/toianw
bthebuilder
@bthebuilder
Nov 17 2016 04:05
Hi all ! having a bit of trouble with the counting cards challenge: any hits as to why the following isn't right would be helpful. Thanks in advance =)
function cc(card) {
var count = 0;
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count +=1;
break;
case "J":
case "Q":
case "K":
case "A":
count -=1;
break;
}
if (count >= 1){
console.log(count + "Bet");
}
else{
console.log(count + "Hold");
}
}
LPR-309
@LPR-309
Nov 17 2016 04:09
@bthebuilder You're logging the results, but you're not returning anything. console.log statements should actually be return
bthebuilder
@bthebuilder
Nov 17 2016 04:11
@LPR-309 ohh okay, thanks
CamperBot
@camperbot
Nov 17 2016 04:11
bthebuilder sends brownie points to @lpr-309 :sparkles: :thumbsup: :sparkles:
:cookie: 419 | @lpr-309 |http://www.freecodecamp.com/lpr-309
LPR-309
@LPR-309
Nov 17 2016 04:13
@bthebuilder :thumbsup: You can also do count++; and count--; inside that switch statement, too. But I don't think it'll make any difference, since you declared count with an initial number value. Should work~
bthebuilder
@bthebuilder
Nov 17 2016 04:16
=) thanks again
tommy
@tommygebru
Nov 17 2016 04:21
@jahnellybean have you tried finding one on codepen?
Christopher Lavine
@Christopher37
Nov 17 2016 04:29
hey i stuck on the manipulating complex objects challenge and i tried my answer and i keep getting stopped by the missing token alert and i really dont know what im doing wrong

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

{
"artist": "Future",
"title": "Slave Master",
"release_year": 2015,
"format": [
"CS"
"LP"]
}
// Add record here
];

Will
@Will-is-Coding
Nov 17 2016 04:33
Try adding a comma between the two artists @Christopher37
scShan
@scShan
Nov 17 2016 04:42
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count +=1;
break;
case "J":
case "Q":
case "K":
case "A":
count -=1;
break;
}
if (count >= 1){
return (count + "Bet");
}
else{
return (count + "Hold");
}
RK Basas
@NateBas
Nov 17 2016 04:42
a should be assigned to b with =
can someone ans that
Will
@Will-is-Coding
Nov 17 2016 04:46
@scShan What's the issue?
tommy
@tommygebru
Nov 17 2016 04:47
@Christopher37 comma between the two records
Will
@Will-is-Coding
Nov 17 2016 04:47
@NateBas Like var foo = "bar"; that is variable foo being assigned to string "bar". So try replacing those two with a & b
tommy
@tommygebru
Nov 17 2016 04:48
@NateBas yes an assignment operator is this [=]
RakeshNerkar
@Rakesh18754
Nov 17 2016 04:48

i have a

function One(parameter){

}

which is being called at multiple places in the JS
so in some places can i just call the function without passing the parameter and at some places by passing the parameter

eg:-
One();
One(parameterPasses);

tommy
@tommygebru
Nov 17 2016 04:49
@NateBas there is more info here http://www.w3schools.com/js/js_assignment.asp :smile:
Ayush Bahuguna
@relentless-coder
Nov 17 2016 04:49
@Rakesh18754 you have to pass the parameter, assuming that the code inside the function depends on the value that is passed.
tommy
@tommygebru
Nov 17 2016 04:49
@scShan try removing the parentheses from your return statements
@Rakesh18754 I dont think you need a parameter, but its recommended, http://www.w3schools.com/js/js_function_parameters.asp
RakeshNerkar
@Rakesh18754
Nov 17 2016 04:56
@relentless-coder @tommygebru ok....so if i dont pass the parameter do i have to pass null or i can leave it blank

I have a variable.

var titileDiv = $(this).parents("[id^='menu']").get(0).childNodes1;
console.log(titileDiv);

         the above statement returns a entire dom element like 
         <div class="test">......</div>
          and now i want to access element inside that ?

console.log(titileDiv.text()); // returns error
console.log($("titileDiv.className");// returns error

AlphaKevy
@AlphaKevy
Nov 17 2016 05:01

Title Case a Sentence

Ah, I for the life of me cannot figure out how to replace the first letter of each word to a capital...guidance would be SO appreciated...

function toTitleCase(str) {
   str = str.replace(/[^a-zA-Z0-9]/g, " ").toLowerCase().split(' '); 
   for (i=0;i<str.length;i++){
     return String(str[i]).charAt(0).toUpperCase();

   }
  return str;
}
toTitleCase("sHoRt AnD sToUt");

Kev

Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:06
hello world
CamperBot
@camperbot
Nov 17 2016 05:06

welcome to FreeCodeCamp @JeffGreenlee42!

Yi Lai
@Yi-Lai
Nov 17 2016 05:07
Screen Shot 2016-11-17 at 12.06.23 AM.png
hello everyone, for the life of me, I can't figure out why this doesn't work, hope someone can shed some light
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:08
:) Hey all.. I have a JS question... I was hoping this if statement work... but it doesn't So I am looking for the proper way to to do this.
```
if (str[i] == [a-z]) {
tempStr = tempStr + str[i];
}
if (str[i] == [a-z]) {
      tempStr = tempStr + str[i];
    }
there! is there a way to compare a character to an range of characters?
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:10
@AlphaKevy what are you using the RegExp to do? If you want to replace any non alphanumeric with space, making all str to lowerCase and splitting would do just fine
ms
@mkshcode
Nov 17 2016 05:12

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber; // Change this Line
var player = testObj[16]; // Change this Line

i'm not sure what to add in playerNumber
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:13
@AlphaKevy you're not storing the str in the loop or keeping track of it somewhere and remember that return keyword exits the function
@AlphaKevy it's best you don't return the str from the loop, you can store each word you changed first letter to uppercase to a variable then when the loop is done you return the result outside the loop
@ms what arw you to do?
ms
@mkshcode
Nov 17 2016 05:17

never mind I got it!

had to put
var playerNumber to 16
and use dot notation to get to \ Montana

@Lumexralph thanks!
CamperBot
@camperbot
Nov 17 2016 05:17
mkshcode sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 454 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:17
@JeffGreenlee42 [a-z]..... Should be a regular expression pattern
@ms :+1:
AlphaKevy
@AlphaKevy
Nov 17 2016 05:19
@Lumexralph Thanks for the advice! I managed to figure out that exact issue :D. The slice method finished the problem off as well. Thanks again.
CamperBot
@camperbot
Nov 17 2016 05:19
alphakevy sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 455 | @lumexralph |http://www.freecodecamp.com/lumexralph
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:19
@Lumexralph yes, that was my intention... but I get an error.. so I am not expressing that pattern correctly somehow. In psuedo code I want to say "If this char is within this pattern.. do this"...
Here is all of my code:
function palindrome(str) {
  var tempStr = "";
  for (i=0; i < str.length; i++) {
    if (str[i] == [a-z]) {
      tempStr = tempStr + str[i];
    } 
  }

  if( str == temStr.reverse()) {
    return true;
  } else {
    return false;
  }

  // Good luck!  
}



palindrome("eye");
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:21
@Yi-Lai posting the code here would be easier to help
@JeffGreenlee42 the js engine is not recognizing [a-z] as regExp, it should be /[a-z] /g..... If you want to test for all alphabet a-z in str exists
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:25
Ahhh... Hmm.. ok! let me try that! :)
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:30
@JeffGreenlee42 but why are you storing each character of str again using a loop and reversing it? It's too much work in my opinion..... Why don't you split the string, reverse it and join it together then you can use that to compare if it's a palindrome with str
Yi Lai
@Yi-Lai
Nov 17 2016 05:30

@Lumexralph thanks!
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = celsius;
celsius*=9;
celsius/=5;
celsius+=32;

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

// Change the inputs below to test your code
convertToF(30);
convertToF(20);
convertToF(0);
convertToF(-10);
convertToF(-30);

Ogundele Olumide
@Lumexralph
Nov 17 2016 05:31
@JeffGreenlee42 never forget that you can't change a string
Digvijay Jaiswal
@DJRockstar
Nov 17 2016 05:31
Hey Guys, i have put together a blog explaining the ins and outs of Hoisting. Give it a read if you like and :heart: if you like Thanks!
https://medium.com/@digvijay.jaiswal18/hoisting-how-js-interprets-variable-declaration-9b1c1218a6ff#.e2mmqnjp9
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:32
@Yi-Lai you're not storing the result in Fahrenheit
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:32
@Lumexralph I am struggling with that.. because it also seems like a lot of work to take a string.. turn it into an array.. then turn it back into a string again to compare?
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:32
@DJRockstar awesome
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:33
I kind of sort of wish that JS would just treat a string like an array! (hrumph!!!)
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:34
@JeffGreenlee42 when you use split on a str... It returns an array.... I.e var newStr = str.split()....that returns an array, so newStr is now an array
Digvijay Jaiswal
@DJRockstar
Nov 17 2016 05:34
@JeffGreenlee42 it can all u have to do is strName.split('') LOL
@Lumexralph lol u read me
Yi Lai
@Yi-Lai
Nov 17 2016 05:35
@Lumexralph got it! thanks :)
CamperBot
@camperbot
Nov 17 2016 05:35
yi-lai sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 456 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:36
Not yet @DJRockstar but when am free i should give it a look
@Yi-Lai :+1:
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:37
@Lumexralph hmm... ok.. I'm going to have to play with that some.. I thought my algorithm was rather elegent! Ha ha! (sigh!) I guess the solution is much messier.
Digvijay Jaiswal
@DJRockstar
Nov 17 2016 05:37
@Lumexralph ill appreciate that!
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:42
@Lumexralph I am wondering.. Within the FCC web page.. If I stick a console.log() function in the code , it does not appear anywhere.. How do you deal with that?
bensch5000
@bensch5000
Nov 17 2016 05:44
@JeffGreenlee42 you can let it run in the browser js console
@JeffGreenlee42 the fcc editor doesn’t capture console.log , this is expected
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:45
@bensch5000 you mean in Chrome Inspect console?
Asadullah5600
@Asadullah5600
Nov 17 2016 05:45
hello all
i want to start learning js with
someone
like class mate
bensch5000
@bensch5000
Nov 17 2016 05:45
@JeffGreenlee42 yes
@JeffGreenlee42 just copy&paste your code there. the console.log should work just fine
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:46
Ok.. I'll try that.. I have noticed I have a really heard time Locating the dang code within all of the other FCC elements.
bensch5000
@bensch5000
Nov 17 2016 05:48
@JeffGreenlee42 gets way easier over time. especially when you’re starting to write your own projects. I do prefer editors like Atom (based on electron) to work on FCC challenges and just transfer my results into the FCC editor
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:50
@bensch5000 yeah.. I love Atom.. but one thing I have bumped into is that despite some time searching for packages, I have NOT found a debugger that works in Atom for JavaScript.
@bensch5000 so I'm trying it out.. Where in the Chrome inspector do you paste your code into?
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:52
@DJRockstar read it and answered your coding challenge
@JeffGreenlee42 use your browser console or use repl.it
bensch5000
@bensch5000
Nov 17 2016 05:52
@JeffGreenlee42 if opened, you can just jump to console. focus the empty console and you should see the blinking text cursor that indicates that you can write something. paste and hit enter
the browser console in chrome and ff is literally an editor as well
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:54
That'll make debugging easier
@DJRockstar is ECMA Script 5 a separate word or ECMAScript 5?
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 05:54
@bensch5000 yes I see that.. and when I run it.. I even see where the Console reuturned my "True" value.. but I have a statement "console.log(tempStr);" and the output from that command does not appear
Is repl.it a website?
Ogundele Olumide
@Lumexralph
Nov 17 2016 05:55
@JeffGreenlee42 use go to this link repl.it
www.repl.it......browser console takes some little understanding else it frustrates you
bensch5000
@bensch5000
Nov 17 2016 05:56
@JeffGreenlee42 you also don’t really need a package in atom, you can blend in the console tab in atom as well
@JeffGreenlee42 http://pho.to/ATv3q
@JeffGreenlee42 just go to View > Developer > Toggle Developer Tools
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:02
@bensch5000 That pic you sent is really intriguing!!! I want that!!! Is there a particular Atom package you used? to blend that it in?
bensch5000
@bensch5000
Nov 17 2016 06:03
@JeffGreenlee42 nope, basic feature in atom. just go to the view menu in atom and follow the steps above
Abhisek Pattnaik
@abhisekp
Nov 17 2016 06:04
ECMA Script - A script which can cause dermical problems.
@Asadullah5600 Hi! You need to start first freecodecamp.com/map
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:06
@bensch5000 Ahhh! now I see! Ok! this is much better.. I thought you had to create some bogus web page and then wade through all of the inspector elements to find the code!
bensch5000
@bensch5000
Nov 17 2016 06:07
@JeffGreenlee42 thought so myself in the beginning. just spending some time in atom to explore the given feature set saved a lot of time and workarounds ;)
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:08
@bensch5000 Ok.. so now I have the code pasted in Atom.. what do I do to "run" it?
bensch5000
@bensch5000
Nov 17 2016 06:09
@JeffGreenlee42 btw if you’re working on a mac, the chrome and atom shortcut are the same. (alt+cmd+i)
@JeffGreenlee42 copy and paste it into the console and hit enter
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:10
Oh.. I see.. it doesn't do it for you! hmm... ! :P
Soumyojyoti Majumdar
@SoumyoNawab8
Nov 17 2016 06:10

I am in "Increment a Number with JavaScript" challenge and my code is var myVar = 87;

// Only change code below this line
myVar = myVar++ ; but the challenge is not completeing

bensch5000
@bensch5000
Nov 17 2016 06:10
@Soumyoahona200 can you share all of your code using https://gitter.zendesk.com/hc/en-us/articles/200176682-Markdown-basics ?
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:11
@bensch5000 one other question: Once I've pasted the code into console... then enter.. I don't seem to be able to edit it.. Do I have to make the change back in Atom and then copy and paste again?
Soumyojyoti Majumdar
@SoumyoNawab8
Nov 17 2016 06:12
@bensch5000 ya sure

'''var myVar = 87;

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

CamperBot
@camperbot
Nov 17 2016 06:12
:bulb: to format code use backticks! ``` more info
bensch5000
@bensch5000
Nov 17 2016 06:12
@JeffGreenlee42 use arrow up to display the last code you’ve entered, you can edit it before running it again
Soumyojyoti Majumdar
@SoumyoNawab8
Nov 17 2016 06:12

'''var myVar = 87;

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

CamperBot
@camperbot
Nov 17 2016 06:12
:bulb: to format code use backticks! ``` more info
bensch5000
@bensch5000
Nov 17 2016 06:13
@Soumyoahona200 try myVar++
Ogundele Olumide
@Lumexralph
Nov 17 2016 06:13
@Soumyoahona200 using myVar = myVar++ is like myVar = myVar = myVar + 1
bensch5000
@bensch5000
Nov 17 2016 06:13
without the assignment
Soumyojyoti Majumdar
@SoumyoNawab8
Nov 17 2016 06:13
yes
so the result should be
88
but its still remaining to 87
bensch5000
@bensch5000
Nov 17 2016 06:14
myVar = myVar++ should be just myVar++;
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:14
Ah.. ok got it! Thanks @bensch5000
CamperBot
@camperbot
Nov 17 2016 06:14
jeffgreenlee42 sends brownie points to @bensch5000 :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @bensch5000 |http://www.freecodecamp.com/bensch5000
Soumyojyoti Majumdar
@SoumyoNawab8
Nov 17 2016 06:14
ohk
Ogundele Olumide
@Lumexralph
Nov 17 2016 06:14
@Soumyoahona200 either you say myVar = myVar + 1
or myVar++
@Soumyoahona200 or myVar += 1
Abhisek Pattnaik
@abhisekp
Nov 17 2016 06:16
myVar++ is shortcut for myVar += 1 which is shortcut for myVar = myVar + 1
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:16
@bensch5000 The one thing that seems to be missing is the ability to step through and set breakpoints? Watches?
bensch5000
@bensch5000
Nov 17 2016 06:17
@JeffGreenlee42 use debugger;
@JeffGreenlee42 http://pho.to/ATv9r
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:27
@bensch5000 Arrrgh! When I step through the code.. it just takes me into endless iterations of "message-registry.js".. How do I get it so it will just step through MY code?
Oh.. this is terrible! Useless!
ivanesparza
@ivanesparza
Nov 17 2016 06:38
Does anyone know how to do the Word Blank? Don't tell me the code, just the instructions please, i don't know what they are asking for in this game about the MadLibs
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 06:43
how does this code give me 25
// Only change code below this line
function timesFive(num){
  return num *5;

}
if I didn't give num a value how does it return with 25?
Ken Haduch
@khaduch
Nov 17 2016 06:46
@ivanesparza - the basic idea is that they are passing a set of words in the four parameters to the function, and you are just to properly concatenate those words to form a sentence, or, I think, just a space-separated concatenation of those four variables. It can be used to form a sentence, the idea is that you have a space separating each of the words that is put into the string that you are to return.
k.vincent
@bobKasbi
Nov 17 2016 06:46
@WhiteLeaf1103 can't be... if you dont't give value, it returns NaN
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:47
@WhiteLeaf1103 if that function did indeed return a value of 25.. then num MUST have had a value stored.
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 06:47
FCC just automatically did it behind the scenes for this challenge?
Ken Haduch
@khaduch
Nov 17 2016 06:47
@WhiteLeaf1103 - it will not return anything if you don't call it, so you have to see what the parameter that was passed was. Is there more code?
@WhiteLeaf1103 - they do run the function with various parameters - the test list shows what the calling function and arguments are.
k.vincent
@bobKasbi
Nov 17 2016 06:48

@WhiteLeaf1103 (function timesFive(num){
return num *5;

})(5);

@WhiteLeaf1103 if you don't pass 5 as value, it returns NaN
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 06:49
// Example
function minusSeven(num) {
  return num - 7;
}

// Only change code below this line
function timesFive(num){
  return num *5;

}
@bobKasbi yea but where does num get its value?
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:50
@WhiteLeaf1103 yes... you had to call that function somewhere.. show us the statement you used to call the function.
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 06:50
@JeffGreenlee42 thats the entire code.
It passes me. with just that and I get 25 in the answer box. @JeffGreenlee42
Return a Value from a Function with Return
is the lesson
Ryan Ledford
@rledford
Nov 17 2016 06:51
@bobKasbi num is the arg passed to the function so whatever value you pass to the function is what num will be
Markus Kiili
@Masd925
Nov 17 2016 06:51
@WhiteLeaf1103 You just declare the function. FCC calls it under the hood.
Ryan Ledford
@rledford
Nov 17 2016 06:51
not to make circular statements, sry
Ken Haduch
@khaduch
Nov 17 2016 06:51
@WhiteLeaf1103 - the test sequence, which is the code down on the left side of the screen, shows the parameters that are passed when the function is called. They typically run a few cases, maybe only one is necessary.
k.vincent
@bobKasbi
Nov 17 2016 06:51
@Ryan Ledford I know ;-)
ivanesparza
@ivanesparza
Nov 17 2016 06:52
@khaduch Oh i see now, I thought that i was going to use an array for some reason but now i see that those are not array brackets but parenthesis, haha thank you!
CamperBot
@camperbot
Nov 17 2016 06:52
ivanesparza sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1938 | @khaduch |http://www.freecodecamp.com/khaduch
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 06:52
@Masd925 so it says somewhere behind the scenes num(5);
Ken Haduch
@khaduch
Nov 17 2016 06:52

@WhiteLeaf1103 - the list for this particular challenge (the test list, that is.)

timesFive should be a function
timesFive(5) should return 25
timesFive(2) should return 10
timesFive(0) should return 0

So it is called with the values "5", "2", and "0" in sequence, testing code checks the answer.

Markus Kiili
@Masd925
Nov 17 2016 06:52
@WhiteLeaf1103 More like timesFive(12);
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:53
@WhiteLeaf1103 Oh I see... you are talking about what happens on the FCC website challenge. Ok.. yes Ryan is correct.. there is a lot of test code behinde the scenes that happens when you submit the answer...
Markus Kiili
@Masd925
Nov 17 2016 06:54
@WhiteLeaf1103 When such function call is made timesFive(12); the JS engine makes an execution context where the function code is run and there num is a variable that has value 12.
Conor Murphy
@cmurphy580
Nov 17 2016 06:54

does anyone know how the TWITCH api works. Is it just,

https://wind-bow.hyperdev.space/twitch-api/"+user+"?callback=foo"

where user is the variable

Ryan Ledford
@rledford
Nov 17 2016 06:54
@WhiteLeaf1103 Markus, mentioned that it's done behind the scenes.
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 06:54
I'm still confused... yea I guess just behind the scenes is the answer
@rledford @Masd925 @JeffGreenlee42 @khaduch thanks everyone
CamperBot
@camperbot
Nov 17 2016 06:55
whiteleaf1103 sends brownie points to @rledford and @masd925 and @jeffgreenlee42 and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @jeffgreenlee42 |http://www.freecodecamp.com/jeffgreenlee42
:cookie: 376 | @rledford |http://www.freecodecamp.com/rledford
:star2: 2931 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 1939 | @khaduch |http://www.freecodecamp.com/khaduch
bensch5000
@bensch5000
Nov 17 2016 06:55
@JeffGreenlee42 can you share your code?
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:57
yes! Here it is
function palindrome(str) {
  var tempStr = "";
  var tmpArr = [];
  for (i=0; i < str.length; i++) {
    if (str[i] == /[a-z]/g) {
      tempStr = tempStr + str[i];
    }
  }

  console.log("Hello world!");
  tmpArr = tempStr.split("");
  if( str == tmpArr.reverse()) {
    return true;
  } else {
    return false;
  }

  // Good luck!
}



palindrome("eye");
Ryan Ledford
@rledford
Nov 17 2016 06:58
try joining your array after reversing
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 06:59
I changed console.log to assure myself that the console is showing it.. So now I am trying to step through the debugger.. It's a slog!!! I don't seem to be able to set watch points.. and I can't seem to prevent the debugger to jumping to code that is not my own!
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:02
Help will be provided at the time of need to those who deserves
CamperBot
@camperbot
Nov 17 2016 07:02
no wiki entry for: will be provided at the time of need to those who deserves
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:02
:expressionless:
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:03
@abhisekp Are you testing CamperBot?
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:03
umm... no :(
bensch5000
@bensch5000
Nov 17 2016 07:03
@JeffGreenlee42 thats strange. btw your tempstr stays empty
@JeffGreenlee42 thats how i’ve done it
function palindrome(str) {
  // Good luck!
  if(str.toLowerCase().replace(/[\W_]+/gi, '').split('').reverse().join('') ===   str.toLowerCase().replace(/[\W_]+/gi, '')){
    return true;
  } else return false;
}



palindrome("2A3*3a2”);
Ryan Ledford
@rledford
Nov 17 2016 07:04
@JeffGreenlee42 you have tempStr declared and are comparing to tmpStr
change one or the other to match
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:04
@JeffGreenlee42 if (str[i] == /[a-z]/g)
this is not how you match regex
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:05
@bensch5000 yes!!! That's what I am trying to debug.. but Gosh! this debugger is NOT behaving like I expect.
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:05
@JeffGreenlee42 /[a-z]/g.test( str[i] )
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:05
@bensch5000 How do you set watch points?
@abhisekp Ok.. I have NOT seen that function mentioned anywhere in the FCC challenges yet... so I am unfamiliar with it.
Ryan Ledford
@rledford
Nov 17 2016 07:07
@JeffGreenlee42 my bad got mixed up with tempStr and tmpArr one uses e and the other doesn't , disregard
Ken Haduch
@khaduch
Nov 17 2016 07:11
@JeffGreenlee42 - are you trying to run the debugger in the FreeCodeCamp window? I've found it to be very difficult to do that. I cannot always find my code to set a breakpoint, although I haven't tried it lately.
bensch5000
@bensch5000
Nov 17 2016 07:11
@JeffGreenlee42 gotta go for now. write me a PM if you wanna get more infos on the debugging / atom
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:12
@bensch5000 you may directly return the whole thing without the if...else construct
bensch5000
@bensch5000
Nov 17 2016 07:12
@abhisekp true ;) thanks
CamperBot
@camperbot
Nov 17 2016 07:12
bensch5000 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3155 | @abhisekp |http://www.freecodecamp.com/abhisekp
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:12
@khaduch no! @bensch5000 showed me a nifty way of using Atom and then Copying the code directly into the Chrome Debugging console.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:13
Thanks @bensch5000 ! I will check it out!
CamperBot
@camperbot
Nov 17 2016 07:13
jeffgreenlee42 sends brownie points to @bensch5000 :sparkles: :thumbsup: :sparkles:
:warning: jeffgreenlee42 already gave bensch5000 points
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:14
I really want to figure out how to set watches.
Ken Haduch
@khaduch
Nov 17 2016 07:14
@JeffGreenlee42 - that might be another difficult way to try and step through the code in the debugger. You might be better off going and opening a codepen project and putting the code there, open it in a debug session, and then see if you can find the code?
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:14
@bensch5000 you may reassign in-place the str variable and compare so that you don't have to repeat
return (str = str.toLowerCase().replace(/\W|_/g, '')) === str.split('').reverse().join('');
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:15
@khaduch The problem there is that codepen does not have a good debugger either!!! so you still end up having to use the Chrome console.
bensch5000
@bensch5000
Nov 17 2016 07:15
@abhisekp far more efficient. great input!
Ryan Ledford
@rledford
Nov 17 2016 07:15
@ryan6627 it will be a dead link
if its in the href='#'
Ken Haduch
@khaduch
Nov 17 2016 07:16
@JeffGreenlee42 - that's true, but if you are trying to run in the chrome console and step through it, I don't know if you can do that at all? At least if you put it in a codepen project and set up the Chrome console, I think that you can find the code (especially in the "debug" mode on CodePen, where it eliminates all of the baggage and overhead code.)
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:17
@JeffGreenlee42 when you move step by step in your code while debugging, you may log the variables by typing it out in the console e.g.
a
> 123
console will follow the same scope as the code
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:18
@khaduch No.. This is much cleaner! When you are in the Chrome Inspector and select "console".. you can paste your JS code directly in! There is no other elements or code to deal with!
@abhisekp why doesn't the Watch portion work?
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:20
@JeffGreenlee42 it will work when the code/execution reaches the scope of the variable you're watching
Darmawan Nashrullah
@darmawannashrullah
Nov 17 2016 07:20
some one help me,,,,,,how make var a;
var b = 2;
with a should have a value of 7
b should have a value of 7
a should be assigned to b with =
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 07:20
what am I doing wrong?
function nextInLine(arr, item) {
  // Your code here
  arr.push(6);
  nextInLine.shift();
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
stand in line challenge
Markus Kiili
@Masd925
Nov 17 2016 07:21
@WhiteLeaf1103 Use arr and item, not nextInLine which is the function name.
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:21
@WhiteLeaf1103 what do you want to do in this challenge?
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:22
@abhisekp yeah.. that's the rub! It doesn't seem to be very good about just running until it finds the next statement in your peice of code..
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 07:22
@abhisekp 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.
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:23
@WhiteLeaf1103 how do you add the number to the end of the array?
and which number to add?
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:24
@abhisekp Also, I tried your suggestion of just typing the variable into the console.. and I just get "Uncaught Reference Error:"
Ken Haduch
@khaduch
Nov 17 2016 07:25
@JeffGreenlee42 - yes, I know that, but can you actually step through the code that way, or just run it and get console.log output?
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:26
@JeffGreenlee42 Typing the variable in the console will work when you've paused the execution in scope of the variable.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:26
@khaduch Yes.. You can.. You have to select the reference.. It looks something like: "VM3021" when you run your code. Then it will show the whole Debug windows with Breakpoints and watches .. etc...
Ryan Ledford
@rledford
Nov 17 2016 07:26
@JeffGreenlee42 try jsfiddle?
Ken Haduch
@khaduch
Nov 17 2016 07:28
@JeffGreenlee42 - oh, I could only do that if I had an error in the code, it seems? Or is there another way to get that?
khaduch @khaduch - I have to go now... I'll see if I can find this thread tomorrow and learn from it... thanks!
CamperBot
@camperbot
Nov 17 2016 07:29
sorry khaduch, you can't send brownie points to yourself! :sparkles: :sparkles:
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:30
@abhisekp that's just it!!! When I set a breakpoint and then hit the icon with the two lines (looks like a "pause" button) it runs to the breakpoint .. but then it jumps to some code snippet that has nothing do with mine! and I can click "step over" till the cows come home and I'm just moving around in some hidden subroutine.. and can't get it to return to MY code! So I can never get it to actually PAUSE in my code!
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:30
lol
lost in the wild
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:31
@abhisekp Its so straigh forward when debugging in C or C++!! :)
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:31
wow!
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 07:32
@abhisekp array.push(#) is how you add a number to the end of an array
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:33
Someone should do a real demonstration of how to use this debugger on YouTube or something.. I've been trying to find one and just haven't found anything worthwhile.
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:33
@JeffGreenlee42 I would suggest to read the doc for documentation by chrome developers link which was provided or watch this awesome series https://www.youtube.com/channel/UCnUYZLuoy1rq1aVMwx4aTzw
Ogundele Olumide
@Lumexralph
Nov 17 2016 07:34
@darmawannashrullah make a var named var a assign 7 to it using= i.e var a = what you're to assign
then you assign a to b
Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:34
@WhiteLeaf1103 which number to add? Are there any numbers given?
Alex Strick van Linschoten
@strickvl
Nov 17 2016 07:34

Can someone help me with the Record Collection problem? https://www.freecodecamp.com/challenges/record-collection

// 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) {
  var record = collection[id];
  // if property is tracks
  if (prop==="tracks") {
    // if there is a tracks property with things in it
    if (record.hasOwnProperty("tracks")) {
      record.tracks.push(value);
    } else {
      // if there is no tracks property
      record.tracks.push([value]);
    }
  } else {
    record.prop.push(value);
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

This is where I currently am, but it gives me an error...

Abhisek Pattnaik
@abhisekp
Nov 17 2016 07:35
@WhiteLeaf1103 ok.
@WhiteLeaf1103 as per the instruction, the number is provided as the 2nd argument to the function which you grab using the item variable
Markus Kiili
@Masd925
Nov 17 2016 07:37
@strickvl When the tracks property is absent, you need to assign (not push) an array to the property.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:40
@abhisekp Unfortunately.. I think Youbute is having trouble with that video series.. I can't get it to play.. across three different browsers.
Alex Strick van Linschoten
@strickvl
Nov 17 2016 07:46
@Masd925 if I change that, it still has the same error. so that’s not the problem, at least it’s not the first problem...
WhiteLeaf1103
@WhiteLeaf1103
Nov 17 2016 07:46
@abhisekp I dont understand
Ian
@toianw
Nov 17 2016 07:47

@JeffGreenlee42 the easiest way if you're running the code in FCC is to add the debugger statement to your code. For example:

function nextInLine(arr, item) {
debugger;
// your code here

Open the developer tools. Then run your code (ctrl + enter). Then you can use step into next function call or 'step over next function call` to follow the code step by step.

Markus Kiili
@Masd925
Nov 17 2016 07:47
@strickvl If prop is not tracks and value not an empty string, you should assign the value.
Alex Strick van Linschoten
@strickvl
Nov 17 2016 07:48
@Masd925 record.tracks=[value]; is what I wrote for that
Markus Kiili
@Masd925
Nov 17 2016 07:49
@strickvl You should start the code with a check for value being an empty string.
I mean this: record.prop.push(value); you are doing this if prop is not tracks.
@strickvl You should first check if value is an empty string and then delete the property. Then check if prop is tracks and then make a hasOwnProperty check and either push value or assign [value]. If value is not an empty string and prop is not tracks, assign value to the property.
Alex Strick van Linschoten
@strickvl
Nov 17 2016 07:52
@Masd925 ok thank you let me try to work that through...
CamperBot
@camperbot
Nov 17 2016 07:52
strickvl sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2932 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Nov 17 2016 07:53
@strickvl You can only use push in one case.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 07:53
@toianw Ok, Thanks! That helps! Now for some reason it is stepping where I expect it to! I just rebooted my machine and used your suggestion. before the debugger took to some really obscure unfamiliar places!
CamperBot
@camperbot
Nov 17 2016 07:53
jeffgreenlee42 sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 426 | @toianw |http://www.freecodecamp.com/toianw
Joseph
@revisualize
Nov 17 2016 07:55
@strickvl Dot Notation is a String Literal. Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation.
Markus Kiili
@Masd925
Nov 17 2016 07:57
@strickvl You need to use bracket notation [prop] instead of .prop, because prop is a variable.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:00
Ok.. general audience. I have a question: Can you compare a string to an array? Is this a legal statement?
```
Alex Strick van Linschoten
@strickvl
Nov 17 2016 08:01
@revisualize @Masd925 this is where I am now:
function updateRecords(id, prop, value) {
  var record = collection[id]; // remember to use bracket notation when referring to a property with a variable
  if(prop === 'tracks'){
    // check to see if record has a tracks property
    var checkresult = record.hasOwnProperty("tracks");
    if (checkresult===0) {
        record.tracks = [];
        record.tracks.push(value);
    }
}
 if(value === ""){
    delete record[prop];
   } else {
    record.tracks=[value];
// if property isn't "tracks"
// set record[prop] to value
}
return collection;
}
@revisualize @Masd925 which seems to have removed one set of problems and created some new problems...
Markus Kiili
@Masd925
Nov 17 2016 08:01
@strickvl You need to start with the value being empty string test.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:02
result = str == arr;
Markus Kiili
@Masd925
Nov 17 2016 08:02
Otherwise you need to repeat it later.
Andrew Del Real
@ADelReal
Nov 17 2016 08:02
var code= "formatted";
Markus Kiili
@Masd925
Nov 17 2016 08:02
@JeffGreenlee42 That is valid but automatic coercion should be avoided (makes hard to understand code).
Alex Strick van Linschoten
@strickvl
Nov 17 2016 08:03
@Masd925 like this? it still doesn’t work.
function updateRecords(id, prop, value) {
  var record = collection[id]; // remember to use bracket notation when referring to a property with a variable
  if(value === ""){
    delete record[prop];
   } else {
    record.tracks=[value];
// if property isn't "tracks"
// set record[prop] to value
}
  if(prop === 'tracks'){
    // check to see if record has a tracks property
    var checkresult = record.hasOwnProperty("tracks");
    if (checkresult===0) {
        record.tracks = [];
        record.tracks.push(value);
    }
}
return collection;
}
Markus Kiili
@Masd925
Nov 17 2016 08:04
@strickvl All later code should go to the else block of first test.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:04
@Masd925 yeah.. In my tests I can't make it work. So if str = "eye" and arr=[e,y,e] .. the comparison is always false!
Aamnah Akram
@aamnah
Nov 17 2016 08:05
can anyone help me debug this? It's the basic Seek and Destroy algo
function destroyer(arr) {

  var args = Array.from(arguments);
  arr = args[0];

  // see if elements are in arr[0]
  // .indexOf()
  for (i=1; i<args.length; i++) {
    var index = arr.indexOf(args[i]);
    if(index !== -1) {
      arr.splice(index, 1);
    }
  }  

  return arr;
}
Markus Kiili
@Masd925
Nov 17 2016 08:06
@JeffGreenlee42 "1,2,3" == [1,2,3]; // true
Jack Lyons
@JackEdwardLyons
Nov 17 2016 08:06
hey guys, im wondering why in my tic tac toe code, my player buttons and tiles are working but not the reset button?
any ideas?
Markus Kiili
@Masd925
Nov 17 2016 08:06
@JeffGreenlee42 You should actually never use abstract equality == and !=.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:07
@Masd925 yes, but then why is "eye" == [e,y,e] false?
Markus Kiili
@Masd925
Nov 17 2016 08:07
@aamnah No need for arr = args[0];. arr is the first argument.
@JeffGreenlee42 You need the commas there.
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:08
@Masd925 really??? why? what else would you use?
Markus Kiili
@Masd925
Nov 17 2016 08:08
@JeffGreenlee42 Strict equality === and !==.
Aamnah Akram
@aamnah
Nov 17 2016 08:09
@Masd925 good catch. still doesn't pass though
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:09
@Masd925 oh.. yeah.. funny though.. I notice that FCC exercises don't always stick to the srict equality rule.
anand20kumar1992
@anand20kumar1992
Nov 17 2016 08:11

var myMusic[1] =[
{

"artist" : "Draft Punk",
"title": "Summer",
"release_year": 1999,
"formats": [
"CD",
"Cassette",
"LP"
],
"gold": true
}
];
var myMusic =[
{
"artist": "Brad Pit",
"title": "Summer",
"release_year": 1999,
"formats": [
"CD",
"Cassette",
"LP"
],
"gold": true
}
];

stck with code please help me out
stuck*
Markus Kiili
@Masd925
Nov 17 2016 08:12
@aamnah Your code only removes each argument once from arr. There can be several though.
Aamnah Akram
@aamnah
Nov 17 2016 08:14
@Masd925 i know. but i'm stuck at how to repeat the same thing again. i already did a loop and iterated, which i thought would take care of all insrtances. how do i keep checking it till there are no more left? should i do another for loop?
@Masd925 oh, filter!
Diane
@106Ch213
Nov 17 2016 08:14
Hi guys, I need a little push on the Return Largest Number in Array Challenge. My problem is that if the largest numbers in each array aren't in croissant order my variable "array" will keep the previous value. How can I get the second value to overwrite the first with the correct number? Here is my code:
function largestOfFour(arr) {
  // You can do this!

  var array = [];
  var largestNumber = [];

  for (i = 0; i < arr.length; i++)
  {
    for (j = 0; j < arr[i].length; j++)
      {
        if (arr[i][j] > array){
          array = arr[i][j];
        }
      }
    largestNumber.push(array);
  }

  return largestNumber;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
// returns [27,27,39,1001] but I want [27,5,39,1001]
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:14
Anyone know what the trick with using join funcion on an arry so that it does not stick commas between each letter?
Markus Kiili
@Masd925
Nov 17 2016 08:14
@JeffGreenlee42 Strict equality operators are very simple and logical. I have read the abstract equality algorithm from the ECMAScript standard a couple of times and have some sheets about how it works, and I still don't remember how it works. That is why it should not be used.
@aamnah Yes.
@JeffGreenlee42 var str = array.join("");
Jeff Greenlee
@JeffGreenlee42
Nov 17 2016 08:17
@Masd925 Ok.. that's the answer.. Thanks!
CamperBot
@camperbot
Nov 17 2016 08:17
jeffgreenlee42 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2933 | @masd925 |http://www.freecodecamp.com/masd925