These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Aug 2016
Joseph
@revisualize
Aug 28 2016 00:00
@FireFalcon1155 What is the output?
Will Hurley
@wjhurley
Aug 28 2016 00:00
@moigithub Thank you so much! I have been stuck on that Wherefore Art Thou challenge and you helped me solve it.
CamperBot
@camperbot
Aug 28 2016 00:00
wjhurley sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2024 | @moigithub |http://www.freecodecamp.com/moigithub
Zheng
@FireFalcon1155
Aug 28 2016 00:00
Hello
Joseph
@revisualize
Aug 28 2016 00:01
@FireFalcon1155 Great.. How would you loop that to include "wOrld" ?
Keli Fine
@kelifine
Aug 28 2016 00:01
@moigithub so i don't get why weather.weather.description isn't working?
Moisés Man
@moigithub
Aug 28 2016 00:01
@kelifine can u share ur codepen link ?
Zheng
@FireFalcon1155
Aug 28 2016 00:01
I can loop through arr, and put line 3 in the loop
Joseph
@revisualize
Aug 28 2016 00:01
@FireFalcon1155 Sure.
Do you see how this is starting to get built?
Zheng
@FireFalcon1155
Aug 28 2016 00:02
yea...
CompGeekGirl
@LisaRamos
Aug 28 2016 00:02
num.indexOf is not a function How can I make this a function? I'm doing Roman Numeral Converter under Intermediate Algorithm Scripting.
function convertToRoman(num) {
  if (num.indexOf(num) === 1) {
    num.push(num);
    console.log('The numbers are : ' + num);
  } else if (num.indexOf(num) > 1) {
    console.log(num + ' is already included with the rest of the numbers.');
  }
 return num;
}

convertToRoman(36);
Moisés Man
@moigithub
Aug 28 2016 00:04
@erayozer17 u comparing the NEXT word vs the PREVIOUS... soo at the end of ur iteration
"lazy" vs "dog".. lazy wins!! cuz it have more characters 4 vs 3
soo ur longest variable will have 4 <-- which is wrong..cuz jumped have more characters
Will Hurley
@wjhurley
Aug 28 2016 00:04
@LisaRamos your code is recursive. It will only find it's own index starting at 0
Moisés Man
@moigithub
Aug 28 2016 00:04
@erayozer17 u should compare the [i]word length vs longest variable...
@kelifine console.log(weather) <-- gimme this
https://i.gyazo.com/db679a26d6827f675b827cfeff1ffbdd.png
soour weather is an array of objects.... it do not have "directly" a description property
FIRST u need to access the array element wheather[0] then u can access description
Keli Fine
@kelifine
Aug 28 2016 00:08
@moigithub ok so I should do weather.weather[3]?
Moisés Man
@moigithub
Aug 28 2016 00:09
@kelifine not 3.. it only have 1 element...
weather.weather[0] <-- return an object... and this object have a description property
weather.weather[0].description
Eray Özer
@erayozer17
Aug 28 2016 00:09
@moigithub thank you so much
CamperBot
@camperbot
Aug 28 2016 00:09
erayozer17 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2025 | @moigithub |http://www.freecodecamp.com/moigithub
Keli Fine
@kelifine
Aug 28 2016 00:10
@moigithub so would I do weather.weather[0]["description"]?
Zheng
@FireFalcon1155
Aug 28 2016 00:10
guys I need some help. so my code down there returns this: 'undefined I\'m A Little Tea Pot' instead of "I'm A Little Tea Pot" how do I fix it?
Moisés Man
@moigithub
Aug 28 2016 00:10
@kelifine yep
Zheng
@FireFalcon1155
Aug 28 2016 00:10

function titleCase(str) {
  var lol;
var arr = str.split(" "); // giving us ["hElLo","wOrld"];
 for(i=0;i<arr.length;i++){ 
     lol+=" "+arr[i].charAt(0).toUpperCase() + arr[i].slice(1).toLowerCase();
 }
  return lol;
}

titleCase("I'm a little tea pot");

function titleCase(str) {
var lol;
var arr = str.split(" "); // giving us ["hElLo","wOrld"];
for(i=0;i<arr.length;i++){
lol+=" "+arr[i].charAt(0).toUpperCase() + arr[i].slice(1).toLowerCase();
}
return lol;
}

titleCase("I'm a little tea pot");

Keli Fine
@kelifine
Aug 28 2016 00:11
@moigithub thanks so much!!!
CamperBot
@camperbot
Aug 28 2016 00:11
kelifine sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2026 | @moigithub |http://www.freecodecamp.com/moigithub
Zheng
@FireFalcon1155
Aug 28 2016 00:11
function titleCase(str) {
  var lol;
var arr = str.split(" "); // giving us ["hElLo","wOrld"];
 for(i=0;i<arr.length;i++){ 
     lol+=" "+arr[i].charAt(0).toUpperCase() + arr[i].slice(1).toLowerCase();
 }
  return lol;
}

titleCase("I'm a little tea pot");
guys I need some help. so my code there returns this: 'undefined I\'m A Little Tea Pot' instead of "I'm A Little Tea Pot" how do I fix it
Moisés Man
@moigithub
Aug 28 2016 00:12
lol is uninitialized.. soo first value would be undefined
lol+=" " is the same as lol = lol + " " ...
soo ur code doing lol = undefined + " " ...
initialize lol as empty string var lol = "";
Zheng
@FireFalcon1155
Aug 28 2016 00:12
so I should do var lol=""?
oh ok
Moisés Man
@moigithub
Aug 28 2016 00:13
and.. still not passing cuz.. u have a extra string at start
u can use trim() to remove that extra when return
Zheng
@FireFalcon1155
Aug 28 2016 00:13
how?
asking like an idiot
hold on
Moisés Man
@moigithub
Aug 28 2016 00:14
@LisaRamos numbers do NOT have indexOf method.. only strings and arrays
Will Hurley
@wjhurley
Aug 28 2016 00:14
@LisaRamos this might help, but be careful because the answer is included further down the page https://github.com/FreeCodeCamp/freecodecamp/wiki/Algorithm-roman-numeral-converter
Zheng
@FireFalcon1155
Aug 28 2016 00:14
@moigithub do I do this .trim() or this? .trim("");
Moisés Man
@moigithub
Aug 28 2016 00:15
@FireFalcon1155 mdn.io/trim <--
beginnerdidi
@beginnerdidi
Aug 28 2016 00:24
I am stuck. How do I assign the contents of a to variable b?
var a = 7;
var b = 7;
Will Hurley
@wjhurley
Aug 28 2016 00:24
@beginnerdidi var b = a; after you have declared a
beginnerdidi
@beginnerdidi
Aug 28 2016 00:25
Let me try. @wjhurley
Thank you. @wjhurley It worked but I still don't understand it.
CamperBot
@camperbot
Aug 28 2016 00:27
beginnerdidi sends brownie points to @wjhurley :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @wjhurley |http://www.freecodecamp.com/wjhurley
errosc
@errosc
Aug 28 2016 00:33
@beginnerdidi var b = a; means that anything that is in variable a is now assigned to b
@beginnerdidi lets say a = 5. When you do var b = a, a is holding the value of 5
Zheng
@FireFalcon1155
Aug 28 2016 00:35

so this is what I noticed

whenever i'm face to face with a problem, i can't seem to solve it no matter how hard i try without someone's help. even then i struggle.

what do i do?

ronaldrdguez
@ronaldrdguez
Aug 28 2016 00:39
break it up
beginnerdidi
@beginnerdidi
Aug 28 2016 00:52
Ok thank you so much for explaining @errosc , I read it again and again and again it made sense...
CamperBot
@camperbot
Aug 28 2016 00:52
beginnerdidi sends brownie points to @errosc :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for errosc
Ryan Malm
@Rybar
Aug 28 2016 00:53
Anyone available to help me destroy a bug? http://ryanmalm.com/js13k/
the blue box should collide with the red box. They're the only two entities present, render correctly but won't collide. Ideas?
CompGeekGirl
@LisaRamos
Aug 28 2016 00:59
This message was deleted
@wjhurley Now how can I fix this unexpected end of input I got in this Roman Numeral Converter exercise?
function convertToRoman(num) {
  var decimalValues = [1000, 900, 500];
  var romanNumerals = ['M', 'CM', 'D'];

  var romanized = '';

  for (i = 0; i < values.length; i++) {
    while (values[i] <= num) {
      romanized + romanNumerals[i];
      num -= value[i];
  }
 return num;
}

convertToRoman(36);
Ryan Malm
@Rybar
Aug 28 2016 01:03
@LisaRamos the problem is with the statement romanized + romanNumerals[i]; should be romanized += romanNumerals[i]
CompGeekGirl
@LisaRamos
Aug 28 2016 01:04
@Rybar I changed that part but I still got the same unexpected end of input message.
Moisés Man
@moigithub
Aug 28 2016 01:04
@LisaRamos i < values.length; whats values ?? i dont see u have that declared
CompGeekGirl
@LisaRamos
Aug 28 2016 01:05
@moigithub Now how do I declare that?
Moisés Man
@moigithub
Aug 28 2016 01:05
@LisaRamos dont know what values is supposed to be
CompGeekGirl
@LisaRamos
Aug 28 2016 01:05
@moigithub I think I messed up that one.
Moisés Man
@moigithub
Aug 28 2016 01:06
probably values should be decimalValues ???? @LisaRamos
Ryan Malm
@Rybar
Aug 28 2016 01:06
@LisaRamos yes, neither value or values is declared
CompGeekGirl
@LisaRamos
Aug 28 2016 01:07
@moigithub I fixed it but it's not running. Have I done anything wrong?
function convertToRoman(num) {
  var decimalValues = [1000, 900, 500];
  var romanNumerals = ['M', 'CM', 'D'];

  var romanized = '';

  for (i = 0; i < decimalValues.length; i++) {
    while (decimalValues[i] <= num) {
      romanized + romanNumerals[i]
      num -= decimalValues[i];
  }
 return num;
}

convertToRoman(36);
Ryan Malm
@Rybar
Aug 28 2016 01:07
you're returning the wrong var... take another look
Moisés Man
@moigithub
Aug 28 2016 01:08
:point_up: August 27, 2016 8:03 PM <--- check that @LisaRamos
Ryan Malm
@Rybar
Aug 28 2016 01:08
and you'll need a few more array entries for both of your number tables for it to work for all numbers
and, you're still not doing +=, like @moigithub pointed out.
jonkiote
@jonkiote
Aug 28 2016 01:10
On the "Profile Lookup" exercise, would it be cheating if you explicitly check the prop variable against "firstName", "lastName", "number", and "likes"? I feel like I'm supposed to iterate through the properties.
Moisés Man
@moigithub
Aug 28 2016 01:10
if it works.. and make ur life easier.. why not :) @Jonkiote
jonkiote
@jonkiote
Aug 28 2016 01:11
Okay, haha.
thanks @moigithub
CamperBot
@camperbot
Aug 28 2016 01:11
jonkiote sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2028 | @moigithub |http://www.freecodecamp.com/moigithub
CompGeekGirl
@LisaRamos
Aug 28 2016 01:11
@Rybar Now how is this code? I know it's still not going through.
function convertToRoman(num) {
  var decimalValues = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];
  var romanNumerals = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];

  var romanized = '';

  for (var i = 0; i < decimalValues.length; i++) {
    while (decimalValues[i] <= num) {
      romanized += romanNumerals[i]
      num -= decimalValues[i];
  }
 return num;
}

convertToRoman(36);
Moisés Man
@moigithub
Aug 28 2016 01:12
:point_up: August 27, 2016 8:07 PM << that too :) @LisaRamos
u should return the roman number instead (at that point propbably num will be 0 cuz all substractions )
looks good except for the return statement. @LisaRamos
CompGeekGirl
@LisaRamos
Aug 28 2016 01:14
@Rybar Now what do I do with the return statement?
Joseph
@revisualize
Aug 28 2016 01:15
@LisaRamos You're almost doing it the same way that I did it.
Ryan Malm
@Rybar
Aug 28 2016 01:15
look at what you're returning. Is num what you've been modifying in your loop? Is it the answer the problem is looking for?
Hans Aranzalez
@haranzalez
Aug 28 2016 01:15
Hi guys, im currently doing one of the challenges: find the longest word in a string. But im getting a type error en im trying to push the length of the words into an array. Here is my code
CompGeekGirl
@LisaRamos
Aug 28 2016 01:15
@Rybar I'm trying to modify num.
Hans Aranzalez
@haranzalez
Aug 28 2016 01:15

function findLongestWord(str) {
var warr = str.split(' ');
var num = [];

for(var i = 0; i <= warr.length; i++)
{
num.push(warr[i].length);
}

return num;

}

findLongestWord("The quick brown fox jumped over the lazy dog");

Ryan Malm
@Rybar
Aug 28 2016 01:15
num isn't the roman numeral string though.
you can return anything in your function....
Hans Aranzalez
@haranzalez
Aug 28 2016 01:16
any help will be appreciate it :)
CompGeekGirl
@LisaRamos
Aug 28 2016 01:17
@Rybar what can I return besides num?
Moisés Man
@moigithub
Aug 28 2016 01:17
@haranzalez on ur code.. num is an array with all words length
ie: [3,5,5,3,6,4]
Ryan Malm
@Rybar
Aug 28 2016 01:18
@haranzalez you're returning the entire array, when what you want is one piece of it. Arrays have some handy functions built in that might help you sort it out...
Hans Aranzalez
@haranzalez
Aug 28 2016 01:19
Yes it should be like that, but is giving me a type error stating that it is not an object
Moisés Man
@moigithub
Aug 28 2016 01:20
@haranzalez also.. arrays start on 0 index.. so it ends on length -1
<= will try to access unexistant elements.. shoul dbe < only
Hans Aranzalez
@haranzalez
Aug 28 2016 01:20
Yes!!! That worked !!! @moigithub
thanks man!!!
Moisés Man
@moigithub
Aug 28 2016 01:21
:+1:
Matheus
@matheus-lima92
Aug 28 2016 01:32

Hi again guys, I'm stuck at the quote machine challenge. I'm trying to get data from the API, but it's not working. This is a part of my code:

$http({
method: 'GET',
url: ' http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=en'
}).then(function successCallback(response) {
alert("Test A!");
}, function errorCallback(response) {
alert("Test B!");
});

no alert is executing, and I don't know how to get the data. Can someone help?
Moisés Man
@moigithub
Aug 28 2016 01:35
@matheus-lima92 $http es un servicio de angular .. para poder usarlo tienes q agregarlo/inyectarlo como dependencia primero
Matheus
@matheus-lima92
Aug 28 2016 01:37
@moigithub Yes, I'm trying to do it with angular, but it's not working
Walid Ashri
@walidashri
Aug 28 2016 01:40
@moigithub Thank you for your help challenge passed :racehorse:
CamperBot
@camperbot
Aug 28 2016 01:40
:star2: 2029 | @moigithub |http://www.freecodecamp.com/moigithub
ashrisoft sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Ryan Malm
@Rybar
Aug 28 2016 01:42
@LisaRamos you get your return figured out?
Chris Jones
@magikid
Aug 28 2016 01:51
Does anyone test their code for the projects? If so, which framework do you use?
Daulis M Gonzalez
@daulis809
Aug 28 2016 01:59
Joseph
@revisualize
Aug 28 2016 01:59
:|
I'm trying to do Where art thou ... LOL. This is almost comical.
CompGeekGirl
@LisaRamos
Aug 28 2016 02:07
Anyway I'm testing out my Wherefore art thou code and all I'm getting is this []. Now how can I make this thing run in the conslole, whatever it is?
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for (var prop in arr) { 
    if (hasOwnProperty.call(arr, prop)) {
      result.push(prop);
    } else if (Object.prototype.hasOwnProperty.call(source, collection)) {
      target[collection] = source[collection];
    } else {
      return target;
    }
  }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
llamatarianism
@llamatarianism
Aug 28 2016 02:11
@LisaRamos var arr = []; for (var prop in arr) { ... }
you know for a fact that arr is empty
why are you iterating through it
CompGeekGirl
@LisaRamos
Aug 28 2016 02:12
@llamatarianism All I could say is I was trying to do something different with my code but should I remove the for loop?
llamatarianism
@llamatarianism
Aug 28 2016 02:12
no, no, the for loop is fine
it's just that you're iterating through arr
when arr is always empty
so the for loop is kinda pointless
really, your code may as well be this:
function whatIsInAName(collection, source) {
  var arr = [];
  return arr;
}
those are the only 2 lines that get executed
CompGeekGirl
@LisaRamos
Aug 28 2016 02:13
@llamatarianism Hold on, I need to do some things. I'll be back tomorrow.
Chris Jones
@magikid
Aug 28 2016 02:24
@daulis809 thanks for the suggestion
CamperBot
@camperbot
Aug 28 2016 02:24
magikid sends brownie points to @daulis809 :sparkles: :thumbsup: :sparkles:
:cookie: 190 | @daulis809 |http://www.freecodecamp.com/daulis809
Daulis M Gonzalez
@daulis809
Aug 28 2016 02:28
@magikid welcome!
Joseph
@revisualize
Aug 28 2016 02:32
blob
Look at me go!
I guess.. I need a second loop?
hmmm.
Walid Ashri
@walidashri
Aug 28 2016 02:36
@revisualize I've done it :smile: good luck
Joseph
@revisualize
Aug 28 2016 02:36
Thanks. I'm trying.
DJ
@qualitymanifest
Aug 28 2016 02:37
@revisualize yes, i used an outer loop to go through collection and an inner loop to go through source's keys
i actually just redid this one to make sure i could still do it
i did not use hasOwnProperty
Joseph
@revisualize
Aug 28 2016 02:37
no hasOwnProperty. Hmmm
CompGeekGirl
@LisaRamos
Aug 28 2016 02:38
Nevermind. I'm still stressing out over Wherefore Art Thou, especially over the [] in the console. How can I fix this code I have here so that way it can run?

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for (var prop in arr) { 
    if (hasOwnProperty.call(arr, prop)) {
      result.push(prop);
    } else if (Object.prototype.hasOwnProperty.call(source, collection)) {
      target[collection] = source[collection];
    } else {
      return target;
    }
  }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Joseph
@revisualize
Aug 28 2016 02:38
I'll try to figure this thing out. I need to leave this Starsmucks Caffe.
@LisaRamos What is arr.length?
Walid Ashri
@walidashri
Aug 28 2016 02:39
@LisaRamos arr is empty
Joseph
@revisualize
Aug 28 2016 02:39
@LisaRamos Where are you getting the prop variable from?
CompGeekGirl
@LisaRamos
Aug 28 2016 02:39
@revisualize What can I put in arr?
Joseph
@revisualize
Aug 28 2016 02:40
Anything you want?
DJ
@qualitymanifest
Aug 28 2016 02:40
@revisualize you can use equality operator to see if certain keys in collection exist and if the properties they contain are the same key/property combo as found in source, all at once
CompGeekGirl
@LisaRamos
Aug 28 2016 02:40
@revisualize I got the idea from Mozilla's developer website.
DJ
@qualitymanifest
Aug 28 2016 02:40
(trying to keep it kind of vague)
Joseph
@revisualize
Aug 28 2016 02:41
Hmm.. I need to figure this out. But, it is 740pm here in Seattle. And my Starsmucks Caffe is closing.
revisualize @revisualize goes the AFK.
Adam Jubert
@adamjubert
Aug 28 2016 02:45

Hey all, I'm having a problem with the "Record Collection" task. For reference: https://www.freecodecamp.com/challenges/record-collection

Here's what I have so far. Would someone mind giving me a hint/pointing me in the right direction? http://codepen.io/anon/pen/qNZPmX

Ken Haduch
@khaduch
Aug 28 2016 02:47
@adamjubert - any place in your code that you are using the id value, it should be indexing into the collection to access particular objects - collection[id] - that would be a place to start. Look at how you are accessing collection - the id value alone really cannot be used on its own.
CompGeekGirl
@LisaRamos
Aug 28 2016 02:49

I'm still having a problem with Wherefore Art Thou. The code:

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for (var prop in arr) { 
    if (hasOwnProperty.call(arr, prop)) {
      result.push(prop);
    } else if (Object.prototype.hasOwnProperty.call(source, collection)) {
      target[collection] = source[collection];
    } else {
      return target;
    }
  }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

It's not running. What can I do to fix it?

Ken Haduch
@khaduch
Aug 28 2016 02:54
@LisaRamos - what is in the arr - you are trying to iterate through it with that for statement, but ...?
CompGeekGirl
@LisaRamos
Aug 28 2016 02:55
@khaduch I think I was trying to iterate through it with the for statement.
Ken Haduch
@khaduch
Aug 28 2016 02:56
@LisaRamos - what does arr contain? It looks like a variable that you should be using to accumulate results, because that is what you are supposed to return. It starts out as an empty array? Nothing to iterate through?
CompGeekGirl
@LisaRamos
Aug 28 2016 02:57
@khaduch Nope but what could I put in arr?
Adam Jubert
@adamjubert
Aug 28 2016 02:57
@khaduch Thanks, such an obvious error. I fixed that but now it's throwing a TypeError: "Cannot set property 'prop' of undefined"
CamperBot
@camperbot
Aug 28 2016 02:57
adamjubert sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1591 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Aug 28 2016 02:58
@LisaRamos - I haven't re-read the problem, but I think that arr should eventually hold the objects that meet the test condition - for this example call, anything with { last: "Capulet" } as part of an object should be copied to arr during your code execution.
CompGeekGirl
@LisaRamos
Aug 28 2016 02:59
@khaduch Do you think I could remove the for loop instead?
Ken Haduch
@khaduch
Aug 28 2016 03:00
@LisaRamos - no, you need to iterate over that array of objects that are passed in as the collection argument, so I think that your for loop should be used to iterate over collection.
@adamjubert - can you post a new link to your updated code?
CompGeekGirl
@LisaRamos
Aug 28 2016 03:02

@khaduch I used the for loop to iterate over collection but I got a message saying that a target is not defined.

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for (var prop in collection) { 
    if (hasOwnProperty.call(arr, prop)) {
      result.push(prop);
    } else if (Object.prototype.hasOwnProperty.call(source, collection)) {
      target[collection] = source[collection];
    } else {
      return target;
    }
  }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

How can I define a target?

Adam Jubert
@adamjubert
Aug 28 2016 03:04

@khaduch http://codepen.io/anon/pen/qNZPmX

It's something with line 34, but I can't figure out what.

Addy
@asonder
Aug 28 2016 03:04
I'm working on Seek and Destroy. For something like (["tree", "hamburger", 53], "tree", 53), can anyone give me some guidance as to how you can access the elements in the initial array vs. the elements in the outer array.
Joseph
@revisualize
Aug 28 2016 03:05
@LisaRamos What does this: hasOwnProperty.call(arr, prop) ... actually do?
@asonder arguments
CompGeekGirl
@LisaRamos
Aug 28 2016 03:06
@revisualize I think I was trying to return a boolean indicating whether an object has the specified property.
Joseph
@revisualize
Aug 28 2016 03:07
@LisaRamos On one you're doing this:
(hasOwnProperty.call(arr, prop))
in another you're doing this:
(Object.prototype.hasOwnProperty.call(source, collection))
What's the difference?
@LisaRamos I'm working on that challenge as well. And I don't think (hasOwnProperty.call(arr, prop)) is actually doing anything.
CompGeekGirl
@LisaRamos
Aug 28 2016 03:09
@revisualize Now how can I change that?
Joseph
@revisualize
Aug 28 2016 03:09
@LisaRamos Also, if it was doing something.. result.push(prop); ... wouldn't do anything because there is no results variable.
@LisaRamos No idea.
But, it doesn't look right to me.
Adam Jubert
@adamjubert
Aug 28 2016 03:10
@khaduch I found the problem - I was using dot notation when apparently I needed to use bracket notation - now I'm working through the rest.
Joseph
@revisualize
Aug 28 2016 03:10
@LisaRamos I don't see hasOwnProperty as a built in Object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
Ken Haduch
@khaduch
Aug 28 2016 03:10

@adamjubert - you must review the lessons on accessing object properties with dot notation and bracket notation - particularly this one: "Accessing Objects Properties with Variables" - since that is what you need to be doing here, as the id and prop are passed in using the function arguments, which are variables that you use. (Hint: collection.id is not correct, since there is no property in collection named id.) Please review those lessons - it is an important concept!

UPDATE : I see that you realized that...

CompGeekGirl
@LisaRamos
Aug 28 2016 03:10
@revisualize Should I get rid of hasOwnProperty?
Joseph
@revisualize
Aug 28 2016 03:11
@LisaRamos Or fix it.
@LisaRamos I know that there is a Object.prototype.hasOwnProperty() method.
And you do too.
Because you're using it.
But, I'm not sure why you'd use it twice.
@LisaRamos So, you don't have a result variable. Also.. What is target? I don't see that you've defined it anywhere. But, you're returning it.
Adam Jubert
@adamjubert
Aug 28 2016 03:19
@khaduch Thanks... One last question before I just go through and completely re-do the last 10-15 lessons... Now I'm stuck on lines 35-37. I swear I've got it right but it's obviously not working correctly.
CamperBot
@camperbot
Aug 28 2016 03:19
adamjubert sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: adamjubert already gave khaduch points
CompGeekGirl
@LisaRamos
Aug 28 2016 03:19
@revisualize I'm confused and stressed out.
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for (var result = 0; result < collection.length; result++) { 
    if (hasOwnProperty.call(arr)) {
      result.push(arr);
    } else if (Object.prototype.hasOwnProperty.call(source, collection)) {
      target[collection] = source[collection];
    } else {
      return target;
    }
  }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Joseph
@revisualize
Aug 28 2016 03:22
@LisaRamos It's okay. Sometimes it is good to take a break. I'm having a hard time with the challenge myself.
Ken Haduch
@khaduch
Aug 28 2016 03:22
@adamjubert - are you saving your CodePen - I'm still seeing collection.id instead of collection[id]???
CompGeekGirl
@LisaRamos
Aug 28 2016 03:23
@revisualize I can't take a break at all or else I'd be lazy. I have to solve this. Has anyone else done this exercise?
Joseph
@revisualize
Aug 28 2016 03:24
@LisaRamos I got two of the four items to check green.
Adam Jubert
@adamjubert
Aug 28 2016 03:24
@khaduch Sorry! Just saved it.
CompGeekGirl
@LisaRamos
Aug 28 2016 03:25
@revisualize Which ones?
Joseph
@revisualize
Aug 28 2016 03:26
@LisaRamos The first two.
CompGeekGirl
@LisaRamos
Aug 28 2016 03:28
@revisualize Do you mean Intermediate Algorithm Scripting?
Ken Haduch
@khaduch
Aug 28 2016 03:33
@adamjubert - lines 35 - 37. You want to create a property tracks on that particular collection[id] in the situation where you do not have "tracks" there. So you can just to collection[id].tracks = []; and then push to that. collection[id].tracks.push(value); OR you can do it all in one move with collection[id].tracks = [value];
Joseph
@revisualize
Aug 28 2016 03:34
@LisaRamos You know.. Where Art Thou.. The challenge...
blob
This.
Adam Jubert
@adamjubert
Aug 28 2016 03:34
@khaduch Ah I was so close! Thank you for your help, Ken. I was feeling stuck and frustrated. Love the FCC Community.
CamperBot
@camperbot
Aug 28 2016 03:34
adamjubert sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: adamjubert already gave khaduch points
Joseph
@revisualize
Aug 28 2016 03:35
@LisaRamos Or are we both working on different challenges?
CompGeekGirl
@LisaRamos
Aug 28 2016 03:37
@revisualize It's the same challenge.
Ken Haduch
@khaduch
Aug 28 2016 03:39

@LisaRamos - I have to stop, it's late, but I'll just try to direct you in a better direction - instead of naming your for loop variable result, which is misleading, just name it i - it is going to be an index through the collection array. Then something like this:

for ( var i = 0; i < collection.length; i++ ) {
    // now you want to check the collection element that you are looking at for the existence and content of properties
    if ( collection[i].hasOwnProperty( whatever_property_you_need_to_check ) && collection[i][whatever_property_you_need_to_check] === source[ whatever_property_you_need_to_check] ) {
        // you have a matching property and value - this is what you need to be able to add the current object to the result `arr`.
        arr.push(collection[i]);
    }
}

That doesn't get you the entire solution, there is a little more complexity, and I'm sorry it if confuses you even more - but you need to do something like that in order to create the solution to this challenge.

Note that the "whatever_property_you_need_to_check" properties are those properties of the object in the source function argument. You have to have each of the same property and same value that exist in the source in each of the collection objects in order to add it to the solution set, stored in arr, which is what will eventually be returned to the caller of the function.

Joseph
@revisualize
Aug 28 2016 03:44
@khaduch That explanation is exactly where I'm at.
Tonnam Balankua
@tonnamb
Aug 28 2016 03:45
@moigithub thank you!
CamperBot
@camperbot
Aug 28 2016 03:45
tonnamb sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2030 | @moigithub |http://www.freecodecamp.com/moigithub
CompGeekGirl
@LisaRamos
Aug 28 2016 03:45
@khaduch Well, I need to step off for now because it's late and I'm stressing myself over this exercise.
Suzanne Atkinson
@AdventureBear
Aug 28 2016 03:45
so the difference between the Diff Two Arrays challenge and the Symmetric Difference challenge is that the latter may take more than 2 arrays, right?
Ken Haduch
@khaduch
Aug 28 2016 03:52
@revisualize - the complication (as I see it) is that some of the source objects have multiple properties. So you have to set up a loop within the for loop that is iterating over the collection, and then keep track of whether or not all of the properties and values that they contain match. I think that is a bit of a leap in solving this challenge. IT is similar to the other collection challenge with the contacts and firstName matching - you cannot just jump and do something (as in that challenge with return "no such contact";) until you have ferreted out all of the possible matches and mismatches. In fact, in my solution, I kept two variables "matches" and "mismatches", and if there was a property match, I incremented "matches", and if there was a miss, I incremented "mismatches". Then at the end, something like if ( matches && !mismatches) { arr.push(collection[i]); } Just a bit of bookkeeping to fully recognize that the object should be kept in the solution array...
@AdventureBear - yeah, basically that's the situation.
khaduch @khaduch - I hope that helps - I'm checking out for the night...
Suzanne Atkinson
@AdventureBear
Aug 28 2016 03:54
@khaduch thanks
CamperBot
@camperbot
Aug 28 2016 03:54
adventurebear sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1592 | @khaduch |http://www.freecodecamp.com/khaduch
beginnerdidi
@beginnerdidi
Aug 28 2016 04:17
I am stuck what am I doing wrong? myVar = 87 + 1;
myVar = myVar++;
myVar = myVar should be changed
Alexander Køpke
@alexanderkopke
Aug 28 2016 04:20
@beginnerdidi myVar++; is the same as myVar = myVar + 1;
Suraj Prasad
@suraj18gts
Aug 28 2016 04:21
can anyone tell me about the Nesting For Loops
beginnerdidi
@beginnerdidi
Aug 28 2016 04:21
Let me try @alexanderkopke
Joseph Parkton
@hippybear
Aug 28 2016 04:22
@beginnerdidi myVar++ not myVar = myVar++
@suraj18gts
for(var i = 0; i < arr.length; i++){
  for(var a = 0; a < arr.length; a++){
    /* Do something here */
  }
}
Lydia Larae
@nevaIsDreaming
Aug 28 2016 04:24
Can someone take a look at my code for the mutation script and tell me where the mistake is? I've been looking at it for a long time and I can't see where the problem is.
Essaid Serhani
@purelight4ever
Aug 28 2016 04:27
blob
Pleas!! Can some body tell me what is wrong with my codes??
Alexander Køpke
@alexanderkopke
Aug 28 2016 04:28
@nevaIsDreaming Where is your code? ;)
Lydia Larae
@nevaIsDreaming
Aug 28 2016 04:29
@alexanderkopke thanks for asking, but i just figured it out. I had a } in the wrong place.
CamperBot
@camperbot
Aug 28 2016 04:29
nevaisdreaming sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 727 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Aug 28 2016 04:30
@nevaIsDreaming good work!
@beginnerdidi in this example only use ++ to add 1 to myVar. You have myVar = myVar +1; but this is not needed in this challenge.. also myVar = myVar++ is not correct. Just myVar++; that is enough
@beginnerdidi try one more time.. If it doesn't work I will show you the solution. Sometimes it is needed to see it to understand it.
@beginnerdidi var ex = 1; <-- ex is now 1. ex++; <--- now ex is 2; ex++; <-- now ex is 3.
Diego Mayer
@Chrono79
Aug 28 2016 04:35

@purelight4ever for certain records the property tracks could not exist, so you have to create it first

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

https://www.freecodecamp.com/challenges/testing-objects-for-properties
https://www.freecodecamp.com/challenges/add-new-properties-to-a-javascript-object

Alexander Køpke
@alexanderkopke
Aug 28 2016 04:36
@purelight4ever also don't forget to return the collection at the end. I think that is needed
beginnerdidi
@beginnerdidi
Aug 28 2016 04:36
It worked only with myVar++; and deleted all the other codes. Thank you so much for your help @alexanderkopke . I copied your example thank you.
CamperBot
@camperbot
Aug 28 2016 04:36
beginnerdidi sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 728 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Aug 28 2016 04:37
@beginnerdidi good work!
Essaid Serhani
@purelight4ever
Aug 28 2016 04:37
@Chrono79 That's a good point... I will try that Thank you.
CamperBot
@camperbot
Aug 28 2016 04:37
purelight4ever sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1927 | @chrono79 |http://www.freecodecamp.com/chrono79
Essaid Serhani
@purelight4ever
Aug 28 2016 04:38
@alexanderkopke Thank you
CamperBot
@camperbot
Aug 28 2016 04:38
purelight4ever sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 729 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Essaid Serhani
@purelight4ever
Aug 28 2016 04:39
@alexanderkopke Thank you
CamperBot
@camperbot
Aug 28 2016 04:39
purelight4ever sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:warning: purelight4ever already gave alexanderkopke points
Alexander Køpke
@alexanderkopke
Aug 28 2016 04:40
@purelight4ever :+1:
Erick Zhao
@erickzhao
Aug 28 2016 04:51
Hey there, can anyone help me out with the Phone Number problem in the advanced algorithms?
I have a somewhat convoluted solution that removes all the spaces in the phone nums first before testing for 3 possible valid phone number formats in regex.
The space-removing regex isn't working properly and I don't really know why.
Henry Cabello
@hacu9
Aug 28 2016 04:54
im on the Mutations bonfire,is there something wrong with my code?

```var lowCase = arr.toString().toLowerCase();
var split = lowCase.split(",");

if(lowCase.indexOf(split[1]) === 0){
console.log(lowCase,split[1]);
return true;

}else if(lowCase.indexOf(split[1]) === -1) return false;```

Erick Zhao
@erickzhao
Aug 28 2016 04:55
When I test that specific block of code, I get this result, for example: http://i.imgur.com/3D5pAI7.png
Bnobo
@acloud12345678
Aug 28 2016 04:57
guys, I need help with JavaScript: Manipulate Arrays With Pop.
i want to show you guys my code but i don;t know how
DJ
@qualitymanifest
Aug 28 2016 04:58
@erickzhao paste all of your code as formatted text. or put it on repl.it and share the link. or something
Erick Zhao
@erickzhao
Aug 28 2016 04:59
@qualitymanifest
telephoneCheck("1 555-555-5555");

function telephoneCheck(str) {


  str = str.replace("/\s/g","");



  //(555)555-5555

  if (/^1?[(][0-9][0-9][0-9][)][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]/m.test(str)) return true;

  //55555555555

  if (/^1?[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/m.test(str)) return true;

  //555-555-5555

  if (/^1?[0-9][0-9][0-9][-][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]$/m.test(str)) return true;

  return false;


}
my regex for telephone string testing is very unoptimized but that shouldn't be the problem because for example "1555-555-5555" would return true while "1 555-555-5555" returns false. something to do with replacing all spaces for some reason afaik.
DJ
@qualitymanifest
Aug 28 2016 05:01
@erickzhao "/\s/g" that should not be in quotation marks
Erick Zhao
@erickzhao
Aug 28 2016 05:01

@acloud12345678 surround ur code with this (minus the exclamation marks)

`!```javascript

`!```code here

@qualitymanifest thanks a lot lmao i'm a dumbass
CamperBot
@camperbot
Aug 28 2016 05:01
erickzhao sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1381 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Bnobo
@acloud12345678
Aug 28 2016 05:02
@erickzhao thanks, let me try
CamperBot
@camperbot
Aug 28 2016 05:02
acloud12345678 sends brownie points to @erickzhao :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @erickzhao |http://www.freecodecamp.com/erickzhao
DJ
@qualitymanifest
Aug 28 2016 05:03
@erickzhao np. it should work after that. it sounds like you understand this already, but this can be done with one block of regex
Bnobo
@acloud12345678
Aug 28 2016 05:03

`
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray;
var removedFromMyArray = myArray.pop();

```

Joseph
@revisualize
Aug 28 2016 05:03

How to do code block format:
```js [SHIFT+ENTER]
// your code here
```[CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

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

Bnobo
@acloud12345678
Aug 28 2016 05:04
@revisualize ok, let me try

// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray;
var removedFromMyArray = myArray.pop();
Joseph
@revisualize
Aug 28 2016 05:04
You can edit posts.
You can also delete posts.
Bnobo
@acloud12345678
Aug 28 2016 05:04
@revisualize ok, thanks for the information, I may need it later on
CamperBot
@camperbot
Aug 28 2016 05:04
acloud12345678 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1760 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 28 2016 05:06
@acloud12345678 Why are you declaring your variable twice?
Bnobo
@acloud12345678
Aug 28 2016 05:06
@revisualize so I should’t do that?
Joseph
@revisualize
Aug 28 2016 05:06
@acloud12345678 Nope.
Bnobo
@acloud12345678
Aug 28 2016 05:06
@revisualize ok, let me try
Joseph
@revisualize
Aug 28 2016 05:06
var removedFromMyArray; Remove this one line and it should work.
revisualize @revisualize leaves. :8ball:
Bnobo
@acloud12345678
Aug 28 2016 05:07
@revisualize thanks
CamperBot
@camperbot
Aug 28 2016 05:07
acloud12345678 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: acloud12345678 already gave revisualize points
Erick Zhao
@erickzhao
Aug 28 2016 05:10
@hacu9 I'm not sure what your code is doing there. From what I can tell, your indexOf call is just comparing arr.toString().toLowerCase() to the 2nd index of arr, put to all lowercase letters. You also don't have a return value for your function if your two if conditions aren't met. From what I recall, you should be looping through each individual letter to see if it's present in the other string, since you're comparing all characters within the two parameters.
ups,ill try later
Bnobo
@acloud12345678
Aug 28 2016 05:14

i need help with Write Reusable JavaScript with Functions
```js

// Example
function ourReusableFunction() {
console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line


// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
Erick Zhao
@erickzhao
Aug 28 2016 05:14
@Bnobo what's your issue?
Bnobo
@acloud12345678
Aug 28 2016 05:15
oops, I deleted my code right before this
let me try again
@erickzhao
```js

// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
var reusableFunction("Hi Wolrd");
Erick Zhao
@erickzhao
Aug 28 2016 05:18
@Bnobo the syntax the create a new function in JS is
function myFunction(parameters){
//function body
}
Bnobo
@acloud12345678
Aug 28 2016 05:19
@erickzhao ok, let me try
THalletProtech
@THalletProtech
Aug 28 2016 05:19
@acloud12345678 you are calling your function a variable
Bnobo
@acloud12345678
Aug 28 2016 05:20
@erickzhao I do not know how to use that, sorry
@THalletProtech I deleted the "var" in front of "myFunction"
THalletProtech
@THalletProtech
Aug 28 2016 05:22
you must initilize your function like in erikz code... replace var with function
Bnobo
@acloud12345678
Aug 28 2016 05:22
it says I am missing formal parameter
oh, wait
THalletProtech
@THalletProtech
Aug 28 2016 05:23
refer to the example above your code
Bnobo
@acloud12345678
Aug 28 2016 05:23
ok
but I don't know what to put in for "parameters"
Erick Zhao
@erickzhao
Aug 28 2016 05:24
its optional
Bnobo
@acloud12345678
Aug 28 2016 05:24
so do I just delete that part, or do I leave it the way it is
Erick Zhao
@erickzhao
Aug 28 2016 05:24
leave empty!
Bnobo
@acloud12345678
Aug 28 2016 05:24
ok
also, what do I type in for //function body
Erick Zhao
@erickzhao
Aug 28 2016 05:25
whatever you need to type
Bnobo
@acloud12345678
Aug 28 2016 05:25
it is still not meeting the requirements

// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
function myFunction(){
myFunction("Hi World");
}
THalletProtech
@THalletProtech
Aug 28 2016 05:27
@erickzhao Whats up
Erick Zhao
@erickzhao
Aug 28 2016 05:27
The example function they give functions the same way
Bnobo
@acloud12345678
Aug 28 2016 05:28

// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
function myFunction(){
reusableFunction(){
  console.log("Hi World");
}
}
Chris Cullen
@123xylem
Aug 28 2016 05:28
This message was deleted
function cpu() { //CPU move chosen from random choice var
  if (userX) {
    if (answer.indexOf("A") >= 0 && answer.indexOf("C") >= 0) {
      $("#B").text("O").css("color", "blue");
    } else if (answer.indexOf("A") >= 0 && answer.indexOf("I") >= 0) {
      $("#E").text("O").css("color", "blue");
    } else if (answer.indexOf("A") >= 0 && answer.indexOf("G") >= 0) {
      $("#D").text("O").css("color", "blue");
    } else if (answer.indexOf("B") >= 0 && answer.indexOf("H") >= 0) {
      $("#E").text("O").css("color", "blue");
    } else if (answer.indexOf("C") >= 0 && answer.indexOf("I") >= 0) {
      $("#F").text("O").css("color", "blue");
    } else if (answer.indexOf("C") >= 0 && answer.indexOf("G") >= 0) {
      $("#E").text("O").css("color", "blue");
    } else if (answer.indexOf("D") >= 0 && answer.indexOf("F") >= 0) {
      $("#E").text("O").css("color", "blue");
    } else {
      $("#" + choice + "").text("O").css("color", "blue");
      cpuAnswer.push(choice.toUpperCase());    console.log(cpuAnswer);

    }
QUESTION:
Here im saying if user moves to within 1 move of winning Get AI to take that winnning move... Are my if else statements correct?
My code is lagging with this and I dont think it works for some reason?
Bnobo
@acloud12345678
Aug 28 2016 05:33
guys?
Chris Cullen
@123xylem
Aug 28 2016 05:33
If I go to position A and C cpu freezes... It should go to B
THalletProtech
@THalletProtech
Aug 28 2016 05:34
i think you have to call your function @acloud12345678
refer to code above it your should be similar
Bnobo
@acloud12345678
Aug 28 2016 05:34
it says that it was already called, but it says reusableFunction is not a function yet
it also says that it has to output "Hi World" to the dev console
THalletProtech
@THalletProtech
Aug 28 2016 05:35
you have 2 functions
Bnobo
@acloud12345678
Aug 28 2016 05:35
I don't understand what you mean
THalletProtech
@THalletProtech
Aug 28 2016 05:36
function myFunction() should be function reusableFunction()
Bnobo
@acloud12345678
Aug 28 2016 05:37
okay, that's one part, there is still another part,
reusableFunction should output "Hi World" to the dev console
THalletProtech
@THalletProtech
Aug 28 2016 05:37
call the function
repost your code @acloud12345678
Bnobo
@acloud12345678
Aug 28 2016 05:38
ok

// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
function reusableFunction() {
reusableFunction(); {
  console.log("Hi World");
}
}
Erick Zhao
@erickzhao
Aug 28 2016 05:38
@bnobo myFunction() should look exactly like ourReusableFunction()
Bnobo
@acloud12345678
Aug 28 2016 05:39
it doesn't work @erickzhao
Erick Zhao
@erickzhao
Aug 28 2016 05:41
look at the syntax in the example function
it should be the same in your function
THalletProtech
@THalletProtech
Aug 28 2016 05:42

// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
//this line below is where you named the function. Good!
function reusableFunction() { 
//this line below is not needed
reusableFunction(); {
  console.log("Hi World");
}//this bracket isnt needed either
}
Erick Zhao
@erickzhao
Aug 28 2016 05:43
a function is basically a reusable block of code
writing reusableFunction(); on a line will execute all the code within the reusableFunction function declaration
Bnobo
@acloud12345678
Aug 28 2016 05:44
@THalletProtech it doesn't work when I delete the line
@erickzhao i don;t know what you mean
THalletProtech
@THalletProtech
Aug 28 2016 05:45
repost code
Bnobo
@acloud12345678
Aug 28 2016 05:45

// Example
function ourReusableFunction() {
  console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
function reusableFunction() { 
//this line below is not needed

  console.log("Hi World");
}
THalletProtech
@THalletProtech
Aug 28 2016 05:45
looks good
now all you need to do is use the function so it wil return the value
Bnobo
@acloud12345678
Aug 28 2016 05:46
how do I do that?
THalletProtech
@THalletProtech
Aug 28 2016 05:46
refer to last line of example
Bnobo
@acloud12345678
Aug 28 2016 05:47
thanks @THalletProtech
CamperBot
@camperbot
Aug 28 2016 05:47
acloud12345678 sends brownie points to @thalletprotech :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @thalletprotech |http://www.freecodecamp.com/thalletprotech
Bnobo
@acloud12345678
Aug 28 2016 05:47
it finally worked
@erickzhao thanks for trying to help me as well
CamperBot
@camperbot
Aug 28 2016 05:47
acloud12345678 sends brownie points to @erickzhao :sparkles: :thumbsup: :sparkles:
:warning: acloud12345678 already gave erickzhao points
THalletProtech
@THalletProtech
Aug 28 2016 05:48
@erickzhao whats up
Erick Zhao
@erickzhao
Aug 28 2016 05:49
hi
yw
THalletProtech
@THalletProtech
Aug 28 2016 05:50
why you up so lat @erickzhao
late*
lol
Ryan Malm
@Rybar
Aug 28 2016 05:52
hi
Chris Cullen
@123xylem
Aug 28 2016 05:54
function cpu() { //CPU move chosen from random choice var
  if (userX) {
    if (answer.indexOf("A") >= 0 && answer.indexOf("C") >= 0) {
      $("#B").text("O").css("color", "blue");
    } else if (answer.indexOf("A") >= 0 && answer.indexOf("I") >= 0) {
      $("#E").text("O").css("color", "blue");
    } 
    } else {  //if human not 1 move from winning pick randomly
      $("#" + choice + "").text("O").css("color", "blue");
      cpuAnswer.push(choice.toUpperCase());    console.log(cpuAnswer);

    }
QUESTION:
Here im saying if user moves to within 1 move of winning Get AI to take that winnning move... Are my if else statements correct?
My code is lagging with this and I dont think it works for some reason?
If I go to position A and C cpu freezes... It should go to B
Joseph Parkton
@hippybear
Aug 28 2016 06:00
@123xylem whats the rest of the code?
@hippybear
@hippybear ah my id boxes are lower case
Jose Escobar Mejia
@mejiaadonay
Aug 28 2016 06:14
Hey guys do any one knows, why there is a zero at the end of the function var singleVal = array.reduce(function(previousVal, currentVal) {
return previousVal - currentVal;
}, 0);
jamesmillerho
@jamesmillerho
Aug 28 2016 06:14
-.-
blob
..
@mejiaadonay 0 means the type
THalletProtech
@THalletProtech
Aug 28 2016 06:16
@mejiaadonay i was wondering that earlier
jamesmillerho
@jamesmillerho
Aug 28 2016 06:16
@mejiaadonay what do you want the reduced thing to be - 0 is a number - it means start at 0 - and the result will also be a number
Jose Escobar Mejia
@mejiaadonay
Aug 28 2016 06:19

Ok because I complete the challenge, to add all elements together, and I didn't add any number at the end, and it works perfectly fine. But thanks guys. var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

singleVal = array.reduce(function(previousVal, currentVal) {
return previousVal + currentVal;
});

Jeremy Redkey
@jeremyredkey
Aug 28 2016 06:31
Hey can anyone help me with debugging this Javascript code? It seems my issue is on "Line 126" Synthax Error: Unexpected End... Yet everything seems to be there to my eyes at least
//variables section

var canvas;
var canvasContext;
var ballX = 50;
var ballY = 50;
var ballSpeedX = 10;
var ballSpeedY = 4;

var paddle1Y = 250;
const PADDLE_HEIGHT = 100; 
// C Programming #define (ALWAYS CONSTANT)

/*
Observing returning event (evt) of mouse positioning coordinates in relation to where the mouse is on the "gameCanvas"
For example starting point on the "gameCanvas" is on (0,0) on the (y,x) axis
EventListener wouldn't care about mouse position or "mousePos" if this code wasn't here
Two piece of data are being returned here... mouseX and mouseY
*/

function calculateMousePos(evt) {
    var rect = canvas.getBoundingClientRect();
    var root = document.documentElement;
    var mouseX = evt.clientX - rect.left - root.scrollLeft;
    var mouseY = evt.clientY - rect.top - root.scrollTop;
    return {
        x:mouseX,
        y:mouseY
        };

}

//variables section


//Speed of objects & EventListener & Resetting the Ball section

window.onload = function () {
    canvas = document.getElementById('gameCanvas');
    canvasContext = canvas.getContext('2d');

    var framesPerSecond = 30;
    setInterval(function() {
        moveEverything();
        drawEverything();
      }, 1000/framesPerSecond );

    canvas.addEventListener('mousemove',
        function(evt) {
            var mousePos = calculateMousePos(evt);
            paddle1Y = mousePos.y-(PADDLE_HEIGHT/2); //So players mouse and paddle relationship position is center
            });
}

function moveEverything() {
    ballX = ballX + ballSpeedX;
    ballY = ballY + ballSpeedY
    if(ballX < 0) {
        if(ballY > paddle1Y &&
        ballY < paddle1Y+PADDLE_HEIGHT) {
                ballSpeedX = -ballSpeedX;
        } else {
        ballReset();    }

    if(ballX > canvas.width) {
        ballSpeedX = -ballSpeedX;
    }

    if(ballY < 0) {
        ballSpeedY = -ballSpeedY;
    }
    if(ballY > canvas.height) {
        ballSpeedY = -ballSpeedY;
    }

//Speed of objects & EventListener & Resetting the Ball section


//Ball Reset f(x) section

function ballReset() {
     ballSpeedX = -ballSpeedX;
    ballX = canvas.width/2;
    ballY = canvas.height/2;
}



//Ball Reset f(x) section



//canvas arguments/parameters

function drawEverything () {

    // next line blanks out the screen with black
    colorRect(0,0,canvas.width,canvas.height,'black');

    // this left player paddle
    colorRect(0,paddle1Y,10,100,'white');

    // next line draws the ball
    colorCircle(ballX,ballY,10,'white');
}



function colorCircle(centerX, centerY, radius, drawColor) { 
canvasContext.fillStyle = drawColor; 
canvasContext.beginPath(); 
canvasContext.arc(centerX, centerY, radius, 0,Math.PI*2,true); 
canvasContext.fill(); 

} 


function colorRect(leftX,topY, width,height, drawColor) { 
canvasContext.fillStyle = drawColor; 
canvasContext.fillRect(leftX,topY, width,height); 

}

//canvas arguments/parameters
jamesmillerho
@jamesmillerho
Aug 28 2016 06:34
-.-
Surya Prakash
@Surya96t
Aug 28 2016 06:34
Hello,
jamesmillerho
@jamesmillerho
Aug 28 2016 06:35
@Surya96t ?
Surya Prakash
@Surya96t
Aug 28 2016 06:36

I'm having trouble in understanding string immutability and I'm not sure what needs to be fixed in this code // Setup
var myStr = "Jello World";

// Only change code below this line

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

billpzt
@billpzt
Aug 28 2016 06:36
Hey there, having some problems with the Seek and Destroy challenge. I read the page that talks about argument objects, and thought I could start out by using a loop and pushing everything into an array. Turns out the first part of "arguments" is an array when you look at it but isn't treated as a separate thing when you run the loop, so that threw my whole reasoning out the window, and now I have no idea what to do next! Can anyone help?
function destroyer(arr) {
  // Remove all the values
  var firstArray = arguments;
  for (var i = 0; i < arguments.length; i++) {
    firstArray.push(arguments[i]);
  }
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Patrick
@patricktownley
Aug 28 2016 06:37
@Surya96t Since strings are immutable, you can't change a character at a given index of a string. You have to build a new string, using your new character and the rest of the old string
@billpzt There's a link on the exercise page to the MDN entry for Arguments - that should have instructions to help you out
Surya Prakash
@Surya96t
Aug 28 2016 06:38
So I should assign a new string to myStr
billpzt
@billpzt
Aug 28 2016 06:39
@patricktownley yeah, that's the page I meant when I said I had read about argument objects!
jamesmillerho
@jamesmillerho
Aug 28 2016 06:39
@billpzt var firstArray = Array.from(arguments)
Patrick
@patricktownley
Aug 28 2016 06:39
Yea - that bit :)
jamesmillerho
@jamesmillerho
Aug 28 2016 06:40
@billpzt if you want [1, 2, 3, 1, 2, 3] - the 1st arguments - just say arr(the parameter of the function)
billpzt
@billpzt
Aug 28 2016 06:40
@jamesmillerho Cool, never heard of that from function before...
Surya Prakash
@Surya96t
Aug 28 2016 06:40

is this correct
// Setup
var myStr = "Jello World";

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

jamesmillerho
@jamesmillerho
Aug 28 2016 06:42
@Surya96t
// You need to totally rewrite the string - since it is immutable
my Str = "Hello World";
// or
myStr = myStr.replace("J","H");
billpzt
@billpzt
Aug 28 2016 06:42
@billpzt if you want [1, 2, 3, 1, 2, 3] - the 1st arguments - just say arr(the parameter of the function)
@jamesmillerho but the problem is I don't know in advance how many arguments they're going to give me. I know the first is supposed to be an array, but then how do I handle the others if I don't know how many of them there'll be? THat's why I thought of making a loop and pushing each thing into a new array, which didn't work as expected...
jamesmillerho
@jamesmillerho
Aug 28 2016 06:43
@billpzt Array.from(arguments) will take all
Patrick
@patricktownley
Aug 28 2016 06:43
@billpzt Also bear in mind when you convert arguments to an array in that exercise, the first element is an array, and the remaining elements are the elements to be added to it
jamesmillerho
@jamesmillerho
Aug 28 2016 06:44
@billpzt If you want every arguments OTHER than the first one - arr - just use the common slice funciton
Array.from(arguments).slice(1);
Surya Prakash
@Surya96t
Aug 28 2016 06:45
@jamesmillerho Thank you
CamperBot
@camperbot
Aug 28 2016 06:45
surya96t sends brownie points to @jamesmillerho :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @jamesmillerho |http://www.freecodecamp.com/jamesmillerho
billpzt
@billpzt
Aug 28 2016 06:45
@billpzt Array.from(arguments) will take all
@jamesmillerho cool, will try that
@patricktownley I know, that's a big part of what got me confused
Ok, will try this stuff out and see how it goes! Thanks @jamesmillerho @patricktownley
CamperBot
@camperbot
Aug 28 2016 06:47
billpzt sends brownie points to @jamesmillerho and @patricktownley :sparkles: :thumbsup: :sparkles:
:cookie: 408 | @jamesmillerho |http://www.freecodecamp.com/jamesmillerho
:cookie: 282 | @patricktownley |http://www.freecodecamp.com/patricktownley
jamesmillerho
@jamesmillerho
Aug 28 2016 06:47
@billpzt
Seek and Destroy answer for reference (but I won't explain -.-)
function destroyer(arr){
  var extra = Array.from(arguments).slice(1);
  return arr.filter(function(a){return !extra.includes(a);});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Dan Couper
@DanCouper
Aug 28 2016 06:48
Arguments is literally all the arguments passed to the function. All you're saying is that your variable firstArray is [1,2,3,1,2,3], 2, 3. It isn't an array. You already have the initial array, it's named as arr.
@billpzt
billpzt
@billpzt
Aug 28 2016 06:51
@DanCouper Still doesn't make much sense to me, but OK :smile:
@jamesmillerho I have access to the solution page on Github, but I wanted to understand the process :smile:
Dan Couper
@DanCouper
Aug 28 2016 06:53
You always have that first array: you know, in advance, that the function will be given an array, plus 0 or more single numbers. arr is that array. Those numbers aren't named
Chris Cullen
@123xylem
Aug 28 2016 06:54
This message was deleted
else if (answer.indexOf("D") >= 0 && answer.indexOf("F") >= 0) {
  $("#e").text("O").css("color", "blue");
  if (answer.indexOf("E") >= 0 || cpuAnswer.indexOf("E") >= 0) {
    $("#" + choice + "").text("O").css("color", "blue");
    cpuAnswer.push(choice.toUpperCase());

  }
}
    else if (answer.indexOf("H") >= 0 && answer.indexOf("I") >= 0) {
  $("#g").text("O").css("color", "blue");
  if (answer.indexOf("G") >= 0 || cpuAnswer.indexOf("G") >= 0) {
    $("#" + choice + "").text("O").css("color", "blue");
    cpuAnswer.push(choice.toUpperCase());

  }
}else {
  $("#" + choice + "").text("O").css("color", "blue");
  cpuAnswer.push(choice.toUpperCase());
  console.log(cpuAnswer);

}
The computer will console.log the correct move in certain situations but wont place its O in the box. Can you help me debug this?
http://codepen.io/123xylem/pen/JKqYZY?editors=0011
billpzt
@billpzt
Aug 28 2016 06:55
@DanCouper Well that's the point, if they aren't named I don't see any way to access them to use in a filter later!
jamesmillerho
@jamesmillerho
Aug 28 2016 06:55
@123xylem
blob
:)
Chris Cullen
@123xylem
Aug 28 2016 06:58
@jamesmillerho not helpful bro i seen it the first time
its a graphics issue
just needs a timeout to fix
Patrick
@patricktownley
Aug 28 2016 06:59
@billpzt You can get them from the arguments object:
var elementsToRemove = Array.from(arguments).slice(1);
Dan Couper
@DanCouper
Aug 28 2016 06:59
Inside a function, arguments is a collection of all the arguments. But you can't do much with it because it isn't an array, so you need to make it into an array.
billpzt
@billpzt
Aug 28 2016 07:01
This message was deleted
Jeremy Redkey
@jeremyredkey
Aug 28 2016 07:02
thank you @ricardomga you really helped me man!
CamperBot
@camperbot
Aug 28 2016 07:02
:cookie: 291 | @ricardomga |http://www.freecodecamp.com/ricardomga
jeremyredkey sends brownie points to @ricardomga :sparkles: :thumbsup: :sparkles:
billpzt
@billpzt
Aug 28 2016 07:03
@patricktownley So will the slice function
alter the original argument, leaving me with the array in one variable and the remaining arguments in another?
Dan Couper
@DanCouper
Aug 28 2016 07:03
No, spice copies
Slice
Patrick
@patricktownley
Aug 28 2016 07:03
@billpzt You already have the original array in the variable arr
Dan Couper
@DanCouper
Aug 28 2016 07:03
You do not ever want to change the actual arguments
The sky will rain blood
Etc etc
billpzt
@billpzt
Aug 28 2016 07:04
@DanCouper That's what I tried to do first with my loop, (get what's in arguments into an array) but instead of treating the actual array as one unit it started to copy each number in it one by one
Egoscio
@Egoscio
Aug 28 2016 07:04
Why doesn't javascript make mutating optional, like other languages
Jeremy Redkey
@jeremyredkey
Aug 28 2016 07:04
@ricardomga I did that I think.....```
function calculateMousePos(evt) {
    var rect = canvas.getBoundingClientRect();
    var root = document.documentElement;
    var mouseX = evt.clientX - rect.left - root.scrollLeft;
    var mouseY = evt.clientY - rect.top - root.scrollTop;
    return {
        x:mouseX,
        y:mouseY
        };

}
billpzt
@billpzt
Aug 28 2016 07:05
Well, I better think more about this before asking more questions, or go to sleep, it's 4 AM here already hahaha
Dan Couper
@DanCouper
Aug 28 2016 07:07
Yes, but what you were doing was saying the variable you declared was the arguments, and then tried values into it
billpzt
@billpzt
Aug 28 2016 07:07
@DanCouper @patricktownley Thanks!
CamperBot
@camperbot
Aug 28 2016 07:07
billpzt sends brownie points to @dancouper and @patricktownley :sparkles: :thumbsup: :sparkles:
:cookie: 198 | @dancouper |http://www.freecodecamp.com/dancouper
:warning: billpzt already gave patricktownley points
billpzt
@billpzt
Aug 28 2016 07:08
@DanCouper I don't know what the heck I'm doing anymore, I better go to sleep and try again after I wake up :laughing:
Dan Couper
@DanCouper
Aug 28 2016 07:10
What you wanted was the original array + the other numbers - how you get the other numbers is how @patricktownley said - use make an array from the arguments, then you can slice off a copy all bit the first
@billpzt it may take a while, but it will click eventually :)
Patrick
@patricktownley
Aug 28 2016 07:11
A night's sleep always helps. Fresh approach to the problem
THalletProtech
@THalletProtech
Aug 28 2016 07:12
i agree @patricktownley
billpzt
@billpzt
Aug 28 2016 07:14
@DanCouper @patricktownley I see now I was ignoring the fact that the index was (1) and not (0), I kept thinking that line was about the initial array, the whole time you two were trying to explain to me something and I was thinking of something else!
Dan Couper
@DanCouper
Aug 28 2016 07:15
Ah, I see where the confusion came from. :)
billpzt
@billpzt
Aug 28 2016 07:17
Well, now I've got some thinking to do before I go asking more questions. Thanks again! Good night (or morning or evening or whatever it is where you are)
 p.globalCompositeOperation = "source-over";
p.fillStyle = "rgba(0, 0, 0, 0.5)";
p.fillRect(0,0,w,h);
 p.globalCompositeOperation = "lighter";
how p.fillStyle = "rgba(0, 0, 0, 0.5)"; gives the effect?
jugglingjsons
@jadczakd
Aug 28 2016 08:16
Hey could someone help me out a bit?I am doing Basic Algorith Scripting and am struggling a bit on the "Return Largest Numbers in Arrays" Here's what I have

function largestOfFour(arr) {
  var results =[];
   for (i = 0 ; i<arr.length; i++){
   var largestNumber;
     for(j = 0 ; j<arr[i].length; j++){
       if(arr[i][j]>largestNumber){
         largestNumber=arr[i][j];
         results+=[largestNumber];
       }
     }
    }
  return results;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Darth Skywalker
@adityaparab
Aug 28 2016 08:19
@jadczakd : Almost there mate!
jugglingjsons
@jadczakd
Aug 28 2016 08:19
I know the iterations are ok. Just don't know how to print the result into results haha
Darth Skywalker
@adityaparab
Aug 28 2016 08:19

your results is an Array. Not a string or number.

results+=[largestNumber];

is not how you add elements to the array

jugglingjsons
@jadczakd
Aug 28 2016 08:19
I know the results += in the example given is wrong, as it would in theory print all the numbers, If it ever printed anything.
Darth Skywalker
@adityaparab
Aug 28 2016 08:19
you'd have to use .push function.
jugglingjsons
@jadczakd
Aug 28 2016 08:20
Allright! cheers, I think I have it! That was quick!
Darth Skywalker
@adityaparab
Aug 28 2016 08:20
:D
cristiantoporascu
@cristiantoporascu
Aug 28 2016 08:22
Hi. I don't understand what I am supposed to do.... I'm on Chapter "Record Collection" of JavaScript..... And the task is quite vague.... If someone can explain is to me or can give me any kind of Hint...
jugglingjsons
@jadczakd
Aug 28 2016 08:27

@adityaparab Thanks mate. Done!


function largestOfFour(arr) {
  var results =[];
   for (i = 0 ; i<arr.length; i++){
   var largestNumber = 0;
   for(j = 0 ; j<arr[i].length; j++){
     if(arr[i][j]>largestNumber){
         largestNumber=arr[i][j];
       }
     }
     results.push(largestNumber);
    }
  return results;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

I know there is a Math.max() as well, although I find it rather problematic to put it to work with multi-dimensional arrays, any pointer as to how to?

CamperBot
@camperbot
Aug 28 2016 08:27
jadczakd sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 635 | @adityaparab |http://www.freecodecamp.com/adityaparab
Moyosore Fagunwa
@moyo92
Aug 28 2016 08:31
Hi, I tried the Title Case a Sentence Challenge and the console's answer looks correct but I'm not completing the challege

function titleCase(str) {
var arrStr= str.split(" ");
var titleStr=[];
for (var i=0;i<arrStr.length;i++){
titleStr += arrStr[i].charAt(0).toUpperCase() + arrStr[i].slice(1).toLowerCase();
titleStr+= " ";
}
titleStr.trim();
return titleStr;
}

titleCase("sHoRt AnD sToUt");

Darth Skywalker
@adityaparab
Aug 28 2016 08:35

@jadczakd : Perfect mate!

Here is another way to do it. :D

function largestOfFour(arr) {
  return arr.map(function(a){
    return Math.max.apply(null, a);
  });
}
@moyo92 : Is there any specific case that is failing?
Eliz
@elizso
Aug 28 2016 08:37
Screen Shot 2016-08-28 at 4.36.52 PM.png
What is this asking us to do?
Darth Skywalker
@adityaparab
Aug 28 2016 08:37
@moyo92 : Okay, it's strange that the console output look correct.
Your titleStr is an Array. titleStr += is not how you add elements to the array. You will need to use .push instead.
@Elizso : Basically, It is asking you to convert that switch chain into an Object. You need to construct your object in such a way that the case name is the key and the value that you assign to result in each case is the corresponding value of that key.
Then you query this object using val (the key) and return value for that key.
Chris Cullen
@123xylem
Aug 28 2016 08:41
This message was deleted
function cpu() { //CPU move chosen from random choice var
if (userX) {
if (choices.length < 1) {
alert("DRAW GAME");
end();
}
if (answer.indexOf("A") >= 0 && answer.indexOf("C") >= 0&& answer.indexOf("B") <= 0 || cpuAnswer.indexOf("B") <= 0) {
$("#b").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
} else if (answer.indexOf("A") >= 0 && answer.indexOf("I") >= 0&& answer.indexOf("E") <= 0 || cpuAnswer.indexOf("E") <= 0) {
$("#e").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
} else if (answer.indexOf("A") >= 0 && answer.indexOf("G") >= 0&& answer.indexOf("D") <= 0 || cpuAnswer.indexOf("D") <= 0) {
$("#d").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
} else if (answer.indexOf("B") >= 0 && answer.indexOf("H") >= 0&&answer.indexOf("E") <= 0 || cpuAnswer.indexOf("E") <= 0) {
$("#e").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
}
else if (answer.indexOf("C") >= 0 && answer.indexOf("I") >= 0&&answer.indexOf("F") <= 0 || cpuAnswer.indexOf("F") <= 0) {
$("#f").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
} else if (answer.indexOf("C") >= 0 && answer.indexOf("G") >= 0&&answer.indexOf("E") <= 0 || cpuAnswer.indexOf("E") <= 0) {
$("#e").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
} else if (answer.indexOf("C") >= 0 && answer.indexOf("B") >= 0&& answer.indexOf("A") <= 0 || cpuAnswer.indexOf("A") <= 0) {
$("#a").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
}
else if (answer.indexOf("E") >= 0 && answer.indexOf("F") >= 0&&answer.indexOf("D") <= 0 || cpuAnswer.indexOf("D") <= 0) {
$("#d").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
}
else if (answer.indexOf("D") >= 0 && answer.indexOf("F") >= 0&&answer.indexOf("E") <= 0 || cpuAnswer.indexOf("E") <= 0) {
$("#e").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
}
else if (answer.indexOf("H") >= 0 && answer.indexOf("I") >= 0&&answer.indexOf("G") <= 0 || cpuAnswer.indexOf("G") <= 0) {
$("#g").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
}
else {
$("#" + choice + "").text("O").css("color", "blue");
cpuAnswer.push(choice.toUpperCase());
console.log(cpuAnswer);
}}
if (cpuAnswer.indexOf("A") >= 0 && cpuAnswer.indexOf("B") >= 0 && cpuAnswer.indexOf("C") >= 0) {
alert("you win!");
setTimeout(function() { end() }, 400);
} else if (cpuAnswer.indexOf("D") >= 0 && cpuAnswer.indexOf("E") >= 0 && cpuAnswer.indexOf("F") >= 0) {
alert("Cpu win!");
setTimeout(function() { end() }, 400);
} else if (cpuAnswer.indexOf("G") >= 0 && cpuAnswer.indexOf("H") >= 0 && cpuAnswer.indexOf("I") >= 0) {
alert("Cpu win!");
setTimeout(function() { end() }, 300);
} else if (cpuAnswer.indexOf("A") >= 0 && cpuAnswer.indexOf("D") >= 0 && cpuAnswer.indexOf("G") >= 0) {
alert("CPU win!");
setTimeout(function() { end() }, 300);
} else if (cpuAnswer.indexOf("B") >= 0 && cpuAnswer.indexOf("E") >= 0 && cpuAnswer.indexOf("H") >= 0) {
alert("CPU win!");
setTimeout(function() { end() }, 300);
} else if (cpuAnswer.indexOf("C") >= 0 && cpuAnswer.indexOf("F") >= 0 && cpuAnswer.indexOf("I") >= 0) {
alert("CPU win!");
setTimeout(function() { end() }, 400);
} else if (cpuAnswer.indexOf("A") >= 0 && cpuAnswer.indexOf("E") >= 0 && cpuAnswer.indexOf("I") >= 0) {
alert("CPU win!");
setTimeout(function() { end() }, 400);
} else if (cpuAnswer.indexOf("C") >= 0 && cpuAnswer.indexOf("E") >= 0 && cpuAnswer.indexOf("G
Can you helpwith this bracket problem? I just cant find the bug? It says unexpected else statement
cristiantoporascu
@cristiantoporascu
Aug 28 2016 08:50
This message was deleted
Moyosore Fagunwa
@moyo92
Aug 28 2016 08:51
@adityaparab Nope, it all works well. If you don't mind my asking, how do you copy the text editor?
cristiantoporascu
@cristiantoporascu
Aug 28 2016 08:52

Hi. I don't understand what I am supposed to do.... I'm on Chapter "Record Collection"..... And the task is quite vague.... If someone can explain is to me or can give me any kind of Hint...

Record Collection
You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.

Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.

If value is empty (""), delete the given prop property from the album.

Joseph
@revisualize
Aug 28 2016 08:54
@cristiantoporascu Let me get you some info.
@cristiantoporascu It's basically the instructions.
cristiantoporascu
@cristiantoporascu
Aug 28 2016 08:56
@Joseph Thank you very much. I'll try and see if it works.
Joseph
@revisualize
Aug 28 2016 08:57
@cristiantoporascu If a variable name is "Joseph" console.log "Joseph is awesome".
if (name === "Joseph") {
    console.log("Joseph is awesome");
}
I'm a little intoxicated. Let me fix that.
Fixed!
Dany Din
@danydin
Aug 28 2016 08:59
any short explanation about the differnce between classes and constructors?
Joseph
@revisualize
Aug 28 2016 08:59
@cristiantoporascu So, What's your function.
@danydin hashtag-nope.
Dany Din
@danydin
Aug 28 2016 08:59
why @cryin
@revisualize pleasee joseph everyone is sleepin
Joseph
@revisualize
Aug 28 2016 09:03
@danydin Do you realize that it is 202am in Seattle.... AND!!! I am in this chat room.... Let's just say that I am ... NOT ... the most... sober of individuals.
Dany Din
@danydin
Aug 28 2016 09:04
ya i belive but ur pro enough to handle it even thats late :p
are you really so passionated about it that you are here so late?!
Joseph
@revisualize
Aug 28 2016 09:04
I can google some bull:ship: for you. smiley face?
Dany Din
@danydin
Aug 28 2016 09:05
i've done it just made it harder for me to grasp
and 5 extra tabs to the already 539058430 tabs opened
Joseph
@revisualize
Aug 28 2016 09:05
Okay... So... A constructor vs a class
Dany Din
@danydin
Aug 28 2016 09:05
yay <3
Joseph
@revisualize
Aug 28 2016 09:05
I really wish @llamatarianism was awake.
Dany Din
@danydin
Aug 28 2016 09:06
xd
Joseph
@revisualize
Aug 28 2016 09:06
Let's see.
Dany Din
@danydin
Aug 28 2016 09:12
who can help me with tests jasimne??
Joseph
@revisualize
Aug 28 2016 09:12
i asked for outside help
Dany Din
@danydin
Aug 28 2016 09:12
i need a freakin* mentor @revisualize
Joseph
@revisualize
Aug 28 2016 09:12
me too.
Dany Din
@danydin
Aug 28 2016 09:13
sure lets make tandem then
Joseph
@revisualize
Aug 28 2016 09:13
But! I am drunk.
Dany Din
@danydin
Aug 28 2016 09:13
from?
Serenity
@qmikew1
Aug 28 2016 09:13
ok what's the issue
Joseph
@revisualize
Aug 28 2016 09:13
I'd seriously be like the worst mentor ever.
YAY!
@danydin !
Dany Din
@danydin
Aug 28 2016 09:14
your pray has been workin out hopefully
our*
Joseph
@revisualize
Aug 28 2016 09:14
Ask your crazy quesiton.
polak90
@polak90
Aug 28 2016 09:14
u wanna know wats a class constructor??
@danydin
Joseph
@revisualize
Aug 28 2016 09:14
@polak90 !!!!
Dany Din
@danydin
Aug 28 2016 09:14
yess
Joseph
@revisualize
Aug 28 2016 09:14
Class vs Constructor!
Dany Din
@danydin
Aug 28 2016 09:14
im lost
Joseph
@revisualize
Aug 28 2016 09:14
SMART PEOPLE!
YAY!
Seriously... I just cheered.. I'm in a bar eating food and I just cheered out loud.
Serenity
@qmikew1
Aug 28 2016 09:15
well, first thing.... this is JS not java - so, class in JS is 'sugar' and doesn't mean the same thing (I think I've said that sentence three times today - at least in es6 where you will see that terminology )
Dany Din
@danydin
Aug 28 2016 09:16
also
// AddressBook is a class?
function AddressBook() {
    this.contacts = [];
}
// is this creats a custom function under AddressBook construcotr?
AddressBook.prototype.addContact = function(contact) {
    this.contacts.push(contact);
}
@qmikew1 i don't know java but i've read its diff than in java and c++
Serenity
@qmikew1
Aug 28 2016 09:17
hang on a second
Dany Din
@danydin
Aug 28 2016 09:18
sure
Joseph
@revisualize
Aug 28 2016 09:18
JOURNEY!
HER WE STAND!
WORLDS APART!
polak90
@polak90
Aug 28 2016 09:19
a constructor does not belong to any class it is used to define a class
Joseph
@revisualize
Aug 28 2016 09:19
HEARTS BROKEN IN TWO... TWO ... TWO!
Serenity
@qmikew1
Aug 28 2016 09:19
it's an object
but hang on
Dany Din
@danydin
Aug 28 2016 09:19
@polak90 ok collberate please :)
and sure @qmikew1
Serenity
@qmikew1
Aug 28 2016 09:20
yes it's a constructer - but it has different properties because it's a constructor vs an object literal
Dany Din
@danydin
Aug 28 2016 09:20
oh nooo
Serenity
@qmikew1
Aug 28 2016 09:20
I think you should read that @danydin
Dany Din
@danydin
Aug 28 2016 09:20
im scared from those links
Serenity
@qmikew1
Aug 28 2016 09:20
no
Dany Din
@danydin
Aug 28 2016 09:20
ya when i see mdn
Serenity
@qmikew1
Aug 28 2016 09:20
ok, if you read the first few lines of the paragraph you'll have your answer
Joseph
@revisualize
Aug 28 2016 09:20
YOU ASKED A HARD QUESTION!
You get MDN links!
Serenity
@qmikew1
Aug 28 2016 09:21
but I was going to walk you through this (also even better I'm going to recommend YDKJS series)
Joseph
@revisualize
Aug 28 2016 09:21
You don't know Jack ... :ship:
Dany Din
@danydin
Aug 28 2016 09:21
i need to bew drunk like you @revisualize to be able to undersatnd whats going on there
Serenity
@qmikew1
Aug 28 2016 09:22
so, I want you to get the 'class' part out of your head for a second ...because that's typical and is going to make your brain explode
Dany Din
@danydin
Aug 28 2016 09:22
i've read the first series from the book was good actaully but needed a break from it afterwards :p
ok its out now @qmikew1
polak90
@polak90
Aug 28 2016 09:23
the code u have written is better
Serenity
@qmikew1
Aug 28 2016 09:23
are you sure?
polak90
@polak90
Aug 28 2016 09:23
yes
refer to this
its about not duplicating and consuming memory allocation
Serenity
@qmikew1
Aug 28 2016 09:24
um, that's called premature optimization
Dany Din
@danydin
Aug 28 2016 09:24
mm looks interasting @polak90 thanks
CamperBot
@camperbot
Aug 28 2016 09:24
danydin sends brownie points to @polak90 :sparkles: :thumbsup: :sparkles:
:cookie: 140 | @polak90 |http://www.freecodecamp.com/polak90
Dany Din
@danydin
Aug 28 2016 09:24
@qmikew1 ok
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:24
hello people
Serenity
@qmikew1
Aug 28 2016 09:24
don't worry about that stuff at this point. Concentrate on basics
Dany Din
@danydin
Aug 28 2016 09:24
ya i belive this way as well
polak90
@polak90
Aug 28 2016 09:24
using prototype function actually is the right way to do it

unction Dog(name, type){
this.name = name;
this.type = type;

this.bark = function(){
alert(this.name + " barks");
};

this.growl = function(){
alert(this.name + " growls");
};

this.getBreed = function(){
return this.type;
};
}

var lassie = new Dog("Lassie", "Collie");
lassie.bark(); // Lassie bark
lassie.growl(); // Lassie growls
var breed = lassie.getBreed(); // Collie

var rintintin= new Dog("Rin Tin Tin", "German Shepard");
rintintin.bark(); // Rin Tin Tin barks
rintintin.growl(); // Rin Tin Tin growls
var breed = rintintin.getBreed(); // German Shepard

this is not good...............
Serenity
@qmikew1
Aug 28 2016 09:25
@polak90 ok, I've done exercises
those
so, okey dokey
polak90
@polak90
Aug 28 2016 09:25

function Dog(name, type){
this.name = name;
this.type = type;
}

Dog.prototype.bark = function(){
alert(this.name + " barks");
}

Dog.prototype.growl= function(){
alert(this.name + " growls");
}

Dog.prototype.getBreed = function(){
return this.type;
}

var lassie = new Dog("Lassie", "Collie");
lassie.bark(); // Lassie barks
lassie.growl(); // Lassie growls
var breed = lassie.getBreed(); // Collie

var rintintin= new Dog("Rin Tin Tin", "German Shepard");
rintintin.bark(); // Rin Tin Tin bark
rintintin.growl(); // Rin Tin Tin growls
var breed = rintintin.getBreed(); // German Shepard

Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:25
Quick visualizing tool for those struggling with RedExp :https://regexper.com/#%2F(%5Bword%5D)%5Cd%5C-%2Fgim
polak90
@polak90
Aug 28 2016 09:25
this is right...................
Serenity
@qmikew1
Aug 28 2016 09:26
anywho, @revisualize the JS channel is interesting for shure
sure*
Dany Din
@danydin
Aug 28 2016 09:26
ah cool now i see the two options face to face @polak90
Joseph
@revisualize
Aug 28 2016 09:26
:)
polak90
@polak90
Aug 28 2016 09:26
cool
Serenity
@qmikew1
Aug 28 2016 09:26
@danydin finish YDKJS
Dany Din
@danydin
Aug 28 2016 09:26
makes much more sense.. it's for memory saving in large applcaitons right
polak90
@polak90
Aug 28 2016 09:26
happy to help
true kinda
cristiantoporascu
@cristiantoporascu
Aug 28 2016 09:27
This message was deleted
Dany Din
@danydin
Aug 28 2016 09:27
oh mam 3 bombs in 10mins :p ya i will but i've so many thigns on my head
im learning jasmine, git, working on a proecjt i've started with a team from scartch and those now :D
Serenity
@qmikew1
Aug 28 2016 09:28
ok, hang on a second. You guys are in the very early stages of the basic JS section is this correct? why are you talking about optimizing etc.? not that, that is bad... but how do you conceptually know about this? - seriously focus on concepts first
Chandrahas P
@Chan11
Aug 28 2016 09:29
closures are very confusing,any good reference
polak90
@polak90
Aug 28 2016 09:29
he he i have JS in the past
i am new to freecodecamp
am basically an embedded linux developer
Joseph
@revisualize
Aug 28 2016 09:29
@Chan11 There are some amazing youtube videos about closures.
polak90
@polak90
Aug 28 2016 09:29
and new to web development
so joined here
but i have done code opti for C C++ and python source
cristiantoporascu
@cristiantoporascu
Aug 28 2016 09:30

@revisualize
function updateRecords(id, prop, value) {
if (value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else {
collection[id][prop].push(value);
}

One task is still not being checked and I don't get it why...

polak90
@polak90
Aug 28 2016 09:30
and JS is not new to me
Serenity
@qmikew1
Aug 28 2016 09:30
you'd have fun with kernel
NeekPizza
@NeekPizza
Aug 28 2016 09:30
can some 1 help me
im on
Assignment with a Returned Value in JS
Chandrahas P
@Chan11
Aug 28 2016 09:31
@revisualize :+1:
Bogdan
@Bogdan032
Aug 28 2016 09:31
I'm currently doing the algorithm Truncate a string and i have no idea what to write. Could anyone give me some hints or methods to finish this challenge??
NeekPizza
@NeekPizza
Aug 28 2016 09:31
the instructions arent clear really
polak90
@polak90
Aug 28 2016 09:31
i write device drivers as a job
lol
and i work on yocto project
Joseph
@revisualize
Aug 28 2016 09:31
MY TAXI has arrived.
Serenity
@qmikew1
Aug 28 2016 09:31
what kind of embedded devices are you working with (that are running linux)
NeekPizza
@NeekPizza
Aug 28 2016 09:31
this is help forum
Joseph
@revisualize
Aug 28 2016 09:31
:v:
NeekPizza
@NeekPizza
Aug 28 2016 09:31
for help
i need help lol
polak90
@polak90
Aug 28 2016 09:31
imx 6
NeekPizza
@NeekPizza
Aug 28 2016 09:32
im on Assignment with a Returned Value
polak90
@polak90
Aug 28 2016 09:32
technologic systems boads
NeekPizza
@NeekPizza
Aug 28 2016 09:32
intro to java script
polak90
@polak90
Aug 28 2016 09:32
some prototype on beagle boards
NeekPizza
@NeekPizza
Aug 28 2016 09:32
...
Darth Skywalker
@adityaparab
Aug 28 2016 09:32

@moyo92 : Yeah, checked your code, you'd need to do either

titleStr = titleStr.trim();
return titleStr;

or simply

return titleStr.trim();
polak90
@polak90
Aug 28 2016 09:32
some more work on q7 module SoMs
similar stuff
Serenity
@qmikew1
Aug 28 2016 09:32
how come you're working on front end web stuff?
vis-a-vis curriculum
polak90
@polak90
Aug 28 2016 09:33
he he just to keep me engaged
i already know a bit of web dev
done some in the past on LAMP stack
Serenity
@qmikew1
Aug 28 2016 09:33
node is very cool
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:33
@ReadyDoMe show your code
polak90
@polak90
Aug 28 2016 09:33
now playing around with python django stack too
jamesmillerho
@jamesmillerho
Aug 28 2016 09:33
so what exactly is this thing doing?
Darth Skywalker
@adityaparab
Aug 28 2016 09:33
@polak90 : Get engaged (and never marry) you won't have to worry about it for the rest of your life
polak90
@polak90
Aug 28 2016 09:34
@adityaparab wat are u getting at?
Darth Skywalker
@adityaparab
Aug 28 2016 09:34
Node is the best aphrodisiac
Serenity
@qmikew1
Aug 28 2016 09:34
have you been drinking @adityaparab
?
Darth Skywalker
@adityaparab
Aug 28 2016 09:35
@qmikew1 : I'm high on life mate! No need to drink ;)
polak90
@polak90
Aug 28 2016 09:35
@jamesmillerho did u use svg???
Farah Soltane
@chokolate
Aug 28 2016 09:36
good evening everyone
Moyosore Fagunwa
@moyo92
Aug 28 2016 09:36
@adityaparab yeah thanks, I got it, there was a trailing space. Now trying to "Confirm the Ending"
NeekPizza
@NeekPizza
Aug 28 2016 09:36
can this forum please only be for helop
CamperBot
@camperbot
Aug 28 2016 09:36
moyo92 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 636 | @adityaparab |http://www.freecodecamp.com/adityaparab
NeekPizza
@NeekPizza
Aug 28 2016 09:36
and not general chat?
we should be helping not just chatting js
....
jamesmillerho
@jamesmillerho
Aug 28 2016 09:36
@polak90 no
NeekPizza
@NeekPizza
Aug 28 2016 09:36
cause i actually need help
polak90
@polak90
Aug 28 2016 09:36
cool
Takács Ádám
@AdamTakacs05
Aug 28 2016 09:36
Hi all, I'm totally stuck with Title Case a sentence challange, anyone able to help me? at least with the plan and order of tasks to be done
polak90
@polak90
Aug 28 2016 09:36
mostly canvas then i guess
that looks cool
@jamesmillerho
Darth Skywalker
@adityaparab
Aug 28 2016 09:37
@moyo92 : Yeah.. that's because the .trim returns new modified string and doesn't modify the actual string you called the function on.
NeekPizza
@NeekPizza
Aug 28 2016 09:37
@polak90 seriously? move this convo to general chat if you aren't here to help or ask for help.
Darth Skywalker
@adityaparab
Aug 28 2016 09:37
canvas > svg
polak90
@polak90
Aug 28 2016 09:37
i was helping just few mins back
if u hadnt notices
NeekPizza
@NeekPizza
Aug 28 2016 09:37
i didnt
polak90
@polak90
Aug 28 2016 09:37
noticed
NeekPizza
@NeekPizza
Aug 28 2016 09:37
i saw u talking
polak90
@polak90
Aug 28 2016 09:37
not my bad
NeekPizza
@NeekPizza
Aug 28 2016 09:38
about some crap u do for work lol
CamperBot
@camperbot
Aug 28 2016 09:38
you need to ask about @someone!
NeekPizza
@NeekPizza
Aug 28 2016 09:38
any 1 able to help with javascript
polak90
@polak90
Aug 28 2016 09:38
ya right crap for u
NeekPizza
@NeekPizza
Aug 28 2016 09:38
im on
assignment witha returned value
@polak90 leave if ur arent helping or ask for help. this is the help chat
Darth Skywalker
@adityaparab
Aug 28 2016 09:38
@ReadyDoMe - how can you expect one to help if you don't post your question (or your question is buried under the pile of wisdom)?
Serenity
@qmikew1
Aug 28 2016 09:38
@ReadyDoMe you're being really rude
greg
@wearenotgroot
Aug 28 2016 09:39
:fire:
NeekPizza
@NeekPizza
Aug 28 2016 09:39
@qmikew1 u were the 1 chatting it up with her so ur defense is mute.
Darth Skywalker
@adityaparab
Aug 28 2016 09:39
Grabs popcorn!
polak90
@polak90
Aug 28 2016 09:39
are u like an admin @ReadyDoMe
lol
NeekPizza
@NeekPizza
Aug 28 2016 09:39
@adityaparab i asked and then they kept talking about painting their nails
Assignment with a Returned Value
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:39
@adityaparab lol
NeekPizza
@NeekPizza
Aug 28 2016 09:39
is what i am on
polak90
@polak90
Aug 28 2016 09:39
i received brownie points for helping some one just few mins back
NeekPizza
@NeekPizza
Aug 28 2016 09:39
in java script
i need help
Takács Ádám
@AdamTakacs05
Aug 28 2016 09:39
same here I did ask something and nothing has happened
polak90
@polak90
Aug 28 2016 09:39
lol
Darth Skywalker
@adityaparab
Aug 28 2016 09:39

@ReadyDoMe

@adityaparab i asked and then they kept talking about painting their nails

Let me guess,, are you American?

NeekPizza
@NeekPizza
Aug 28 2016 09:39
@AdamTakacs05 yeah because @polak90 thinks this is fucking AOL instant messanger
Darth Skywalker
@adityaparab
Aug 28 2016 09:40
Anyway, mid asking your question again? @ReadyDoMe
NeekPizza
@NeekPizza
Aug 28 2016 09:40
@adityaparab Assignment with a Returned Value
in java script
i think its intro to java script
Darth Skywalker
@adityaparab
Aug 28 2016 09:40
@ReadyDoMe : Post your code!
NeekPizza
@NeekPizza
Aug 28 2016 09:40

@adityaparab // Only change code below this line
var processArg = 7;
var processed;

function processArg(num){
return (processed);
}

not really sure what its asking
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:40
@AdamTakacs05 what is the problemo?
NeekPizza
@NeekPizza
Aug 28 2016 09:40
the directions are really unclear.
Serenity
@qmikew1
Aug 28 2016 09:40
so, anyway... clearly you don't understand how this works. People help you because they are nice or volunteering to do so ... drop the entitlement and it works much better
Darth Skywalker
@adityaparab
Aug 28 2016 09:40
Would mind posting directions again?/
NeekPizza
@NeekPizza
Aug 28 2016 09:41
@qmikew1 GTFO IF U ARENT HERE TO HELP OR ASK FOR HELP FUCK
jamesmillerho
@jamesmillerho
Aug 28 2016 09:41
troll
NeekPizza
@NeekPizza
Aug 28 2016 09:41

@adityaparab Assume we have pre-defined a function sum which adds two numbers together, then:

ourSum = sum(5, 12);

will call sum function, which returns a value of 17 and assigns it to ourSum variable.
Instructions

Call the processArg function with an argument of 7 and assign its return value to the variable processed.

CamperBot
@camperbot
Aug 28 2016 09:41
:trollface: troll problems? notify admins here
Darth Skywalker
@adityaparab
Aug 28 2016 09:41

@qmikew1

so, anyway... clearly you don't understand how this works. People help you because they are nice or volunteering to do so ... drop the entitlement and it works much better

That's exactly what makes me wonder if he's American :P

greg
@wearenotgroot
Aug 28 2016 09:41
@ReadyDoMe processArg is the name of your function
jamesmillerho
@jamesmillerho
Aug 28 2016 09:41
:sweat_smile:
NeekPizza
@NeekPizza
Aug 28 2016 09:42
@wearenotgroot it says to call it
Serenity
@qmikew1
Aug 28 2016 09:42
and I'm not here to ask for help
dumba^^
NeekPizza
@NeekPizza
Aug 28 2016 09:42
@qmikew1 i swear to god
Serenity
@qmikew1
Aug 28 2016 09:42
see my finger?
Darth Skywalker
@adityaparab
Aug 28 2016 09:42

@ReadyDoMe :

All you need is this

function processArg(num){
return num;
}
NeekPizza
@NeekPizza
Aug 28 2016 09:42
no one cares anymore help, or ask gtfo
Takács Ádám
@AdamTakacs05
Aug 28 2016 09:42
@lunjwaba1 Im at title case a asentence challange and im totally stuck...i wuld need a plan at least or just an approach so I can figure it out but i have no idea, i tried with for loops i guess that is essential but somehow i just cant understand the whole thing
greg
@wearenotgroot
Aug 28 2016 09:42
@ReadyDoMe calling/executing the function--> function name + ()
processArg(...); //<----------
NeekPizza
@NeekPizza
Aug 28 2016 09:42
@adityaparab huh
@adityaparab it says argument of 7...
polak90
@polak90
Aug 28 2016 09:42

// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

processed = processArg(7);

there u go
was it hard?
simple as FFFFF
u rude sob
Darth Skywalker
@adityaparab
Aug 28 2016 09:43
@polak90 : No direct answers please. You focus on getting engaged.
not to me, mind you.. I'm shy
polak90
@polak90
Aug 28 2016 09:44
@adityaparab flirty sleazy sexist douche u are
gtfo
u are not helping
Darth Skywalker
@adityaparab
Aug 28 2016 09:44
@polak90 Thank you :D
CamperBot
@camperbot
Aug 28 2016 09:44
adityaparab sends brownie points to @polak90 :sparkles: :thumbsup: :sparkles:
:cookie: 141 | @polak90 |http://www.freecodecamp.com/polak90
Darth Skywalker
@adityaparab
Aug 28 2016 09:44
@polak90 : You aren't helping either. You're just posting direct answers. Which to me sounds more like spoon feeding than helping :D
polak90
@polak90
Aug 28 2016 09:45
ya he deserved it
becuz he was being a cry baby
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:45
@AdamTakacs05 turn the string into an array first
polak90
@polak90
Aug 28 2016 09:45
it was the simplest of tasks
NeekPizza
@NeekPizza
Aug 28 2016 09:45
polak
u helped
like
polak90
@polak90
Aug 28 2016 09:45
he has never heard of C
i guerss
NeekPizza
@NeekPizza
Aug 28 2016 09:45
this is a room for help
u are sitting here blabbering on
burying other people who actually need help
no one cares
Darth Skywalker
@adityaparab
Aug 28 2016 09:45
@ReadyDoMe : knock it off mate!
polak90
@polak90
Aug 28 2016 09:45
ya i have been helping ppl since yesterday
Darth Skywalker
@adityaparab
Aug 28 2016 09:46
get that Donald Trump outta yo ass :D
polak90
@polak90
Aug 28 2016 09:46
and got brownie points consistently
Takács Ádám
@AdamTakacs05
Aug 28 2016 09:46
@lunjwaba1 I did that already yeah that seemed obvious
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:46
@ReadyDoMe gotten your point through, please can't you be cordial man
polak90
@polak90
Aug 28 2016 09:46
ppl need to read task properly and ask help for wats worth
rest u can google
Dany Din
@danydin
Aug 28 2016 09:47
@polak90 is great, she found me super tutorial :D
polak90
@polak90
Aug 28 2016 09:47
and it is simple concept
return value of function
learn c
Darth Skywalker
@adityaparab
Aug 28 2016 09:47
Just like Learning Chinese for the first time :D
polak90
@polak90
Aug 28 2016 09:47
return by value
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:47
@AdamTakacs05 turn everthing into lowerCase
polak90
@polak90
Aug 28 2016 09:47
return by pointer
and more
then u wud understand basics of it
Darth Skywalker
@adityaparab
Aug 28 2016 09:47

@polak90

return by pointer

Nope! By reference

polak90
@polak90
Aug 28 2016 09:47
ya reference
i know
Darth Skywalker
@adityaparab
Aug 28 2016 09:48
good!
polak90
@polak90
Aug 28 2016 09:48
and there is pointers too
its about perception
Darth Skywalker
@adityaparab
Aug 28 2016 09:48
Reference and pointers are two different things. If you've ever done Assembly :laughing:
Takács Ádám
@AdamTakacs05
Aug 28 2016 09:48
@lunjwaba1 yes, done!
polak90
@polak90
Aug 28 2016 09:48
some work on c and they never heard of make utility or file dreadful
ya ok got ur point
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:49
@AdamTakacs05 you got the for loop, and look into the "charAt" method
polak90
@polak90
Aug 28 2016 09:49
i work on both
Darth Skywalker
@adityaparab
Aug 28 2016 09:49

ya ok got ur point

or point(er) ;)

Henry Cabello
@hacu9
Aug 28 2016 09:49
How can i access the last 2 numbers ? destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:49
@AdamTakacs05 you can loop through the first character of each array element and make it uppercase
Takács Ádám
@AdamTakacs05
Aug 28 2016 09:50
@lunjwaba1 I see ok I try that!
Thank you @lunjwaba1
CamperBot
@camperbot
Aug 28 2016 09:50
adamtakacs05 sends brownie points to @lunjwaba1 :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @lunjwaba1 |http://www.freecodecamp.com/lunjwaba1
Darth Skywalker
@adityaparab
Aug 28 2016 09:50

@hacu9 :

var allExceptFirst = Array.prototype.slice.call(arguments, 1);

will give you last elements.

Brendan Kinahan
@BKinahan
Aug 28 2016 09:50
@polak90 Please don't post full challenge solutions for people asking questions. The room is HelpJavaScript, not SpoilersJavaScript :)
NeekPizza
@NeekPizza
Aug 28 2016 09:50
@BKinahan THANK YOU
CamperBot
@camperbot
Aug 28 2016 09:50
readydome sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 2317 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Aug 28 2016 09:51
@polak90 There is also a CodeReview room where that kind of thing is what people are looking for, if you're interested.
Henry Cabello
@hacu9
Aug 28 2016 09:52
@adityaparab @wearenotgroot thanks
CamperBot
@camperbot
Aug 28 2016 09:52
hacu9 sends brownie points to @adityaparab and @wearenotgroot :sparkles: :thumbsup: :sparkles:
:cookie: 637 | @adityaparab |http://www.freecodecamp.com/adityaparab
:star2: 1476 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Joseph
@revisualize
Aug 28 2016 09:52
YAY! more smart people!
greg
@wearenotgroot
Aug 28 2016 09:52
@hacu9 :+1:
Joseph
@revisualize
Aug 28 2016 09:52
Guess what.. I also cured my hiccups.
I just held my breath and burped a bunch while holding my breath.
It was kind of gross.
greg
@wearenotgroot
Aug 28 2016 09:53
@revisualize :clap:
Darth Skywalker
@adityaparab
Aug 28 2016 09:53
From top or from the bottom?
Brendan Kinahan
@BKinahan
Aug 28 2016 09:53
@revisualize congrats :+1:
I usually only ever hiccup once.. Pretty lucky that way :D
Joseph
@revisualize
Aug 28 2016 09:54
Oh Em Gee.. It is almost 3am.
hashtag-bed.time.
Serenity
@qmikew1
Aug 28 2016 09:54
it's also important to note why the arguments object is being converted into an actual array (or context) - because you can't do much with former
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:54
almost 5am
Joseph
@revisualize
Aug 28 2016 09:55
@lunjwaba1 It is almost 3am in Seattle. And.. I just got home. So.. yeah. me + bed = :zzz:
gk0r
@gk0r
Aug 28 2016 09:55
If "===" compares for value and type. How would I handle the same comparison but expressed as literally greater than? E.g. ">==" ?
Darth Skywalker
@adityaparab
Aug 28 2016 09:55
It's 3.30 pm here!
still me me + bed
NeekPizza
@NeekPizza
Aug 28 2016 09:55
ugh
Brendan Kinahan
@BKinahan
Aug 28 2016 09:55
@gk0r you would need a separate comparison for type
NeekPizza
@NeekPizza
Aug 28 2016 09:56
some of these challenges are not very specific
im having problem with Stand in Line
Lusako Njwaba
@lunjwaba1
Aug 28 2016 09:56
@adityaparab where is "here"?
NeekPizza
@NeekPizza
Aug 28 2016 09:56
challenge.
Joseph
@revisualize
Aug 28 2016 09:56
HEY!
Farah Soltane
@chokolate
Aug 28 2016 09:56
good morning: its my first time using the chat. and i am stuck with one fcc example. i dont understand what the task : https://www.freecodecamp.com/challenges/record-collection
NeekPizza
@NeekPizza
Aug 28 2016 09:56
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.
Darth Skywalker
@adityaparab
Aug 28 2016 09:56
@gk0r : like >== or <==
Joseph
@revisualize
Aug 28 2016 09:56
@revisualize I can help with that.
@ReadyDoMe
@chokolate OH! I can help with that too.
Brendan Kinahan
@BKinahan
Aug 28 2016 09:56
@ReadyDoMe are you familiar with the array methods push / pop, shift / unshift?
Joseph
@revisualize
Aug 28 2016 09:56
One second!
NeekPizza
@NeekPizza
Aug 28 2016 09:56
oh yeah
Joseph
@revisualize
Aug 28 2016 09:56

How to do code block format:
```js [SHIFT+ENTER]
// your code here
```[CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

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

AND!
DONE!
I helped!
Moyosore Fagunwa
@moyo92
Aug 28 2016 09:57
Hi, in the "Confirm the Ending" challenge, why should confirmEnding("Open sesame", "same") return true. This is the case failing my code
Darth Skywalker
@adityaparab
Aug 28 2016 09:57
@revisualize : Take your brownie points and go home! Thanks :D
CamperBot
@camperbot
Aug 28 2016 09:57
adityaparab sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1761 | @revisualize |http://www.freecodecamp.com/revisualize
Brendan Kinahan
@BKinahan
Aug 28 2016 09:58
@moyo92 because the string "Open sesame" ends with "same". See the last four letters? They're the same ;)
NeekPizza
@NeekPizza
Aug 28 2016 09:58
@revisualize ugh man java script is so hard
Darth Skywalker
@adityaparab
Aug 28 2016 09:58
@moyo92 : Where is your code?
NeekPizza
@NeekPizza
Aug 28 2016 09:58
@revisualize i just feel like a compelete idiot wrote it
Moyosore Fagunwa
@moyo92
Aug 28 2016 09:58
@adityaparab
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var strArr = str.split(" ");
//console.log(strArr.length);
if(strArr.length == 1){
return (str.substring(str.length -1) === target);
}
else{
//console.log(strArr[(strArr.length) -1]);
return (strArr[(strArr.length) -1] === target);
}
}
Brendan Kinahan
@BKinahan
Aug 28 2016 09:58
@revisualize go to bed :P
Joseph
@revisualize
Aug 28 2016 09:58
@ReadyDoMe If you feel that way.. It is true.
Brendan Kinahan
@BKinahan
Aug 28 2016 09:58
@ReadyDoMe well it was initially written in a week
NeekPizza
@NeekPizza
Aug 28 2016 09:59
@revisualize like it doesn't need to be THIS complicated
Moyosore Fagunwa
@moyo92
Aug 28 2016 09:59
@adityaparab here: function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var strArr = str.split(" ");
//console.log(strArr.length);
if(strArr.length == 1){
return (str.substring(str.length -1) === target);
}
else{
//console.log(strArr[(strArr.length) -1]);
return (strArr[(strArr.length) -1] === target);
}
}
Joseph
@revisualize
Aug 28 2016 09:59
@ReadyDoMe It isn't complicated. It is just two lines of code.
@ReadyDoMe Can you answer the two questions posted in the link?
Darth Skywalker
@adityaparab
Aug 28 2016 09:59
@moyo92 You don't need to split it. You can take a look at .substr function and read about what positive and negative parameters mean.
NeekPizza
@NeekPizza
Aug 28 2016 10:00
the instructions on the challenge arent clear at all.
add the number to the end of the array...WHAT NUMBER
Joseph
@revisualize
Aug 28 2016 10:00
@ReadyDoMe Yes they are!
NeekPizza
@NeekPizza
Aug 28 2016 10:00
it just assumes im gunna know what that means???
jamesmillerho
@jamesmillerho
Aug 28 2016 10:00
@moyo92 "Never give up and good luck will find you."
Joseph
@revisualize
Aug 28 2016 10:00
@ReadyDoMe // an array (arr) and a number (item) as arguments.
@ReadyDoMe Read the instructions.
NeekPizza
@NeekPizza
Aug 28 2016 10:00
argument
is what goes in () of the function right?
Joseph
@revisualize
Aug 28 2016 10:01
@ReadyDoMe The instructions are very clear.
NeekPizza
@NeekPizza
Aug 28 2016 10:01
so function nextInLine (arr, item){}
Lusako Njwaba
@lunjwaba1
Aug 28 2016 10:01
@chokolate the function you create should be able to update the collection, either by deleting a property e.g. "artist" (if the "value" parameter is empty "")
NeekPizza
@NeekPizza
Aug 28 2016 10:01
right?
Joseph
@revisualize
Aug 28 2016 10:01
@ReadyDoMe Yes.
gk0r
@gk0r
Aug 28 2016 10:01
@adityaparab I tried that, but the test is coming back with an error. I must be doing something wrong https://github.com/Rafase282/My-FreeCodeCamp-Code/wiki/Lesson-Returning-Boolean-Values-From-Functions
Brendan Kinahan
@BKinahan
Aug 28 2016 10:01
@ReadyDoMe Yeah, arguments were covered a few challenges earlier in https://www.freecodecamp.com/challenges/passing-values-to-functions-with-arguments
Review that one if you need a refresher :)
NeekPizza
@NeekPizza
Aug 28 2016 10:02
ok...but
it says
add number to end of array
how would i do that
Moyosore Fagunwa
@moyo92
Aug 28 2016 10:02
@adityaparab thanks, I see it now, I should be comparing the target with the same length of characters in str...not comparing the last word
CamperBot
@camperbot
Aug 28 2016 10:02
moyo92 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: moyo92 already gave adityaparab points
Joseph
@revisualize
Aug 28 2016 10:02
@ReadyDoMe How do you do that?
Darth Skywalker
@adityaparab
Aug 28 2016 10:02
@ReadyDoMe : That is what you have .push function for
Brendan Kinahan
@BKinahan
Aug 28 2016 10:02
@ReadyDoMe That's why I asked if you knew about the array methods push / pop , shift/ unshift
Darth Skywalker
@adityaparab
Aug 28 2016 10:03
@moyo92 : Correct!
Brendan Kinahan
@BKinahan
Aug 28 2016 10:03
@revisualize No need to shout ;) Go to bed already!
AlBMyName
@IshmaRey-Hool
Aug 28 2016 10:03

Hi Guys,

I was doing ...
https://www.freecodecamp.com/challenges/build-a-random-quote-machine

This is my pen:
http://codepen.io/Ishma-Reyhool/pen/pyZJvx

Could someone tell me why my color change feature at the very bottom isn't working.

Joseph
@revisualize
Aug 28 2016 10:03
an array (arr) and a number (item) as arguments.
Lusako Njwaba
@lunjwaba1
Aug 28 2016 10:03
@chokolate (id,property,poperty -value) as parameters, e.g. they pass (5439,"artist","") delete "artist"
greg
@wearenotgroot
Aug 28 2016 10:04
@ReadyDoMe Array docs here is the documentation for Array, including the list of methods that are available to you
Is there a way to remove the scroll bar on the right of my project?
Brendan Kinahan
@BKinahan
Aug 28 2016 10:04
@IshmaRey-Hool looks like you set backItter to 1 every time the function runs.
Lusako Njwaba
@lunjwaba1
Aug 28 2016 10:04
@chokolate if the parameter has a property which isn't in the collection yet, add it
jamesmillerho
@jamesmillerho
Aug 28 2016 10:05
there was a horizontal bar. I used float: right to remove it
revisualize @revisualize storms off stage left. :zzz: :v: :fu: :wave: :v: :) :peach:
Brendan Kinahan
@BKinahan
Aug 28 2016 10:07
funny how :fu: was added to unicode before crossed-fingers
Joseph
@revisualize
Aug 28 2016 10:08
@BKinahan hehe.
Lusako Njwaba
@lunjwaba1
Aug 28 2016 10:08
@BKinahan it's universal and all that.I think that's the most famous gesture
Joseph
@revisualize
Aug 28 2016 10:08
:revolving_hearts::heartpulse::sparkling_heart::heartpulse::heartbeat::heart:
Brendan Kinahan
@BKinahan
Aug 28 2016 10:08
:ok_hand:
Dany Din
@danydin
Aug 28 2016 10:09
// this is the class?
var Person = function () {
  // and this is the Constructor?
  console.log('instance created');
};
Karayel
@Karayel
Aug 28 2016 10:09
Hı guys, I have a problem with code pen. I am getting XHR failed loading: GET but I am sure, I am doing right. What's wrong with codepen about xhr ? Thank
gk0r
@gk0r
Aug 28 2016 10:10
How would I solve the "Returning Boolean Values from Functions" lesson ?
Farah Soltane
@chokolate
Aug 28 2016 10:10
@lunjwaba1 i c what u say
Joseph
@revisualize
Aug 28 2016 10:10
return this === that;
Dany Din
@danydin
Aug 28 2016 10:10
@Karayel share a link
gk0r
@gk0r
Aug 28 2016 10:11
@revisualize "===" is an exact match. This wants a check of less than
Which I thought might be along the lines of "<==" but that fails
ZZPot
@ZZPot
Aug 28 2016 10:11
@jamesmillerho overflow: hidden;
Joseph
@revisualize
Aug 28 2016 10:11
@gk0r So use less than.
@gk0r <=
meh.
I'm supposed to be going to bed.
revisualize @revisualize leaves.
gk0r
@gk0r
Aug 28 2016 10:12
Thank you @revisualize
CamperBot
@camperbot
Aug 28 2016 10:12
gk0r sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1762 | @revisualize |http://www.freecodecamp.com/revisualize
Dany Din
@danydin
Aug 28 2016 10:12
@Karayel wheres ur problem its log the data
Altaryum
@Altaryum
Aug 28 2016 10:12
Can't figure out the STAND IN LINE challenge, can anyone help,thx.
Karayel
@Karayel
Aug 28 2016 10:13
@danydin wait a sec
Joseph
@revisualize
Aug 28 2016 10:13
@Altaryum // How do you add a number (item) to the end of an array (arr)?
// How do you remove the first element from an array (arr)?
revisualize @revisualize leaves.
Joseph
@revisualize
Aug 28 2016 10:13
Good night everyone.
Karayel
@Karayel
Aug 28 2016 10:14
@danydin when ı am typing something then click enter.I am getting this error from console VM3087 jquery.min.js:4XHR failed loading: GET "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=searc…pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=asdfas"
Dany Din
@danydin
Aug 28 2016 10:14
@Karayel No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
you need CORS
or jsonp
Karayel
@Karayel
Aug 28 2016 10:15
@danydin what is CORS
Dany Din
@danydin
Aug 28 2016 10:15
there is a limation to access 3rd domains servers
so those 2 methods are to bypass it
Karayel
@Karayel
Aug 28 2016 10:15
@danydin yea, I see it yesterday. I try it but the same error occurs
Dany Din
@danydin
Aug 28 2016 10:15
check cors on google if you want to get deeper in it
no way.. you've to change the code and then it will work
Farah Soltane
@chokolate
Aug 28 2016 10:16
i am so stuk. i understand what the idea of the function is. but- am i writing code for each album of the collection?
Karayel
@Karayel
Aug 28 2016 10:16
@danydin I am looking at it. I will come back here later.
jamesmillerho
@jamesmillerho
Aug 28 2016 10:16
@ZZPot thanks
CamperBot
@camperbot
Aug 28 2016 10:16
jamesmillerho sends brownie points to @zzpot :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @zzpot |http://www.freecodecamp.com/zzpot
Dany Din
@danydin
Aug 28 2016 10:16
ok
Lusako Njwaba
@lunjwaba1
Aug 28 2016 10:19
@chokolate here is a hint, your function should be able to "search /loop " through each id/album and check for the properties and update accordingly.
Id has prop? : No/yes ,do this ...."else" do this
Dan Couper
@DanCouper
Aug 28 2016 10:29
@Karayel firefox and chrome will prevent requests from an insecure (HTTP) address to a secure (HTTPS) address - this is always an issue when you try to test things locally. With FCC, the one that always comes up is the Weather project (the only available weather APIs are HTTPS). One way you can get around it is by using Safari (I think IE as well, I'm on a Mac atm, so I can't test that). The 'access-control' message that comes up sometimes is to do with the external site - if you controlled both, you could tell the external site to send a header back saying "yup, this content is fine to use". But that's almost never the case. Sometimes, you can just change the url of the thing you're trying to get from HTTPS to HTTP, but this is iffy, and doesn't work a lot of the time.
DarkManeiac
@DarkManeiac
Aug 28 2016 10:30

hi guys i need some help at repeat a string....
i mean : repeatStringNumTimes("", 3) should return "**".

and this is the code:

function repeatStringNumTimes(str, num) {
// repeat after me
return str;
}

repeatStringNumTimes("abc", 3);

nicop
@nicopcat
Aug 28 2016 10:30
hi
DarkManeiac
@DarkManeiac
Aug 28 2016 10:30
hello
nokia6290
@nokia6290
Aug 28 2016 10:31
Good evening fellow code mates, I'm stuck with the "GOLF code" assignment on javascript course. I can't seem to understand what the assignment is asking me.. By any chance anyone has recently completed it and would be willing to give me tips ( I'm not seeking full answer, I would like to understand it ! )
Thank you
nicop
@nicopcat
Aug 28 2016 10:32
sorry i am a fresher who may not be able to solve your problem..
I am stuck too..
stuck on the Counting Cards
nokia6290
@nokia6290
Aug 28 2016 10:32
@nicopcat with the same task?
DarkManeiac
@DarkManeiac
Aug 28 2016 10:32
i can help u at counting cards
nicop
@nicopcat
Aug 28 2016 10:33
really??!
@nokia6290 nope sorry
@nokia6290 hold on , i remember i have been thru that task ,just hold on a second until my task solved
masterbunny
@m4sterbunny
Aug 28 2016 10:34
Howdy campers - so when is an array not an array? Can anyone explain why my Array fails a simple isArray test?! http://codepen.io/m4sterbunny/pen/oLKpXg
DarkManeiac
@DarkManeiac
Aug 28 2016 10:34

i didnt understood very well... but this is the code
var count = 0;
function cardValue (card) {
var zeroVal = card === 7 || card === 8 || card === 9;
if (zeroVal) return 0;
else if (typeof card === 'string' || card === 10) return -1;
else if (typeof card === 'number' || card !== 10) return 1;
}

function cc(card) {
// Only change code below this line
count += cardValue(card);
if (count > 0) return ${count} Bet;
else if (count < 0) return ${count} Hold;
else return ${count} Hold;
// Only change code above this line
}

nokia6290
@nokia6290
Aug 28 2016 10:35
@nicopcat thanks for that !
CamperBot
@camperbot
Aug 28 2016 10:35
nokia6290 sends brownie points to @nicopcat :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for nicopcat
nokia6290
@nokia6290
Aug 28 2016 10:35
@nicopcat thx !
CamperBot
@camperbot
Aug 28 2016 10:35
nokia6290 sends brownie points to @nicopcat :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for nicopcat
nicop
@nicopcat
Aug 28 2016 10:36
@DarkManeiac i thought it should be done with Switch
DarkManeiac
@DarkManeiac
Aug 28 2016 10:36
notrly
not rly... it cannot be solved very well, i tryed
Joseph
@revisualize
Aug 28 2016 10:37
@m4sterbunny an array is an array except when it is not an array.
Then it is an object.
:)
masterbunny
@m4sterbunny
Aug 28 2016 10:37
@revisualize Hey this is JS EVERYthing is an object!
seriously dude I copy pasted my array from record collection - to play with in code pen, but it is not an array?! Why oh why I am melting down here
Joseph
@revisualize
Aug 28 2016 10:38
I know.
;)
jamesmillerho
@jamesmillerho
Aug 28 2016 10:38
canvas is fun
blob
nicop
@nicopcat
Aug 28 2016 10:38
i cant be solved with Switch sentence?
@DarkManeiac
DarkManeiac
@DarkManeiac
Aug 28 2016 10:38
i tryed... it didnt work to me
Joseph
@revisualize
Aug 28 2016 10:39
@Masana84 hasOwnProperty?
marija
@44552
Aug 28 2016 10:39

function testGreaterThan(val) {
if (val >10) { // Change this line
return "Over 100";
}

if (val >5) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(11);
is my code correct i can not pass the challenge can anyone help me please

Vijay
@vijayirtt59
Aug 28 2016 10:39
hi guys
DarkManeiac
@DarkManeiac
Aug 28 2016 10:39

function cc(card) {
// Only change code below this line
count += cardValue(card);
if (count > 0) return ${count} Bet;
else if (count < 0) return ${count} Hold;
else return ${count} Hold;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A'); // 0 Hold
cc(10); cc('J'); cc('Q'); cc('K'); cc('A'); // -5 Hold
@nicopcat

masterbunny
@m4sterbunny
Aug 28 2016 10:39
@nicopcat It can:
switch(card) {
case 2:
case 3:
Vijay
@vijayirtt59
Aug 28 2016 10:39
i need help in solving record collection problem
i was given a JSON
Joseph
@revisualize
Aug 28 2016 10:39
@m4sterbunny look on my gist. I think youre actually looking for hasOwnProperty
nicop
@nicopcat
Aug 28 2016 10:40

var count = 0;

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

// Only change code above this line
}

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

Vijay
@vijayirtt59
Aug 28 2016 10:40
dont know how to solve it
Read that!
:)
Vijay
@vijayirtt59
Aug 28 2016 10:40
thanks
jamesmillerho
@jamesmillerho
Aug 28 2016 10:42
blob
Vijay
@vijayirtt59
Aug 28 2016 10:42
no code there
Geo Galagaran
@geeofree
Aug 28 2016 10:43
can anyone help me with the smallest common multiple challenge? :( I'm stuck.. Here's the code I did with comments.

function smallestCommons(arr) {
  var nums = [],primes = [2,3,5,7], multis = [];
  for(var i = Math.min(arr[0],arr[1]); i <= Math.max(arr[0],arr[1]); i++){
    if(i != 1){
         nums.push(i); 
    }
  }
  for(var p = 0; p < primes.length; p){
    for(var n = 0; n < nums.length; n++){
      /*
        check if nums[n] is divisible by primes[p].If true, change value of that
          index and set p back to 0(this is to check the new values of 'nums' array) 
      */
      if((nums[n] % primes[p]) == 0){
          nums[n] = nums[n] / primes[p];
          p = 0;
        /*
        Problem: Need to only check if nums[n] is divisible by primes[p] only One times
        per num[n] cycles, and not per nums[n] that are divisible by primes[p].
        */
      }

      //increment p if at last index of nums array
      if(n == nums.length-1){
          p++;
      }
    }
  }
  return multis.concat(nums);
}

console.log(
smallestCommons([1,5])
  )
jamesmillerho
@jamesmillerho
Aug 28 2016 10:43
@da7thsin use ```js
Vijay
@vijayirtt59
Aug 28 2016 10:43
pls anyone help me on record collection problem
Levi
@MalangeLevi
Aug 28 2016 10:44
@vijayirtt59 yes
Joseph
@revisualize
Aug 28 2016 10:44
@vijayirtt59 did you want me to gift you the answer? Or did you want to actually learn the material?
Levi
@MalangeLevi
Aug 28 2016 10:44
@vijayirtt59 what do u have so far
jamesmillerho
@jamesmillerho
Aug 28 2016 10:44
@da7thsin this is not about divisible by primes but all number within 1,5
Vijay
@vijayirtt59
Aug 28 2016 10:45
learning material is enough joseph
i jus cant understant it
Levi
@MalangeLevi
Aug 28 2016 10:45
@vijayirtt59 did u try to write a code...
Vijay
@vijayirtt59
Aug 28 2016 10:46
yes levi

function updateRecords(id, prop, value) {
var obj = collection.id[prop];
console.log(obj);
if(prop != "tracks" && value != ""){

}

return collection;
}

obj is returing undefined
Levi
@MalangeLevi
Aug 28 2016 10:46
yes u are in the rigth path...
Vijay
@vijayirtt59
Aug 28 2016 10:46
when i try in my console its returing value
Geo Galagaran
@geeofree
Aug 28 2016 10:46
@jamesmillerho No no. The 'primes' array are just for checking/dividing the numbers within the range of the array in the argument. This is the algorithm I'm trying to do if it helps https://www.youtube.com/watch?v=z5vlj06Ex0U
Levi
@MalangeLevi
Aug 28 2016 10:46
you dont neer var object, remove it
Stephen James
@sjames1958gm
Aug 28 2016 10:46
@vijayirtt59 Remember id is a variable just like prop
Levi
@MalangeLevi
Aug 28 2016 10:47
need
remove console.log too, u dont need it
Stephen James
@sjames1958gm
Aug 28 2016 10:49
@da7thsin The problem with the primes array is it doesn't apply to the general solution. Also, prime factorization is not a simple task.
You could consider LCM by calculating the GCD first
Vijay
@vijayirtt59
Aug 28 2016 10:50

function updateRecords(id, prop, value) {

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

levi i am getting collection.id is undefined
jamesmillerho
@jamesmillerho
Aug 28 2016 10:51
@da7thsin this is very difficult to do, consider 1-13. you can't find a prime number to divide all of them
masterbunny
@m4sterbunny
Aug 28 2016 10:51
@revisualize I am just on a mission to fiddle- (I have your Record Collection hints saved for future use), but it this Array is not an array what is it?!
Vijay
@vijayirtt59
Aug 28 2016 10:52
its JSON
Levi
@MalangeLevi
Aug 28 2016 10:52
collection[id].artist = value
@m4sterbunny is json file
masterbunny
@m4sterbunny
Aug 28 2016 10:53
@nicopcat why is case 2 in 2 places?
jamesmillerho
@jamesmillerho
Aug 28 2016 10:53
@da7thsin the easy way to do is to just start from the largest number (13 in 1-13)
check if 1-13 are divisible by 13;
if not;
increment that number by 13 each time
Vijay
@vijayirtt59
Aug 28 2016 10:53
@MalangeLevi but if other property was passed? Do we need to hardcode artist
Geo Galagaran
@geeofree
Aug 28 2016 10:54
@jamesmillerho Hm.. The 'primes' array are just 2,3,5,7. They're not really primes but are like GCD's for the nums array.
Levi
@MalangeLevi
Aug 28 2016 10:55
@vijayirtt59 depend...if you know the property just use it, if you want to find a property than hasownproperty....
@vijayirtt59 i just used the properties...
Stephen James
@sjames1958gm
Aug 28 2016 10:57
@vijayirtt59 id is a variable and requires [id]
Levi
@MalangeLevi
Aug 28 2016 10:59
@vijayirtt59 remember u have parameters...id, prop, value,
greg
@wearenotgroot
Aug 28 2016 10:59
@vijayirtt59 useful links
dot vs bracket notation
.hasOwnProperty
Vijay
@vijayirtt59
Aug 28 2016 11:04
thanks greg
@MalangeLevi if(prop=="tracks" && value != ""){
collection[id]["tracks"].push(value);
}
is this right? If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.
Levi
@MalangeLevi
Aug 28 2016 11:05
@vijayirtt59 u will need to push but not yet u need more codes before pushing...are u reading the assigment?
@vijayirtt59 your code is right... but...
greg
@wearenotgroot
Aug 28 2016 11:06
@vijayirtt59 remember .push is an array method, so you need to make sure that the array you are pushing on exist (in this case the array we want is in 'tracks' property). this is where the .hasOwnProperty comes in handy. Test if 'tracks' exist, if it does then push the value. if not create/add the property 'tracks' and its value is an array then push
Vijay
@vijayirtt59
Aug 28 2016 11:08
greg only if it is tracks i am pushing it
thanks greg got it
Ivan Temchur
@ttemcha
Aug 28 2016 11:13
hello everyone! please can u tell me what is wrong with my code in palindrome challenge
function palindrome(str) {
  var palStr = str.replace(/[^\w\s)]|[_]/g, "").toLowerCase().split("").reverse();

  return str === palStr;

}

palindrome("eye");