These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
Nov 2016
Gang Zhao
@crumpx
Nov 03 2016 00:00
You used switch case of if for this one
The function will be called multiple times
So there will be no loop involved
Each time the function being called it will receive a number or latter. You need to change value of count within the function accordingly
Michael Kinkor
@mlkinkor
Nov 03 2016 00:05
Hey, I'm having some trouble with testing an object for a property. Specifically in the "Testing Objects for Properties" if the property exists, I can get it to return no problem, but I'm having trouble figuring out how to add the "Not Found" statement if the property does not exist. Any hints?
iceveda06
@iceveda06
Nov 03 2016 00:05
working on Profile-Lookup...any help? i feel like im missing something in there function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (firstName === contacts[i].firstName) {
if (contacts[i].hasOwnProperty("prop")) {
return (contacts[i].firstName.prop);
}
else return ("No such property");
}
else return ("No such contact");
}
// Only change code above this line
}
Walid Ashri
@walidashri
Nov 03 2016 00:06
@mlkinkor if else :)
iceveda06
@iceveda06
Nov 03 2016 00:06
i dont thin im looping through them correctly
Gang Zhao
@crumpx
Nov 03 2016 00:07
@mlkinkor how about if (arr.hasOwnProperty(item) = -1) return "Not Found"
Johnny
@JohnnyBizzel
Nov 03 2016 00:08
@iceveda06 contacts[i].hasOwnProperty("prop") You should not pass a string to this function, pass just prop unquoted
Also, careful with the returns inside the loop. They will exit the function.
Gang Zhao
@crumpx
Nov 03 2016 00:09
@iceveda06 maybe you should check how many times your for loop actually runs
Michael Kinkor
@mlkinkor
Nov 03 2016 00:09
@walidashri @crumpx Thank you for the hints. My attempt at an if statement doesn't seem to be working. Help? if (myObj.hasOwnProperty(checkProp) = false)
CamperBot
@camperbot
Nov 03 2016 00:09
mlkinkor sends brownie points to @walidashri and @crumpx :sparkles: :thumbsup: :sparkles:
:cookie: 555 | @walidashri |http://www.freecodecamp.com/walidashri
:cookie: 400 | @crumpx |http://www.freecodecamp.com/crumpx
Johnny
@JohnnyBizzel
Nov 03 2016 00:10
@mlkinkor IF you have tested all the items in the collection you can assume it is not found!
iceveda06
@iceveda06
Nov 03 2016 00:10
@crumpx what do you mean how many times
shouldn't it loop through the length?
Gang Zhao
@crumpx
Nov 03 2016 00:10
Its == not =
If you return in any point during, it will end the loop
Aaron Bell
@awb715
Nov 03 2016 00:10
up to wikipedia viewer! seemscrazy hard
Johnny
@JohnnyBizzel
Nov 03 2016 00:10
@mlkinkor You should learn about ! < not operator
if (myObj.hasOwnProperty(checkProp)) ... if it exists, this returns true, if not it is false
iceveda06
@iceveda06
Nov 03 2016 00:11
@crumpx so instead of 'return' i should use console.log to dump the result?
Michael Kinkor
@mlkinkor
Nov 03 2016 00:11
Thank you @crumpx
CamperBot
@camperbot
Nov 03 2016 00:11
mlkinkor sends brownie points to @crumpx :sparkles: :thumbsup: :sparkles:
:warning: mlkinkor already gave crumpx points
Gang Zhao
@crumpx
Nov 03 2016 00:11
You can set up a variable outside of that loop, and change its value inside the loop and also checking its value
iceveda06
@iceveda06
Nov 03 2016 00:12
ok now i get result that says no such contact so its outputting something
Gang Zhao
@crumpx
Nov 03 2016 00:12
But if I were you
Michael Kinkor
@mlkinkor
Nov 03 2016 00:12
Thank you @JohnnyBizzel I'm just slowly going through the training,
CamperBot
@camperbot
Nov 03 2016 00:12
mlkinkor sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 733 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Gang Zhao
@crumpx
Nov 03 2016 00:12
I will find that person first and put him in a variable, then I'll just check if he has the property's
Johnny
@JohnnyBizzel
Nov 03 2016 00:13
@mlkinkor :+1: Enjoy the journey!
Gang Zhao
@crumpx
Nov 03 2016 00:13
If that variable is empty that means "no such contact"
iceveda06
@iceveda06
Nov 03 2016 00:13
so in the first if statement dump it in to a variable and see if he has the propery using hasownproperty statement
Johnny
@JohnnyBizzel
Nov 03 2016 00:14
@iceveda06 Think about the problem: if you find what you are looking for, you can return it immediately.
Else you must handle the "no such" cases.
iceveda06
@iceveda06
Nov 03 2016 00:15
ok
Gang Zhao
@crumpx
Nov 03 2016 00:15
To ease the solution, you can loop through the persons name and if persons name is found, out it in a variable and return
Johnny
@JohnnyBizzel
Nov 03 2016 00:16
@crumpx :+1:
Gang Zhao
@crumpx
Nov 03 2016 00:16
Then deal with property in that variable
Johnny
@JohnnyBizzel
Nov 03 2016 00:16
I'm off to bed. Best regards coders!!
Gang Zhao
@crumpx
Nov 03 2016 00:16
Good night sir
Brian
@BrianCodes33
Nov 03 2016 00:18
function bouncer(arr) {
  return arr.filter(function(val){
    return val;
  });
  }
Anthony DeVenuto
@adevenuto
Nov 03 2016 00:18
So I just worked out Caesars Cipher and while its outputting exactly what it is suppose to the last test is failing. Here is a fiddle of the code: pull it up in the inspector and its outputting what it's suppose to
Brian
@BrianCodes33
Nov 03 2016 00:18
anyone can help me here
VaseJS
@VaseJS
Nov 03 2016 00:18
hello everyone, can someone let me know what i’m doing wrong? challenge: exact change.
Gang Zhao
@crumpx
Nov 03 2016 00:24

//jshint esversion:6

rot13 =
(str) => {
str = [...str];
return str.map((char)=>{
let code = char.charCodeAt(0);
if (code >= 65 && code <=77){
return String.fromCharCode(code+13);
} else if (code >= 78 && code <= 90){
return String.fromCharCode(code-13);
} else {
return char;
}
}).join('');
};

rot13("SERR CVMMN!");

compare the logic
__mifflin__
@cdrainxv
Nov 03 2016 00:28
@adevenuto : the letter A is not being shifted to the letter N in the last test case.
@adevenuto : in the last case you are returning:
THE QUICK BROW DOG JUMPED OVER THE LAZY FOX.
instead of:
THE QUICK BROWN DOG JUMPED OVER THE LAZY FOX.
@adevenuto : Simple fix I believe:
if (str.charCodeAt(i)-13 < 65 && str.charCodeAt(i) > 64)
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:31
~~~
oops

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

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
ok what and where am I missing things lol
Walid Ashri
@walidashri
Nov 03 2016 00:33
@ryanjvandyke what is result value now?
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:34
nothing. it wont run lol
Anthony DeVenuto
@adevenuto
Nov 03 2016 00:34
@cdrainxv Wow. lol. I missed that, I've been looking at it for to long i guess. Thanks!
CamperBot
@camperbot
Nov 03 2016 00:34
adevenuto sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:cookie: 686 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Walid Ashri
@walidashri
Nov 03 2016 00:34
@ryanjvandyke :) so think of something to change it
__mifflin__
@cdrainxv
Nov 03 2016 00:34
@adevenuto: no problem. :smile: :+1:
Aaron Bell
@awb715
Nov 03 2016 00:35
anyone working on wikipedia?
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:35
this is the link but im not sure how to do what its asking
V
Walid Ashri
@walidashri
Nov 03 2016 00:35
@cdrainxv Bon dias
perseusMyk
@perseusMyk
Nov 03 2016 00:36
@ryanjvandyke look on left side you will see the out put of the fct
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:36
correct. its blank
Walid Ashri
@walidashri
Nov 03 2016 00:36
@ryanjvandyke just make a sentience of the variables and set it to result
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:36
i know what i have to do. but writing the code is whats getting me
Walid Ashri
@walidashri
Nov 03 2016 00:38
@ryanjvandyke a hint result = myNoun + myAdjective
perseusMyk
@perseusMyk
Nov 03 2016 00:39
@ryanjvandyke I see, you are defining variable , no need for that , use the result ( the variable aready defined ) to add to it the parametres
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:40
ok im getting closer lol
Walid Ashri
@walidashri
Nov 03 2016 00:41
@ryanjvandyke watch for the Dogs ;)
__mifflin__
@cdrainxv
Nov 03 2016 00:41
@walidashri: Buena noches! :wave:
@ryanjvandyke: make it look like a proper sentence… hint… words are seperated by a space .
Walid Ashri
@walidashri
Nov 03 2016 00:42
@cdrainxv nooooooo keep that hint for last let the dogs out :D
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:42
how do i add the space?
result = myAdjective  + myNoun  + myVerb  + myAdverb;
Walid Ashri
@walidashri
Nov 03 2016 00:42
c @cdrainxv :(
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:43
thats what I hace so far
Simon Cordova
@gbsimon87
Nov 03 2016 00:43
Can anyone check why pressing enter won't work to perfom the search?
http://codepen.io/gbsimon87/pen/YGJkbO?editors=1010
perseusMyk
@perseusMyk
Nov 03 2016 00:43
@ryanjvandyke good so far
how will type a space ?
__mifflin__
@cdrainxv
Nov 03 2016 00:43
@walidashri: Oh come on… your hint practically gave away the answer… I’m just reminding :wink: @ryanjvandyke of proper english structure.
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:44
@perseusMyk yes becuase its not shwing the result with any spaces
perseusMyk
@perseusMyk
Nov 03 2016 00:44
@ryanjvandyke I know space for us is just hit space , but for the program space is a string . right ?
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:46
correct
__mifflin__
@cdrainxv
Nov 03 2016 00:46
@ryanjvandyke: to add a space you just add an empty string like this: myAdjective + " " + myNoun
Onome Sotu
@onomesotu
Nov 03 2016 00:46
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var args;
  var newArr;
  var numIndex;
  function sorter(a, b) {//callback to sort() method
    return a - b;
  }

  args = Array.from(arguments);
  args.shift();
  numIndex = args[0];

  newArr = arr.concat(args);
  return newArr.sort(sorter).indexOf(numIndex);

}

getIndexToIns([40, 60], 50);
Does anyone have a another solution?
jasonbartelds77
@jasonbartelds77
Nov 03 2016 00:47
a should be assigned to b with =
var a = 7;
var b = 7;
Onome Sotu
@onomesotu
Nov 03 2016 00:47
This is very spaghetti in nature ;)
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 00:47
Got it! Thanks @cdrainxv and @perseusMyk
CamperBot
@camperbot
Nov 03 2016 00:47
ryanjvandyke sends brownie points to @cdrainxv and @perseusmyk :sparkles: :thumbsup: :sparkles:
:cookie: 687 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
:warning: could not find receiver for perseusmyk
__mifflin__
@cdrainxv
Nov 03 2016 00:55
@jasonbartelds77:
var x = "hello";
var y = 7;
// assign x to y—> now you want y to have the value of x
y = x; // x has been assigned to y. y is now "hello". x is still "hello"
Simon Cordova
@gbsimon87
Nov 03 2016 00:56
Hey guys...I'm using .html so that my ajax call gets appended to my html, however it's only displaying the last item returned...any ideas?
using .append works but it keeps appending to the list...
I'd like to delete the current list and then append
Walid Ashri
@walidashri
Nov 03 2016 00:57
@gbsimon87 clear before append
__mifflin__
@cdrainxv
Nov 03 2016 00:58
@onomesotu: You probably don’t want mine:
return arr.reduce((a,b) => b < num ? a + 1 : a,0);
Walid Ashri
@walidashri
Nov 03 2016 00:58
@gbsimon87 check
Simon Cordova
@gbsimon87
Nov 03 2016 00:58
@walidashri I tried that but nothing...
$('#outputList').clear();
          $('#outputList').append('<h4><a href=' + data[3][i] + '>' + data[1][i] + '</a>' + '</h4>' + '<p>' + data[2][i] + '</p>');
I tried empty instead of clear as well but it only returns the last item from my ajax call
Walid Ashri
@walidashri
Nov 03 2016 00:59
@gbsimon87 as I know on clear() in JQuery
Simon Cordova
@gbsimon87
Nov 03 2016 01:00
There's empty, which removes all child nodes, and .remove(), which removes the element itself
Walid Ashri
@walidashri
Nov 03 2016 01:01
@gbsimon87 add the empty before the for loop
Simon Cordova
@gbsimon87
Nov 03 2016 01:02
oh wow @walidashri you have no idea how long that had me stumped thanks a lot
CamperBot
@camperbot
Nov 03 2016 01:02
gbsimon87 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 556 | @walidashri |http://www.freecodecamp.com/walidashri
Simon Cordova
@gbsimon87
Nov 03 2016 01:02
Can I bother you with one last thing?
Walid Ashri
@walidashri
Nov 03 2016 01:03
@gbsimon87 :+1:
Simon Cordova
@gbsimon87
Nov 03 2016 01:03
I have two functions written out to use the enter key instead of having to click the search button, however, neither seem to be working , could you review them?
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 01:05
var myArray = [1,2,3];
var myData = myData[0];
should have a property of 1 but its not working. any help?
Walid Ashri
@walidashri
Nov 03 2016 01:05
@gbsimon87 sure but give me 5 min
Simon Cordova
@gbsimon87
Nov 03 2016 01:05
thanks @walidashri np take your time
CamperBot
@camperbot
Nov 03 2016 01:05
gbsimon87 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:warning: gbsimon87 already gave walidashri points
Simon Cordova
@gbsimon87
Nov 03 2016 01:06
@ryanjvandyke are you sure the var myData is assigned correctly?
Ryan VanDyke
@ryanjvandyke
Nov 03 2016 01:08
I see what I did thank you @gbsimon87
CamperBot
@camperbot
Nov 03 2016 01:08
ryanjvandyke sends brownie points to @gbsimon87 :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @gbsimon87 |http://www.freecodecamp.com/gbsimon87
Simon Cordova
@gbsimon87
Nov 03 2016 01:12
@ryanjvandyke no worries
Vipersad
@Vipersad
Nov 03 2016 01:22
// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 2;

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

// Only change code below this line
processed = process (7);
You should assign processArg to processed
please help
ManBearPigg
@ManBearPigg
Nov 03 2016 01:24
What is the Big-O-Notation of n^0.01 ? Is it O(n) ?
Vipersad
@Vipersad
Nov 03 2016 01:25
me
Walid Ashri
@walidashri
Nov 03 2016 01:27
@gbsimon87 hey put the keypress outside the click function and check the id name
Adolfo Saenz
@AdoSae1
Nov 03 2016 01:27
hey guys I'm on the "converting celsius to fahrenheit" challenge and every time i run test for the numbers they give me they are correct but im not sure on how to get all of them to check
Walid Ashri
@walidashri
Nov 03 2016 01:28
@AdoSae1 ur code
Adolfo Saenz
@AdoSae1
Nov 03 2016 01:29

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit = 30 * 9/5 +32;
// Only change code above this line
return fahrenheit;
}

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

Walid Ashri
@walidashri
Nov 03 2016 01:29
@AdoSae1 u should use the arg celsius to pass
Adolfo Saenz
@AdoSae1
Nov 03 2016 01:30
what do you mean?
Daniel Nora
@DanielNora
Nov 03 2016 01:30
@ghulamshabir It does not display a thumb down for .substr() for me... Only for other functions
Adolfo Saenz
@AdoSae1
Nov 03 2016 01:30
@walidashri
Walid Ashri
@walidashri
Nov 03 2016 01:31
@AdoSae1 ur code'll return 86 what ever the celsius is
walidashri @walidashri brb
Adolfo Saenz
@AdoSae1
Nov 03 2016 01:33
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
i can get them all to check but not all together
Ken Haduch
@khaduch
Nov 03 2016 01:41
@AdoSae1 - you should be using the function argument variable celsius in your calculation - you have a hard-coded 30in there, so you might pass the convertToF(30); test. The idea behind a function is to make it perform the calculation for any value that is passed to it. The value that is being passed in is available within the function using the variable celsius - and you are not using it.
Mitch
@MitchWilkins
Nov 03 2016 01:47
In the "Record Collection" I am trying to get it to set the value code if (prop != "tracks" && value !== ""){
collection[id][prop][value] = value;
} code
but it is saying that the value is undefined
Walid Ashri
@walidashri
Nov 03 2016 01:50
@MitchWilkins collection[id][prop][value] this means the property "value"of the property "prop" of the collection[id]
Adolfo Saenz
@AdoSae1
Nov 03 2016 01:50
@khaduch ok i got it, totally makes sense now looking at it
thanks!
Mitch
@MitchWilkins
Nov 03 2016 01:52
@walidashri Ok I see the flaw in my logic, but I am trying to get it to add the value of the variable value to the array
Walid Ashri
@walidashri
Nov 03 2016 01:53
so set the prop value to array then push the value
mgeezy
@mirogeezy
Nov 03 2016 01:54
hello fellows I need help
Mitch
@MitchWilkins
Nov 03 2016 01:54
like collection[prop].push(value)?
mgeezy
@mirogeezy
Nov 03 2016 01:54

hi I am on that challenge https://www.freecodecamp.com/challenges/selecting-from-many-options-with-switch-statements

Although I resolved it I get indicated error on the break lines: "Unreachable break after return"

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
return("alpha");
break;
case 2:
return("beta");
break;
case 3:
return("gamma");
break;
case 4:
return("delta");
break;
}

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

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

Walid Ashri
@walidashri
Nov 03 2016 01:55
@MitchWilkins yes if it's an array
mgeezy
@mirogeezy
Nov 03 2016 01:55
It is bothering me this error so please explain much appreciated
Adolfo Saenz
@AdoSae1
Nov 03 2016 01:56
@khaduch can you post your code for that challenge . i thought i had it but bleh.
Walid Ashri
@walidashri
Nov 03 2016 01:57
@mirogeezy if u return no need for break return already stop the execution
mgeezy
@mirogeezy
Nov 03 2016 01:58
yeah but instructions explained this pseudo code:
switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
}
Skibper
@Skibper
Nov 03 2016 01:58
Hi guy
mgeezy
@mirogeezy
Nov 03 2016 01:59
it required break. so i am wondering how to deal with this return
Mitch
@MitchWilkins
Nov 03 2016 01:59
@walidashri So I tried that and it says "Type Error: cannot read property 'push' of undefined"
mgeezy
@mirogeezy
Nov 03 2016 02:00
i tried to do var answer = ""; it also works, but still getting error that "answer is already defined". I resolved the challenge but would like to perfection it :)
Skibper
@Skibper
Nov 03 2016 02:00
Im stuck in Ceasars Cipher now, can anyone help me fix my code...
function rot13(str) { // LBH QVQ VG!
var arr = [];
var newstr ="";
for (var i=0;i<str.length;i++){ arr[i]=str.charCodeAt(i); if (arr[i]>=65 && arr[i]<=90){
if (arr[i]<78)
arr[i]+=13;
else
arr[i]-=13;
}
else
arr[i]=str.charAt(i);
newstr += String.fromCharCode(arr[i]);
}
return newstr;
}
Walid Ashri
@walidashri
Nov 03 2016 02:01
@MitchWilkins set it to array first
Luke
@TheGenieOfTruth
Nov 03 2016 02:01
A more efficient solution is to create two arrays:
var alphabet = "abcdefghijklmnopqrstuvwxyz".toUpperCase().split("");
var cipher = "nopqrstuvwxyzabcdefghijklm".toUpperCase().split("");
Course' that's not what the challenge is asking for, but it takes up less space :)
esayli
@esayli
Nov 03 2016 02:02
@MitchWilkins try to do like this collection[id] = []; collection[id][prob] = []; collection[id][prob][value] = value
Skibper
@Skibper
Nov 03 2016 02:02
okai let me try
esayli
@esayli
Nov 03 2016 02:03
@MitchWilkins you can look here also for better understanding http://stackoverflow.com/questions/4943633/creating-and-parsing-a-3d-array-in-javascript
Vipersad
@Vipersad
Nov 03 2016 02:12
// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 2;

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

// Only change code below this line
var process= 2;
You should assign processArg to processed
Vipersad
@Vipersad
Nov 03 2016 02:18
Please help
Walid Ashri
@walidashri
Nov 03 2016 02:24
@Vipersad hot to call processArg with arg 7
comaeternal
@comaeternal
Nov 03 2016 02:39
Can someone check out my code. I have basically completed the challenge, but I'm stuck on one part
 function truncateString(str, num) {
  if (num < 3) {
    return str.slice(0, num) + "...";
  } else if (num > 10) {
    var x = num - 3;
    return str.slice (0, x) + "...";

  } else {
    return str.slice(-str.length);
  }

}

//truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) should return "A-tisket a-tasket A green and yellow //basket".
truncateString("A-tisket a-tasket A green and yellow basket", 11);
Tyrone
@tsaulon
Nov 03 2016 02:43
Hello, I'm working on the Wikipedia viewer and I'm trying to make request data from the API but it says "No 'Access-Control-Allow-Origin' header is present on the request source". How do I fix this?
    $(document).ready(function(){

        $('#searchContainer').addClass('animated fadeIn');

        $( "#search" ).click(function() {
                $( "#searchContainer" ).animate({
                        "margin-top": 0
                }, 500, function() { 
                //Call Ajax Function Here

                var searchItem = document.getElementById('text').value;
                var api = "https://en.wikipedia.org/w/api.php?action=opensearch&search="+ searchItem +"&format=jsonp&callback=?";

                    $.ajax({
                        url: api,
                        type: "GET",
                        async: false,
                        datatype: 'json',
                        success: function(data, status, jqXHR){
                            console.log(data);
                        }
                    });
                });
        });
    });
Mitch
@MitchWilkins
Nov 03 2016 02:43
@walidashri @esayli right now I have this collection[id][prop].push(value); but it just replaces the value instead of adding it. It updates but never keeps the previous value.
crosby11
@crosby11
Nov 03 2016 02:47
@Dubsta Hello Michael i could use some tutoring with coding javascript if you are avalable
Kurt
@recnepstruk
Nov 03 2016 02:47
hey guys. i’m getting a syntax error near unexpected token in command line for this entry. i’m trying to clone the repository into a file. <script src="https://gist.github.com/finscn/8bc573bb3a970b1c214d.js"></script>
Daniel Nora
@DanielNora
Nov 03 2016 02:50
Hey @MitchWilkins . Are you doing that when prop is not "tracks"?
crosby11
@crosby11
Nov 03 2016 02:50
@EvanDCP what is javascript tutor
Daniel Nora
@DanielNora
Nov 03 2016 02:52
When prop is "tracks", then you're supposed to verify that such property does exist within the object collection[id], by using the .hasOwnProperty() method.
If the property does not exist then you must create it and assign a new array to it. After that, simply .push(value) to it.
Stephen James
@sjames1958gm
Nov 03 2016 02:53
@comaeternal You should be comparing num to str.length not 10
Daniel Nora
@DanielNora
Nov 03 2016 02:53
When prop is not "tracks", then you simply assign value to collection[id][prop] using the assignment operator.
Mitch
@MitchWilkins
Nov 03 2016 02:56
@DanielNora no I am using it for prop == "tracks" && value !== ""
Daniel Nora
@DanielNora
Nov 03 2016 02:56
Alright, then you must make sure that collection[id].hasOwnProperty(prop) before trying to .push(value) to it.
Walid Ashri
@walidashri
Nov 03 2016 02:57
@MitchWilkins u need to check if tracks is there in the obj or not
@sjames1958gm Hello how is it going thanks
CamperBot
@camperbot
Nov 03 2016 02:57
walidashri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4153 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 03 2016 02:57
@walidashri Hey
@walidashri Trying to understand Oauth
Daniel Nora
@DanielNora
Nov 03 2016 02:58
That way you'll know if the object has the property "tracks", because some don't. If they don't, you have to create it, and assign a new array to it. After that, you can push the value to the array.
Walid Ashri
@walidashri
Nov 03 2016 02:59
@sjames1958gm yea next todo for me this never ends :cry:
Stephen James
@sjames1958gm
Nov 03 2016 02:59
@walidashri nope - I am doing this and I am 58
Walid Ashri
@walidashri
Nov 03 2016 03:00
not far just 40 yesterday
Daniel Nora
@DanielNora
Nov 03 2016 03:01
If collection[id].hasOwnProperty(prop) evaluates to false, then you need to create the "tracks" property and assign a new array to it
Brian
@BrianCodes33
Nov 03 2016 03:18
someone mind helping w/ seek and destroy?
Dylan
@dhcodes
Nov 03 2016 03:20
I can try, what code do you have so far @BrianCodes33
Brian
@BrianCodes33
Nov 03 2016 03:22
so i’m trying to understand i can use the argument in the call to place in a variable?
the arguments object
function destroyer(arr) {
  console.log(arguments);
  if (arguments === arr) {
    return true;
  }
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
i’m not really sure since they are not provided in default paramaetrs
Joseph
@revisualize
Nov 03 2016 03:24
@BrianCodes33
function unknownNumberOfArgs () {
    var args = Array.from(arguments);
    var args = [...arguments];
    return args;
}
unknownNumberOfArgs(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6);
log
CamperBot
@camperbot
Nov 03 2016 03:24
Archives for HelpJavaScript
Dylan
@dhcodes
Nov 03 2016 03:24
yeah, like @revisualize says; the first step is usually to convert the arguments to an array
Brian
@BrianCodes33
Nov 03 2016 03:24
ok
Victor McLean
@vmvictorvm
Nov 03 2016 03:24

Hi guys, I encountered a weird issue with npm. (Working with Angular 2)

  1. The dev application run fine, usually I run "npm run build" and "npm start" together and it's running fine.
  2. Now i just change some code and then I run "npm run build" and "npm start" again and I got this error:
    VM363:46 EXCEPTION: Error in app.component.html:10:8 caused by: Maximum call stack size exceeded

  3. I revert my code back to previous stage, run "npm run build" and "npm start" but I still got the same error message

Joseph
@revisualize
Nov 03 2016 03:25
function someArguments (name) {
     console.log(name);
     console.log(arguments);
     return "Hello " + name;
}
someArguments("Joseph", "is", "an", "awesome", "guy", "so", "he", "thinks");
Brian
@BrianCodes33
Nov 03 2016 03:26
so i convert the the args to an array w/ this line var args = Array.from(arguments);?
Dylan
@dhcodes
Nov 03 2016 03:26
yep
Joseph
@revisualize
Nov 03 2016 03:26
@BrianCodes33 You can. But, you don't need to for that lesson.
Brian
@BrianCodes33
Nov 03 2016 03:27
ok so now i check to see if args[0] is equal to other args
Joseph
@revisualize
Nov 03 2016 03:29
@BrianCodes33 For my second example. arguments[0] is always the first parameter.
@BrianCodes33 Look.
https://repl.it/EMSf
Brian
@BrianCodes33
Nov 03 2016 03:29
yea but how do i account for all other arguments in the call
Joseph
@revisualize
Nov 03 2016 03:29
Look at that link.
@BrianCodes33 Hint: I don't make links randomly.
:P
Okay maybe I do.. Sometimes.
Dylan
@dhcodes
Nov 03 2016 03:31
@BrianCodes33 read up on the mdn links they give
it may help
on the challenge
Joseph
@revisualize
Nov 03 2016 03:31
DING DING DING!
Dylan
@dhcodes
Nov 03 2016 03:31
@revisualize do you know how to use es6 in the editor?
i understand that it tells me how, but what's the syntax
Joseph
@revisualize
Nov 03 2016 03:32
@dhcodes Yeah, you just use it.
Dylan
@dhcodes
Nov 03 2016 03:32
oh
I thought you had to put a line like 'esversion': 6
at the top
Joseph
@revisualize
Nov 03 2016 03:32
It gives you some warnings. But, I just ignore them. It still works.
Brian
@BrianCodes33
Nov 03 2016 03:33
function destroyer(arr) {
  var args = Array.from(arguments);
  if (args[0] === args) {
    return true;
  }
}
Josaped Moreno
@androuino
Nov 03 2016 03:34
hello, please help on Mutation challenge please.
Emily Sperry
@sperrye
Nov 03 2016 03:34
I finished Basic Javascript!!
Josaped Moreno
@androuino
Nov 03 2016 03:34

function mutation(arr) {
  // extract the values from the arr
  var left = arr[0].toLowerCase();
  var right = arr[1].toLowerCase();

  for (var i = 0, len = left.length; i < len; i++) {
    for (var j = 0, len2 = right.length; j < len2; j++) {
      if (left[i].indexOf(right[j]) !== -1)
        return true;
      else
        return false;
    }
  }
}

mutation(["hello", "hey"]);
Thanks.
Daniel Nora
@DanielNora
Nov 03 2016 03:34
@sperrye Congratulations, Emily!
Brian
@BrianCodes33
Nov 03 2016 03:35
i dont think you need an inner loop @androuino
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:36
@dhcodes do you have the "convert celsius to fahrenheit" challenge done?
Josaped Moreno
@androuino
Nov 03 2016 03:37
@BrianCodes33 why?
Dylan
@dhcodes
Nov 03 2016 03:38
@AdoSae1 yep
what's up
idk why I'm trying to help @BrianCodes33 because I've apparently forgotten how to do it myself lol
Brian
@BrianCodes33
Nov 03 2016 03:39
@androuino you only need to loop through the target
Sam Nejad
@hesamnejad
Nov 03 2016 03:40
Hi, how do I set a print screen of a code inside here?
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:40
I feel like im on the edge of understanding but everyone i talk to about it is wording it differently which is messing me up. i just need to see the correct code so i can connect the dots myself.
@dhcodes
Sam Nejad
@hesamnejad
Nov 03 2016 03:40
I´m new :/
Dylan
@dhcodes
Nov 03 2016 03:40
@AdoSae1 do you have anything so far?
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:41
yea give me a min
Daniel Nora
@DanielNora
Nov 03 2016 03:41
I'm doing the Mutation one, lol
__mifflin__
@cdrainxv
Nov 03 2016 03:41
@dhcodes: Add // jshint esversion:6 at the top to stop if from throwing the warning.
Dylan
@dhcodes
Nov 03 2016 03:41
thanks @cdrainxv
CamperBot
@camperbot
Nov 03 2016 03:41
dhcodes sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:cookie: 691 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Josaped Moreno
@androuino
Nov 03 2016 03:41
@BrianCodes33 so I should remove my inner loop which is the words that needs to search.
Dylan
@dhcodes
Nov 03 2016 03:41
was missing the hint part
Daniel Nora
@DanielNora
Nov 03 2016 03:41
It's almost 2 a.m. here
Brian
@BrianCodes33
Nov 03 2016 03:43
@androuino you can have an inner loop but it is not necessary
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:43
javascriptnfjigfibue.PNG
@dhcodes
Brian
@BrianCodes33
Nov 03 2016 03:44
`for (var i=0; i<left.length; i++)
Joseph
@revisualize
Nov 03 2016 03:45

@AdoSae1
Parameters are values that get passed into your function from the function call. You can use parameters like variables.
Example:

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

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

You're not using the parameter for your function.

Josaped Moreno
@androuino
Nov 03 2016 03:46
@BrianCodes33 ok, I'll try to work on it again. Thanks btw.
CamperBot
@camperbot
Nov 03 2016 03:46
androuino sends brownie points to @briancodes33 :sparkles: :thumbsup: :sparkles:
:cookie: 7 | @briancodes33 |http://www.freecodecamp.com/briancodes33
Dylan
@dhcodes
Nov 03 2016 03:46
@AdoSae1 like joseph said, you can think of a function as a bit of code that's reusable for the parameters (the part in between the () ) passed to it
Jeff
@horusofoz
Nov 03 2016 03:47

Can you confirm this is how the Stand in Line exercise is meant to be completed?
'''
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var temp = arr.shift(); // Change this line
return temp;
}

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

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

CamperBot
@camperbot
Nov 03 2016 03:47
:bulb: to format code use backticks! ``` more info
Dylan
@dhcodes
Nov 03 2016 03:47
so right now your code is converting 30
@AdoSae1
Jeff
@horusofoz
Nov 03 2016 03:47
Markdown fail
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var temp = arr.shift();  // Change this line
  return temp;
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Dylan
@dhcodes
Nov 03 2016 03:47
but 30 or any other temperature would be passed to the function via the parameter celsius @AdoSae1
Brian
@BrianCodes33
Nov 03 2016 03:48
@androuino no problem
Dylan
@dhcodes
Nov 03 2016 03:48
the test cases on these functions work by checking that when they pass different numbers to the celsius parameter (ex. convertToF(30) ) they get the correct output
@AdoSae1
Jeff
@horusofoz
Nov 03 2016 03:49
it passes just seems sub-optimal
supermario0315
@supermario0315
Nov 03 2016 03:51
I'm still confused with this
fahrenheit = -10*9/5+32;

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

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

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

I'm supposed to get 5 outcomes
But how?
Brian
@BrianCodes33
Nov 03 2016 03:52
@revisualize i still don’t get how i hold every other instance of arguments except at 0th index and store those in a variable, then do my condition
Dylan
@dhcodes
Nov 03 2016 03:53
@supermario0315 think about it like this
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:53
@supermario0315 dude i feel you still not sticking with me
Dylan
@dhcodes
Nov 03 2016 03:53
@supermario0315 your current code only converts for -30
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:53
correct
so i only see one checkmark
supermario0315
@supermario0315
Nov 03 2016 03:54
Okay so how do I convert multiple numbers again?
Brian
@BrianCodes33
Nov 03 2016 03:54
can anyone answer my question
Dylan
@dhcodes
Nov 03 2016 03:54
but -30 will be passed into the function by the parameter celsius when the function is defined
@supermario0315
supermario0315
@supermario0315
Nov 03 2016 03:54
Ahh
Dylan
@dhcodes
Nov 03 2016 03:54
a function is reusable because it uses the parameters passed into it
supermario0315
@supermario0315
Nov 03 2016 03:54
@dhcodes I'm still a little confused on how I should do it
Ryan McMahon
@Radio-Mac
Nov 03 2016 03:55
Howdy folks. How goes it?
Dylan
@dhcodes
Nov 03 2016 03:55
well if -30 and celsius are interchangeable
...
@BrianCodes33 arguments[1] and arguments[2]?
Joseph
@revisualize
Nov 03 2016 03:55
@BrianCodes33 Why do you need to store it in a variable?
It's in an object.
supermario0315
@supermario0315
Nov 03 2016 03:56
I'm still confused overall
Ryan McMahon
@Radio-Mac
Nov 03 2016 03:56
What's this about Celsius? Is someone working on the Fahrenheit conversion problem?
supermario0315
@supermario0315
Nov 03 2016 03:56
Me
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:56
yep
me as well
supermario0315
@supermario0315
Nov 03 2016 03:56
@Radio-Mac
Ryan McMahon
@Radio-Mac
Nov 03 2016 03:56
@supermario0315 @AdoSae1 What's confusing you?
supermario0315
@supermario0315
Nov 03 2016 03:56

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

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

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

I'm supposed to get a few outcomes
but I have no idea how to do it
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:56
same^
Joseph
@revisualize
Nov 03 2016 03:56
@supermario0315 What is the "MATH" to convert Celsius to Fahrenheit?
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:57
the temperature in Celsius times 9/5, plus 32.
Ryan McMahon
@Radio-Mac
Nov 03 2016 03:57
Alright here's the drill. The (-1) in the convertToF? That's gets passed into the Celsius as a function.
supermario0315
@supermario0315
Nov 03 2016 03:57
Celsius*9/5+32;
Joseph
@revisualize
Nov 03 2016 03:57
@supermario0315 GREAT!
Ryan McMahon
@Radio-Mac
Nov 03 2016 03:57
In other words. For the function, celsius is the -1 you're working with.
Joseph
@revisualize
Nov 03 2016 03:57
@supermario0315 That's the answer.

Parameters are values that get passed into your function from the function call. You can use parameters like variables.
Example:

function hello(name) {
     return "Hello " + name + ", How is your day?";
}
hello("Joseph"); // "Hello Joseph, How is your day?"
hello("Sally"); // "Hello Sally, How is your day?"

You can use the name parameter just like a variable inside of your function.

Ryan McMahon
@Radio-Mac
Nov 03 2016 03:57
Great! You figured it out.
supermario0315
@supermario0315
Nov 03 2016 03:57
Oh
Joseph
@revisualize
Nov 03 2016 03:57
YEAH!
supermario0315
@supermario0315
Nov 03 2016 03:58
Celsius not defined XD
Dylan
@dhcodes
Nov 03 2016 03:58
This message was deleted
supermario0315
@supermario0315
Nov 03 2016 03:58
So I just need to define Celsius now
Joseph
@revisualize
Nov 03 2016 03:58
@supermario0315 It is a PARAMETER for your function.
Adolfo Saenz
@AdoSae1
Nov 03 2016 03:59
duuuuuuuuuuuuuuuuuuuude i got it......
Joseph
@revisualize
Nov 03 2016 03:59
@supermario0315 You know. That big block of text that I just posted above.
Dylan
@dhcodes
Nov 03 2016 03:59

function convertToF(celsius) { //celsius is defined here as a parameter so you can use it in your code below
  var fahrenheit;
  // Only change code below this line 
  fahrenheit = -30*9/5+32;

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

// Change the inputs below to test your code
convertToF(-1);
Sam Nejad
@hesamnejad
Nov 03 2016 03:59
How you guys set a photo or piece of code out here?
Ryan McMahon
@Radio-Mac
Nov 03 2016 03:59
Stupid question but did you define celsius as celsius and not Celsius? They're picky about capitalization.
Dylan
@dhcodes
Nov 03 2016 03:59
@hesamnejad it's three backticks ```, and then shift-enter, then paste your code
Joseph
@revisualize
Nov 03 2016 04:00

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.

supermario0315
@supermario0315
Nov 03 2016 04:00
Hmm
Dylan
@dhcodes
Nov 03 2016 04:00
so you got it @AdoSae1
?
supermario0315
@supermario0315
Nov 03 2016 04:00
Still consued XD
*Confused
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:00
yea
Dylan
@dhcodes
Nov 03 2016 04:01
@supermario0315 did you read the comment in the first line of my code above?
Brian
@BrianCodes33
Nov 03 2016 04:01
this is driving me nuts
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:01
i had -30 fixed correct
Joseph
@revisualize
Nov 03 2016 04:01
@supermario0315 How are you still confused?
supermario0315
@supermario0315
Nov 03 2016 04:01
Yeah
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:01
Alright. @AdoSae1 @supermario0315 Stop confusing yourselves.
Joseph
@revisualize
Nov 03 2016 04:01
@supermario0315 What is the math to convert Celsius to Fahrenheit?
@supermario0315 What is the parameter for your function?
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:01
The only numbers you have to work with is (9/5) and 32.
Joseph
@revisualize
Nov 03 2016 04:01
@supermario0315 What is your function returning?
Sam Nejad
@hesamnejad
Nov 03 2016 04:02
Thanks.. @dhcodes
CamperBot
@camperbot
Nov 03 2016 04:02
hesamnejad sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
Thomas Gerot
@tjgerot
Nov 03 2016 04:02
@revisualize T(°F) = T(°C) × 9/5 + 32
CamperBot
@camperbot
Nov 03 2016 04:02
:star2: 1547 | @dhcodes |http://www.freecodecamp.com/dhcodes
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:02
You should NOT but putting in any other numbers in the function.
*be
Joseph
@revisualize
Nov 03 2016 04:02
@AdoSae1 :+1:
Dylan
@dhcodes
Nov 03 2016 04:02
booooo
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:02
@AdoSae1 There you go.
Just remember to use (9/5) if it's spitting an error out at you.
Dylan
@dhcodes
Nov 03 2016 04:03
no posting answers, @supermario0315 is still working on it...
Joseph
@revisualize
Nov 03 2016 04:03
Too late.
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:03
@dhcodes To be fair they were hammering it out together.
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:03
I suck im sorry guys
Dylan
@dhcodes
Nov 03 2016 04:03
lol
no worries, it's not a huge deal
AlfonsoVACO
@AlfonsoVACO
Nov 03 2016 04:03
i've a question...
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:03
So question for those who are working through the Javascript functionality.
Dylan
@dhcodes
Nov 03 2016 04:04
what's up @AlfonsoVACO
what's up @Radio-Mac
Joseph
@revisualize
Nov 03 2016 04:04
@camperbot Thanks.
CamperBot
@camperbot
Nov 03 2016 04:04
revisualize sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 2570 | @camperbot |http://www.freecodecamp.com/camperbot
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:05
I'm working on Multiple Identical Options in Switch Statements and I just want a gentle poke to see where I'm screwing up.
function sequentialSizes(val) {
  var answer = "";
  // Only change code below this line
  switch(answer)
{
  case 1:
  case 2:
  case 3:
     answer = "Low";
    break;
  case 4:
  case 5:
  case 6:
    answer = "Mid";
    break;
  case 7:
  case 8:
  case 9:
    answer = "High";
}


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

// Change this value to test
sequentialSizes(4);
Joseph
@revisualize
Nov 03 2016 04:06
@Radio-Mac answer is "" ... Should you be using the parameter?
supermario0315
@supermario0315
Nov 03 2016 04:06
I suck at this XD
Dylan
@dhcodes
Nov 03 2016 04:06
@Radio-Mac doesn't look like you are including val anywhere
supermario0315
@supermario0315
Nov 03 2016 04:06
Still a beginner so I'm not really sure what I am doing wrong

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit = Celsius*9/5+32;

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

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

Sam Nejad
@hesamnejad
Nov 03 2016 04:06
@revisualize Thanks
CamperBot
@camperbot
Nov 03 2016 04:06
hesamnejad sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2213 | @revisualize |http://www.freecodecamp.com/revisualize
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:06
i pmd you
Dylan
@dhcodes
Nov 03 2016 04:06
@supermario0315 close
Joseph
@revisualize
Nov 03 2016 04:06

@Radio-Mac Parameters are values that get passed into your function from the function call. You can use parameters like variables.
Example:

function hello(name) {
     return "Hello " + name + ", How is your day?";
}
hello("Joseph"); // "Hello Joseph, How is your day?"
hello("Sally"); // "Hello Sally, How is your day?"

You can use the name parameter just like a variable inside of your function.

Ryan McMahon
@Radio-Mac
Nov 03 2016 04:06
@revisualize @dhcodes Darn it. I knew I missed something. Shows what I get for working on this late at night. Thanks!
CamperBot
@camperbot
Nov 03 2016 04:06
radio-mac sends brownie points to @revisualize and @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 2214 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1548 | @dhcodes |http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Nov 03 2016 04:07
but see how the parameter is lowercase? @supermario0315
that matters
Joseph
@revisualize
Nov 03 2016 04:07
@supermario0315 What is the parameter for your function?
supermario0315
@supermario0315
Nov 03 2016 04:07
OMG I GOT IT XD
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:07
That did the trick.
supermario0315
@supermario0315
Nov 03 2016 04:07
I forgot case matters XD
Dylan
@dhcodes
Nov 03 2016 04:07
WOOOOOOOOOOOOOOOO
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:07
Replacing if/else chains. Oh man this is going to be a slog.
Dylan
@dhcodes
Nov 03 2016 04:07
:tada: :tada: :tada:
supermario0315
@supermario0315
Nov 03 2016 04:07

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit = celsius*9/5+32;

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

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

Adolfo Saenz
@AdoSae1
Nov 03 2016 04:08
:+1:
supermario0315
@supermario0315
Nov 03 2016 04:08
Thanks guys :D
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:08
@dhcodes do we only have to put the word inside()?
because i put
Dylan
@dhcodes
Nov 03 2016 04:09
@AdoSae1 for which?
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:09
fahrenheit = (celsius)*9/5+32;
and that worked
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:09
By the way @supermario0315, you can use ``` for your code. Makes it nice and neat for everyone.
Dylan
@dhcodes
Nov 03 2016 04:09
you don't need the () within the function
Brian
@BrianCodes33
Nov 03 2016 04:10
function destroyer(arr) {
  var args = Array.from(arguments);
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < args.length; j++) {
      if (arr[i] === args[j]) {
        delete arr[i];
      }
    }
  }
  return arr.filter(Boolean);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:10
ok sweet thanks makes sense
Dylan
@dhcodes
Nov 03 2016 04:10
it can be fahrenheit = celsius * 9/5 + 32
Adolfo Saenz
@AdoSae1
Nov 03 2016 04:10
@dhcodes :clap:
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:11
Sheesh. Replacing the if/else statements with switch cases was more of a hassle than it needed to be.
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:36
Hello, it's me again with another request for a poke in the right direction. I'm wondering how to return the count in the Card Count challenge.

var count = 0;

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

  if (count <= 0)
    {
      return (count, "Hold");
    }
  else if(count > 0)
    {
      return (count, "Bet");
    }
  return "Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
I'm able to get whether to hold or bet working correctly, that isn't the issue. The issue is getting to see the count variable.
Joseph
@revisualize
Nov 03 2016 04:39
@Radio-Mac You're supposed to be returning a String.
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:40
It's the same when I'm just returning "Bet" or "Hold". That isn't the issue, the issue for me is the fact that apparently my either isn't being recognized or I've screwed up the count sequence.
Man, this is where having a debugger would help me out here.
__mifflin__
@cdrainxv
Nov 03 2016 04:49
@Radio-Mac: pythontutor… great visualizer
lucasoliv
@lucasoliv
Nov 03 2016 04:50
Hey guys! I am probably doing something wrong here, but I am looking at it for ages now and I am not being able to figure it out myself. Thank you in advance!
Introduction: Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
function chunkArrayInGroups(arr, size) {

var x = Math.floor(arr.length/size);  
var y = arr.length%size;
var lal = [];
var j = 1;  

for ( i = 0 ; i < x ; i++) {
  lal.push(arr.slice(i*size,size*j));
  j++;
} 

if ( y === 0) {
  return lal;
} else {  
  lal = lal.push(arr.slice(-y));
  return lal;  
}

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
Ryan McMahon
@Radio-Mac
Nov 03 2016 04:51
@cdrainxv Thanks! You are a life saver.
CamperBot
@camperbot
Nov 03 2016 04:51
radio-mac sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:cookie: 694 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Jeff
@horusofoz
Nov 03 2016 05:16
JS Exercise - Return Early Pattern for Functions - Is this meant to use an IF statement or is it meant to user the === operator from the previous exercise?
The IF statement passes but doesn't seem like it should be the right answer when the previous exercise showed how to replace IFs with this operator
supermario0315
@supermario0315
Nov 03 2016 05:17
'FirstLine \n"Second Line\n"'
Hi guys I have another question. Am I doing this wrong?
Jeff
@horusofoz
Nov 03 2016 05:18
@supermario0315 The second newline is meant to be a carriage-return
Tripped up on that yesterday
Also make sure your backslashes have an escape character as per the info from the exercise
Daniel Filimon
@dfili8
Nov 03 2016 05:22
function nextInLine(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Johnny
@JohnnyBizzel
Nov 03 2016 05:23
@horusofoz The number of people who don't get this is amazing! Escaped backslash = \\
@dfili8 Where is your code?
Daniel Filimon
@dfili8
Nov 03 2016 05:23
can anyone help on this challenge?
Johnny
@JohnnyBizzel
Nov 03 2016 05:24
@dfili8 You didn't attempt anything yet?
Jeff
@horusofoz
Nov 03 2016 05:24
@dfili8 Do you remember the pop and unshift methods?
Johnny
@JohnnyBizzel
Nov 03 2016 05:24
or shift()
Jeff
@horusofoz
Nov 03 2016 05:24
@JohnnyBizzel True. Guess it's all about stumbling before you can walk.
Daniel Filimon
@dfili8
Nov 03 2016 05:24
I tried multiple times with the push and shift functions but can only get two out of the four requirements, not sure what else i need??
Johnny
@JohnnyBizzel
Nov 03 2016 05:25
@dfili8 Your code doesn't have this attempt. What did you actually try?
Jeff
@horusofoz
Nov 03 2016 05:25
Tip: Are you returning the shifted value?
Daniel Filimon
@dfili8
Nov 03 2016 05:26
no I'm not
Jeff
@horusofoz
Nov 03 2016 05:26
You need to.
Johnny
@JohnnyBizzel
Nov 03 2016 05:27
@dfili8 What was your code that passed 2 requirements?
Jeff
@horusofoz
Nov 03 2016 05:28
@JohnnyBizzel Can you confirm if the Return Early Pattern for Functions exercise is meant to be solved with an IF statement or the === operator from the previous exercise?
Johnny
@JohnnyBizzel
Nov 03 2016 05:28
@cdrainxv <3 Python tutor. I even use it for debugging Python now :D

Return a Value from a Function with Return

We can pass values into a function with arguments. You can use a return statement to send a value back out of a function.

Example

function plusThree(num) {
  return num + 3;
}
var answer = plusThree(5); // 8
@horusofoz You mean this one ^^
__mifflin__
@cdrainxv
Nov 03 2016 05:30
@JohnnyBizzel: Ahah... You came around full circle. :smile:
Jeff
@horusofoz
Nov 03 2016 05:30
@JohnnyBizzel No this one
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0 || b < 0)
    {
      return undefined;
    }
  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Johnny
@JohnnyBizzel
Nov 03 2016 05:30

Return Early Pattern for Functions

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
  console.log("Hello");
  return "World";
  console.log("byebye")
}
myFun();
Jeff
@horusofoz
Nov 03 2016 05:35
@JohnnyBizzel That's the one. I can get it passed with my code above but feel like it shouldn't be using an if statement as the previous exercise replacing an if statement with a comparison operator to get the same result with less code.
Daniel Filimon
@dfili8
Nov 03 2016 05:36
function nextInLine(arr, item) {
  testArr.push(item);
  testArr.shift(arr);

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
nextInLine([], 1) should return 1
After nextInLine(testArr, 10), testArr[4] should be 10
those are the two that were fulfilled
Jeff
@horusofoz
Nov 03 2016 05:37

@dfili8 change return to return testArr.shift(arr);

That will return the value that was shifted

Johnny
@JohnnyBizzel
Nov 03 2016 05:37
@horusofoz I think at the stage people will be at on this challenge, it doesn't matter how they solve it.
@dfili8 The function creates a copy of the testArr array which gets used inside the scope of the function arr. Use this.
This is what makes functions able to accept any input. They don't need to use global vars.
Jeff
@horusofoz
Nov 03 2016 05:39
@JohnnyBizzel Is it possible to do with a comparison operator in less lines of code? I just want to check in case I'm not really getting how to use that tool properly
thuytn
@Sophia-nguyen
Nov 03 2016 05:40
Hi, I have two object
 var  a = {value: 1, value1: 2},
         b =  _.cloneDeep(a);
   a.value2 = 3;
  //I want set a = b and keep reference to a
Johnny
@JohnnyBizzel
Nov 03 2016 05:41
@horusofoz You could use a ternary operator I guess?
@Sophia-nguyen You have 3 now!
thuytn
@Sophia-nguyen
Nov 03 2016 05:45
@JohnnyBizzel, I updated my question. I want reset all value in Object a = Object b
Jeff
@horusofoz
Nov 03 2016 05:50
@JohnnyBizzel Thanks got it down to:
// Setup
function abTest(a, b) {
  // Only change code below this line
  return (a < 0 || b < 0) ? undefined : Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
  // Only change code above this line
}
// Change values below to test your code
abTest(2,2);
CamperBot
@camperbot
Nov 03 2016 05:50
horusofoz sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 734 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Jeff
@horusofoz
Nov 03 2016 05:51
Though likely would use an if in real life for simplicity in reading the code
Aarya Bhorra
@aarya1302
Nov 03 2016 05:51
for (i = 0; i < array.length; i++){
    for (j < array[i].length; j++){
        sorted = array[i][j].sort(function(a, b){
            return b - a;
        })
        good = [];
        good += sorted;
        nice = good;

    }

}
Johnny
@JohnnyBizzel
Nov 03 2016 05:51
@horusofoz :+1: super :sparkles:
Aarya Bhorra
@aarya1302
Nov 03 2016 05:52
I can't run this code for some reason
It says unexpected token
Johnny
@JohnnyBizzel
Nov 03 2016 05:52
@aarya1302 inner for loop is missing the initial value
@aarya1302
for (i = 0; i < array.length; i++){
var j;
 for (j = 0; j < array[i].length; j++){ 
         sorted = array[i][j].sort(function(a, b){ return b - a; }) 
           good = []; 
            good += sorted; 
    nice = good; } }
thuytn
@Sophia-nguyen
Nov 03 2016 05:59
 var  a = {value: 1, value1: 2},
         b =  _.cloneDeep(a), // Backup value of Object a
         c = a;

    c.value2 = 3; // Now a = {value: 1, value1: 2, value2: 3}

    //Then I reset value of Object c
    c = b; // c = {value: 1, value1: 2}

    -> and I want: a = {value: 1, value1: 2};
How can I do it?
Aarya Bhorra
@aarya1302
Nov 03 2016 06:01
Every time I run it says this:
for (j < array[i].length; j++){
                                 ^
SyntaxError: Unexpected token )
thuytn
@Sophia-nguyen
Nov 03 2016 06:01
@JohnnyBizzel Could you please help my solution?
Johnny
@JohnnyBizzel
Nov 03 2016 06:01
@Sophia-nguyen Sorry, I don't understand the problem.
thuytn
@Sophia-nguyen
Nov 03 2016 06:02
@JohnnyBizzel yep, thanks :)
CamperBot
@camperbot
Nov 03 2016 06:02
sophia-nguyen sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 735 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 03 2016 06:03

@aarya1302 I've never seen a for loop like that in my life.
Probably because:

\\ The for loop has the following syntax:
for (statement 1; statement 2; statement 3) {
    code block to be executed
}

http://www.w3schools.com/js/js_loop_for.asp

@Sophia-nguyen You could just add a = b if that's what you want to do.
Ian
@toianw
Nov 03 2016 06:07

@aarya1302 if your count variable is already initialized, you could do this:

var i = 0;
for (; i < 10; i++) {
    // do something
}

but it isn't so readable.

Aarya Bhorra
@aarya1302
Nov 03 2016 06:09
Ok I'll try it @toianw
Ogundele Olumide
@Lumexralph
Nov 03 2016 06:10
@aarya1302 why don't you read up a lil about the construct of a for loop? It'll help you know what you're doing and will reduce the confusion
Aarya Bhorra
@aarya1302
Nov 03 2016 06:10
ok
Thanks guys @toianw @JohnnyBizzel @Lumexralph
CamperBot
@camperbot
Nov 03 2016 06:11
aarya1302 sends brownie points to @toianw and @johnnybizzel and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 412 | @toianw |http://www.freecodecamp.com/toianw
:cookie: 736 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:cookie: 399 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Nov 03 2016 06:13
@aarya1302 :+1:
Johnny
@JohnnyBizzel
Nov 03 2016 06:14
@aarya1302 :+1: :clap:
Kanak Rajesh Sharma
@knkhere
Nov 03 2016 06:30
Can somebody please help me with Closures?
silver537
@silver537
Nov 03 2016 06:32
first=x=>second=y=>third=z=>x+y+z
Kanak Rajesh Sharma
@knkhere
Nov 03 2016 06:32
How can i return a function or a variable ass needed?
Daniel Kweon-lee
@dkweonlee
Nov 03 2016 06:33
I'm doing the golf course and im having a trouble could you help me with this?
this is my code:
function golfScore(par, strokes) {
// Only change code below this line
if (4,1){
return "Hole-in-one!";
}else if(4,2){
return "Eagle";
}else if (5,2){
return "Eagle";
}else if(4,3){
return "Bride";
}else if(4,4){
return "Par";
}else if(1,1){
return "Hole-in-one!";
}else if(5,5){
return "Par";
}else if(4,5){
return "Bogey";
}else if(4,6){
return "Double";
}else if(4,7){
return "Go Home!";
}else if(5,9){
return "Go Home!";
}
Kartikeya Gupta
@kartikeya100
Nov 03 2016 06:33
i had installed node and was doing some react, after dev dependencies of babel react webpack bla bla....i got like 50000 files in node_modules.....is that alright??
Paul Hoskinson
@plhosk
Nov 03 2016 06:35
@dkweonlee Are you joking? you are just hard coiding in every possibility
silver537
@silver537
Nov 03 2016 06:36
function first(x){
  return function second(y){
    return x + y;
  }
}

var firstValue = first(1) // assign the function called second with the value of 1 for it's x in to firstValue

console.log(firstValue(2)) // will out put the value of function called second x + y where y is the value of 2
Joseph
@revisualize
Nov 03 2016 06:37
@silver537 closure?
silver537
@silver537
Nov 03 2016 06:38
yea
it was an answer to this dude's question @knkhere
Joseph
@revisualize
Nov 03 2016 06:38
@plhosk You know what.. You can't force people to learn. If they don't want to learn how to do the lesson correctly and they want to brute force everything. They can brute force everything.
silver537
@silver537
Nov 03 2016 06:40
but really... that's a lack of thinking on their part.
Joseph
@revisualize
Nov 03 2016 06:40
@plhosk That's been discussed quite a bit actually and the Admin team said... You can't force someone to learn.
Paul Hoskinson
@plhosk
Nov 03 2016 06:40
just never actually seen it before LOL
Daniel Kweon-lee
@dkweonlee
Nov 03 2016 06:40
@plhosk work smarter! got it!
Kanak Rajesh Sharma
@knkhere
Nov 03 2016 06:40
thanx @silver537 !.. Just wondering how the cases when i pass in a string or an array to the function would be handled
CamperBot
@camperbot
Nov 03 2016 06:40
knkhere sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 665 | @silver537 |http://www.freecodecamp.com/silver537
Joseph
@revisualize
Nov 03 2016 06:40
@dkweonlee That's NOT how you're supposed to be solving the lessons.
@silver537 Thanks for becoming :imp:
CamperBot
@camperbot
Nov 03 2016 06:40
revisualize sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 666 | @silver537 |http://www.freecodecamp.com/silver537
Joseph
@revisualize
Nov 03 2016 06:40
DEVIL MAN!
silver537
@silver537
Nov 03 2016 06:40
LMAO!
my points are soooo appropriate
coincedential at best
Kanak Rajesh Sharma
@knkhere
Nov 03 2016 06:41
:laughing:
666
silver537
@silver537
Nov 03 2016 06:42
@revisualize you have summoned my dark side
Joseph
@revisualize
Nov 03 2016 06:42
log
CamperBot
@camperbot
Nov 03 2016 06:42
Archives for HelpJavaScript
silver537
@silver537
Nov 03 2016 06:43
@knkhere it's the same concept. the point is you can store a value AND a function into one variable.
Kartikeya Gupta
@kartikeya100
Nov 03 2016 06:43
i had installed node and was doing some react, after dev dependencies of babel react webpack bla bla....i got like 50000 files in node_modules.....is that alright??
Paul Hoskinson
@plhosk
Nov 03 2016 06:43
you could store multiple values, arrays, etc into the function too
silver537
@silver537
Nov 03 2016 06:44
and that function will remember it's parent function's parameter value and uses it for later use.
Paul Hoskinson
@plhosk
Nov 03 2016 06:44
50000 files? what is the total size
silver537
@silver537
Nov 03 2016 06:45
that's just a regular function. which goes without saying
Kanak Rajesh Sharma
@knkhere
Nov 03 2016 06:45
Right
Kartikeya Gupta
@kartikeya100
Nov 03 2016 06:45
151 mb 501 on disk
104,490 to be exact
Paul Hoskinson
@plhosk
Nov 03 2016 06:45
sounds plausible
not all of it will be used in any program
Kartikeya Gupta
@kartikeya100
Nov 03 2016 06:46
babel-core,loader,preset-es-2015, preset react, stage 2, react,react-dom,webpack,webpack devserver @plhosk
Paul Hoskinson
@plhosk
Nov 03 2016 06:48
as far as i know that is normal
Kartikeya Gupta
@kartikeya100
Nov 03 2016 06:50
@plhosk ok....this is my first time with nodeJS
@plhosk thanks
CamperBot
@camperbot
Nov 03 2016 06:50
kartikeya100 sends brownie points to @plhosk :sparkles: :thumbsup: :sparkles:
:cookie: 339 | @plhosk |http://www.freecodecamp.com/plhosk
Jeff
@horusofoz
Nov 03 2016 06:53
Is there a more detailed breakdown of the exercise Record Collection from Basic JavaScript?
Having trouble interpreting the instructions
silver537
@silver537
Nov 03 2016 06:54
nope
the instructions are sound
i don't want to sound mean, but please read it and reread it till you get it.
that challenge is very important
@Dreams-link-xiong
Nov 03 2016 06:56

var count = 0;

function cc(card) {
// Only change code below this line
for(var i=0;i<card.length;i++){
switch(card[i]){
case 2:
case 3:
case 4:
case 5:
case 6:
count=count+1;
break;
case 7:
case 8:
case 9:
count=count+0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count=count-1;
break;
default:
break;
}

}
if(count>0){
return count+' Bet';
}
else if(count<=0){
return count+' Hold';
}

// Only change code above this line
}

// Add/remove calls to test your function.
// 提示: Only the last will display
cc([2,3,4,5,6]);

Markus Kiili
@Masd925
Nov 03 2016 06:56
@horusofoz You should test parameters value and prop and access collection on if blocks. Tracks property needs some special care.
@Dreams-link-xiong
Nov 03 2016 06:56
Was I wrong?
silver537
@silver537
Nov 03 2016 06:57
@Dreams-link-xiong
why did you ignore this line? // Only change code above this line
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 06:58
need help
silver537
@silver537
Nov 03 2016 06:59
@poseidonrage i need help too..
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 06:59
ask @silver537
silver537
@silver537
Nov 03 2016 07:00
@poseidonrage why didn't you?!!? :(
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:00
@silver537 I am on queue question
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.
silver537
@silver537
Nov 03 2016 07:01
lol
that blew me away xD
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:01
function nextInLine(arr, item) {
// Your code here
var removal = arr[0];
arr.push(item);
arr.shift();
return removal; // Change this line
}
this is the function i wrote
@Dreams-link-xiong
Nov 03 2016 07:01
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:01
:sparkles: what happened
silver537
@silver537
Nov 03 2016 07:02
@poseidonrage you're supposed to return the value of shift
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:02
@silver537 var removal = arr.shift(); ?
silver537
@silver537
Nov 03 2016 07:02
yessir!
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:03
nop it didnt worked
i just tried it
silver537
@silver537
Nov 03 2016 07:04
@Dreams-link-xiong reset the code, and do everything you did except the for loop and the array.
just return shift
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:04
all is green except this
nextInLine([], 1) should return 1
silver537
@silver537
Nov 03 2016 07:05
just return shift
@Dreams-link-xiong
Nov 03 2016 07:05

@silver537 var count = 0;

function cc(card) {
// Only change code below this line
for(var i=0;i<card.length;i++){
switch(card[i]){
case 2:
case 3:
case 4:
case 5:
case 6:
count=count+1;
break;
case 7:
case 8:
case 9:
count=count+0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count=count-1;
break;
default:
break;
}

}
if(count>0){
return count+' Bet';
}
else if(count<=0){
return count+' Hold';
}

// Only change code above this line
}

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

silver537
@silver537
Nov 03 2016 07:06
@Dreams-link-xiong no forloop. in your switch, it should only be card
Conor Murphy
@cmurphy580
Nov 03 2016 07:07
anyone know whats up with this api? Can't get it to get any coordinates.
var api = "http://api.openweathermap.org/data/2.5/weather?lat="+ lat +"&lon="+ lon +"&appid=70cdf3a8238732af45a9704ee5633da8';
tried removing the spaces, nothing works
silver537
@silver537
Nov 03 2016 07:08
@cmurphy580 what are you using to get coordinates?
Joseph
@revisualize
Nov 03 2016 07:08
Need to crossorigin.
@cmurphy580
Conor Murphy
@cmurphy580
Nov 03 2016 07:09
@silver537 the "get position" code from one of the lessons. @revisualize What do you mean? whats crossorigin?
silver537
@silver537
Nov 03 2016 07:12
it's an HTTP thing
just use it
if you're on chrome and you're on an unsecure server, the geolocation wont work
Ashish Jambhulkar
@ashjambhulkar
Nov 03 2016 07:15
is not working

'This string has "double quotes" in it. And "probably" lots of them.'

Instructions
Change the provided string from double to single quotes and remove the escaping.

silver537
@silver537
Nov 03 2016 07:16
This message was deleted
CODE
naaaaoooowwww
Joseph
@revisualize
Nov 03 2016 07:19
@silver537 i post a like to the thing and i still get asked whats the thing.
Conor Murphy
@cmurphy580
Nov 03 2016 07:19
changed it to single quotes . still doesn't work.Yep I'm on chrome. How do i use crossorigin?
@silver537
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:19
@ashjambhulkar
Joseph
@revisualize
Nov 03 2016 07:19
You go to the website. It tells you.
Conor Murphy
@cmurphy580
Nov 03 2016 07:19
nevermind
Yasser Hussain
@yasserhussain1110
Nov 03 2016 07:20
Is it possible to make ajax POST request to a different server than mine? my request params can't be json?
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:21
@cmurphy580 i I avoided the security issue of chrome with httprequest,i used firefox and used jsonp, i used forecast weather api though
LydaTech
@lydatech
Nov 03 2016 07:21
@yasserhussain1110 or http://api.jquery.com/jquery.ajax/ be careful about CORS issues
Yasser Hussain
@yasserhussain1110
Nov 03 2016 07:23
@lydatech will it work even for different server. I mean same origin policy won't be a problem here??
Cyril de Wit
@cyrildewit
Nov 03 2016 07:24
Does anyone know a library like jQuery but then with only event handlers?
LydaTech
@lydatech
Nov 03 2016 07:24
@yasserhussain1110 CORS will always be an issue
Vijayanandkrishnan
@Vijayanandkrishnan
Nov 03 2016 07:26

hi , for Record Collection
function updateRecords(id, prop, value) {
if ( value!=="" )
{
collection[id][prop]=value;
}

else if (prop==="tracks" && value!=="" )
{

collection[id][[tracks]].push(value);

//collection.id.tracks.push(new1);
}

else if ( value==="" )
{
delete collection[id][prop]; }

return collection;
}
I am not getting the update tracks part correct. what part is wrong?https://www.freecodecamp.com/challenges/record-collection#

@Dreams-link-xiong
Nov 03 2016 07:28
@silver537 I got it. Thank you.
CamperBot
@camperbot
Nov 03 2016 07:28
:cookie: 667 | @silver537 |http://www.freecodecamp.com/silver537
dreams-link-xiong sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
Jeff
@horusofoz
Nov 03 2016 07:28
@silver537 Got there in the end. I feel like having some explanation of what was done with the different possible actions such as below is really helpful.
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  //Set property value
  if (prop !== "tracks" && value !== "") {
    collection[id][prop] = value;
  }
  //Set tracks
  else if (prop === "tracks" && !collection[id].hasOwnProperty("tracks")) {
    var tempTracks = [];
    tempTracks.push(value);
    collection[id].tracks = tempTracks;
  }
  //Add track
  else if (prop === "tracks" && value !== "") {
    collection[id].tracks.push(value);
  }
 //Delete property from id/album
  else if (value === "") {
    delete collection[id][prop];
  }
  //return full collection
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
silver537
@silver537
Nov 03 2016 07:31
good!
Roman Struna
@RomchyFCC
Nov 03 2016 07:33
case value1:
//Statements executed when the result of expression matches value1
[break;]
case value2:
//Statements executed when the result of expression matches value2
[break;]
...
case valueN:
//Statements executed when the result of expression matches valueN
[break;]
default:
//Statements executed when none of the values match the value of the expression
[break;]
ugh sorry guys
how can i copy one of the puzzles, i am pretty sure i have the correct answer but it keeps throwing out a syntax error, could some one help me with what i am missing?
Jeff
@horusofoz
Nov 03 2016 07:35
@RomchyFCC Can you copy it into a JSFiddle or PasteBin?
Markus Kiili
@Masd925
Nov 03 2016 07:35
@horusofoz By ordering the conditions differently, you can avoid some repeating ones:
function updateRecords(id, prop, value) {
  if (value==="") delete collection[id][prop];
  else if (prop!=="tracks") collection[id][prop]=value;
  else if (collection[id].hasOwnProperty(prop)) collection[id][prop].push(value);   
  else collection[id][prop]=[value];
  return collection;
}
Samiullah Khan
@technbuzz
Nov 03 2016 07:35
Help needed in Wherefore art thou algorithm
CamperBot
@camperbot
Nov 03 2016 07:35
no wiki entry for: needed in wherefore art thou algorithm
Conor Murphy
@cmurphy580
Nov 03 2016 07:35
Alright for some reason this isn't grabbing my current location..
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position){
any ideas why?
Samiullah Khan
@technbuzz
Nov 03 2016 07:36
Have you given permission of your location @cmurphy580
Conor Murphy
@cmurphy580
Nov 03 2016 07:36
how would i go about doing that>
Markus Kiili
@Masd925
Nov 03 2016 07:36
@technbuzz Sure.
Roman Struna
@RomchyFCC
Nov 03 2016 07:36
@horusofoz https://jsfiddle.net/bzuj1yqe/ does this work?
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:37
@cmurphy580 from your pc or browser settings
Conor Murphy
@cmurphy580
Nov 03 2016 07:37
Yah i think its authorized. It gets my location on other websites
even the lesson where i got that code
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:38
@cmurphy580 are you using chrome?
Jeff
@horusofoz
Nov 03 2016 07:38
@RomchyFCC You need to update the answer value. e.g. answer = "Alpha"
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:38
@cmurphy580 if yes chrome will not allow a location request from a localhost
Samiullah Khan
@technbuzz
Nov 03 2016 07:38
You also need to use https protocol @cmurphy580
silver537
@silver537
Nov 03 2016 07:39

@RomchyFCC @horusofoz
backticks
` <- backtick

``` <-three here
code here

``` <- then three here

Roman Struna
@RomchyFCC
Nov 03 2016 07:39
oh, of course, how stupid of me...thank you so much @horusofoz
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:40
i am still stuck :worried:
Jeff
@horusofoz
Nov 03 2016 07:40
@RomchyFCC You're welcome. Always good to help someone else with how many answers I've gotten in here.
Conor Murphy
@cmurphy580
Nov 03 2016 07:40
@Lumexralph @technbuzz I'm using crossorigin. Is that what you mean by the https protocol
silver537
@silver537
Nov 03 2016 07:40
@cmurphy580 in your address bar, it should say something like https://blah.com/blah/
if it doesn't have the https then it wont work
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:40
blob
Roman Struna
@RomchyFCC
Nov 03 2016 07:40
@silver537 what do you mean with backtick? :O
also how do i send brownies and stuff :D?
silver537
@silver537
Nov 03 2016 07:41
` <- THATS A BACK TICK
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:41
@cmurphy580 https is just a scheme like http. ftp..crossorigin is a site that helps solve CORS issues
Conor Murphy
@cmurphy580
Nov 03 2016 07:41
alright. But shouldn't that getlocation code grab my coordinates @silver537 @Lumexralph
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:41
@silver537 ?
Roman Struna
@RomchyFCC
Nov 03 2016 07:42
@silver537 oh ok....OOOHHH you mean for me to paste code in here or?
Jeff
@horusofoz
Nov 03 2016 07:42
@RomchyFCC The back tick key is normally location to the left on a standard keyboard. It's alternate is a tilde ~
silver537
@silver537
Nov 03 2016 07:42
@cmurphy580 it will if you are using https
freecodecamp.com/ wont work.
https://freecodecamp.com/ will work
@RomchyFCC yes
Samiullah Khan
@technbuzz
Nov 03 2016 07:42
No @cmurphy580 Cross Origin has nothing to do with Mismatch content
Conor Murphy
@cmurphy580
Nov 03 2016 07:44
here is what i have. Its not asking me if i want this site to have my location.
$(document).ready(function(){
   var lat;
   var lon;
   var temp;

   if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position){


    lat = position.coords.latitude;
    lon = position.coords.longitude;


     var api = "https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&appid=70cdf3a8238732af45a9704ee5633da8";

     $.getJSON(api, function(data){
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:44
ok

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

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

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


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

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Roman Struna
@RomchyFCC
Nov 03 2016 07:45
var Romchy = "learning"
text("I am " + Romchy, 50, 35);
Conor Murphy
@cmurphy580
Nov 03 2016 07:45
@technbuzz @silver537 @Lumexralph
here is what i have. Its not asking me if i want this site to have my location.
$(document).ready(function(){
   var lat;
   var lon;
   var temp;

   if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position){


    lat = position.coords.latitude;
    lon = position.coords.longitude;


     var api = "https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&appid=70cdf3a8238732af45a9704ee5633da8";

     $.getJSON(api, function(data){
Markus Kiili
@Masd925
Nov 03 2016 07:46
@poseidonrage Remove the first and last line and just return the value of arr.shift() by putting return before it.
silver537
@silver537
Nov 03 2016 07:46
@cmurphy580 paste your screen shot in here
Roman Struna
@RomchyFCC
Nov 03 2016 07:47
@silver537 @horusofoz thanks again guys, HUGGEEE help #giveTheseGuysACookie (because i don't know how :/)
CamperBot
@camperbot
Nov 03 2016 07:47
romchyfcc sends brownie points to @silver537 and @horusofoz :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for horusofoz
:cookie: 668 | @silver537 |http://www.freecodecamp.com/silver537
Baqar Hussain Naqvi
@poseidonrage
Nov 03 2016 07:47
thanks @Masd925
CamperBot
@camperbot
Nov 03 2016 07:47
poseidonrage sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2828 | @masd925 |http://www.freecodecamp.com/masd925
Shubham Sharma
@shubham1604
Nov 03 2016 07:47
Hi...does anyone know cocos2d js here?
Conor Murphy
@cmurphy580
Nov 03 2016 07:48
blob
@silver537
Jeff
@horusofoz
Nov 03 2016 07:48
Any idea what's not configured right with :warning: could not find receiver for horusofoz
silver537
@silver537
Nov 03 2016 07:48
yep just as i thought
@cmurphy580 it's like you havn't been listening at all. -.-
Samiullah Khan
@technbuzz
Nov 03 2016 07:48
Oh @cmurphy580 codepen is not on https
silver537
@silver537
Nov 03 2016 07:49
on the very top in your address bar. put https:// before codepen
Conor Murphy
@cmurphy580
Nov 03 2016 07:49
@silver537 shoot. god. my bad. thats all you have to and it'll keep it that way for here on out
silver537
@silver537
Nov 03 2016 07:50
maybe maybe not. but you have to keep an eye on it.
Conor Murphy
@cmurphy580
Nov 03 2016 07:50
@silver537 @technbuzz @Lumexralph My bad again. Thanks for the help
CamperBot
@camperbot
Nov 03 2016 07:50
cmurphy580 sends brownie points to @silver537 and @technbuzz and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 669 | @silver537 |http://www.freecodecamp.com/silver537
:cookie: 273 | @technbuzz |http://www.freecodecamp.com/technbuzz
:cookie: 400 | @lumexralph |http://www.freecodecamp.com/lumexralph
Vijayanandkrishnan
@Vijayanandkrishnan
Nov 03 2016 07:51
hi, in record collection, how to check for : If prop is "tracks" but the album doesn't have a "tracks" property,
Roman Struna
@RomchyFCC
Nov 03 2016 07:51

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

case 2:
answer "beta";
break;

case 3:
answer "gamma";
break;

case 4:
answer "delta";
break;

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

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


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

  case 2:
  answer "beta";
  break;

  case 3:
  answer "gamma";
  break;

  case 4:
  answer "delta";
  break;


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

// Change this value to test
caseInSwitch(1);
silver537
@silver537
Nov 03 2016 07:51
@horusofoz you havn't linked your github to this.
Vijayanandkrishnan
@Vijayanandkrishnan
Nov 03 2016 07:51
Can anyone help
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:51
@technbuzz i think it's
Roman Struna
@RomchyFCC
Nov 03 2016 07:51
still getting a syntax error: unexpexted token case if anyone could help :/
Vijayanandkrishnan
@Vijayanandkrishnan
Nov 03 2016 07:51
hi, in record collection, how to check for : If prop is "tracks" but the album doesn't have a "tracks" property,
silver537
@silver537
Nov 03 2016 07:52
@RomchyFCC you're not assigning anything to answer
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:52
@technbuzz because when I did my weather app I had to use https to request my pen
Markus Kiili
@Masd925
Nov 03 2016 07:52
@Vijayanandkrishnan if(prop==="tracks"). For property existence use .hasOwnProperty() method.
Jeff
@horusofoz
Nov 03 2016 07:52
@RomchyFCC Can you post your current code?
Roman Struna
@RomchyFCC
Nov 03 2016 07:53
that is my current one @horusofoz
Ogundele Olumide
@Lumexralph
Nov 03 2016 07:53
@cmurphy580 all good !
silver537
@silver537
Nov 03 2016 07:53
@RomchyFCC youre. not. assigning. anything. to. answer
Roman Struna
@RomchyFCC
Nov 03 2016 07:53
@horusofoz i honestly have 0 clue what i need to assign to answer
Jeff
@horusofoz
Nov 03 2016 07:54

@RomchyFCC

answer  =  "alpha";

etc

silver537
@silver537
Nov 03 2016 07:54
^
Roman Struna
@RomchyFCC
Nov 03 2016 07:55
ok so i did that but still showing a syntax error starting at case 1: line
silver537
@silver537
Nov 03 2016 07:56
@RomchyFCC oh. you're forgetting the switch(){} syntax
Roman Struna
@RomchyFCC
Nov 03 2016 07:57
OOOH of course, i thought the function did that for me, gosh i should have seen that, @silver537 thanks again
CamperBot
@camperbot
Nov 03 2016 07:57
romchyfcc sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:warning: romchyfcc already gave silver537 points
Jeff
@horusofoz
Nov 03 2016 07:57
@silver537 How to link account? I must have missed a step when doing the FCC signup
silver537
@silver537
Nov 03 2016 07:59
about @horusofoz
CamperBot
@camperbot
Nov 03 2016 07:59
:warning: no user found for horusofoz
silver537
@silver537
Nov 03 2016 07:59
ah.
Jeff
@horusofoz
Nov 03 2016 07:59
I sign into Gitter with GitHub so unsure how not linked.
silver537
@silver537
Nov 03 2016 07:59
you have to link it to fcc
my bad
Jeff
@horusofoz
Nov 03 2016 08:00
about @horusofoz
CamperBot
@camperbot
Nov 03 2016 08:00
:cookie: 215 | @horusofoz |http://www.freecodecamp.com/horusofoz
Jeff
@horusofoz
Nov 03 2016 08:00
There we go :)
Thanks @silver537
CamperBot
@camperbot
Nov 03 2016 08:00
horusofoz sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 670 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Nov 03 2016 08:00
np
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:10
anyone needs help
typdragon
@typdragon
Nov 03 2016 08:17
hello wurld
I wonder if anyone can help me with a js question?
I want to put an array in a function and get the total of the array. I'm not sure if i'm on the right track but this is what i have
var my_max = function(num){
for (var i = 0; i <= num.length; i++) {
return i += num;
}
};
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:21
@typdragon hello there
typdragon
@typdragon
Nov 03 2016 08:21
@aman-kumayu Hi :D
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:21
@typdragon your challenge is to sum all the elements of array right !
typdragon
@typdragon
Nov 03 2016 08:22
@aman-kumayu yep
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:23
var my_max=function(num)
{
var sum=0;
for(var i=0;i<=num.length;i++)
{
sum=sum+i;
}
return sum;
}
you should add i everytime you increment in your for loop and then return the sum variable will get you the sum of all elements of array
typdragon
@typdragon
Nov 03 2016 08:24
oooh @aman-kumayu I seee
Markus Kiili
@Masd925
Nov 03 2016 08:24
@typdragon Are you trying to get a sum of the elements of an array?
typdragon
@typdragon
Nov 03 2016 08:24
@aman-kumayu I recognise that code
@Masd925 yes
oh, maybe I didn't specify that properly to aman
Markus Kiili
@Masd925
Nov 03 2016 08:25
@typdragon Then you need to sum = sum + num[i]
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:25
@typdragon oh that i forgot
Markus Kiili
@Masd925
Nov 03 2016 08:25
i loops over indices and num[i] is one element.
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:26
@Masd925 right
typdragon
@typdragon
Nov 03 2016 08:26
@Masd925 got it
thanks both, i'll go try it
CamperBot
@camperbot
Nov 03 2016 08:26
typdragon sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2829 | @masd925 |http://www.freecodecamp.com/masd925
typdragon
@typdragon
Nov 03 2016 08:26
@aman-kumayu thanks :D
CamperBot
@camperbot
Nov 03 2016 08:26
typdragon sends brownie points to @aman-kumayu :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @aman-kumayu |http://www.freecodecamp.com/aman-kumayu
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:27
np
Markus Kiili
@Masd925
Nov 03 2016 08:27
@aman-kumayu num is not really a good name for an array. function(arr) would be better for readability.
typdragon
@typdragon
Nov 03 2016 08:27
@Masd925 that's more my fault, he was using my code
Abhishek S
@abjoker
Nov 03 2016 08:27
is there a built in function in javascript to check a string for non-alphanumeric characters
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:27
@Masd925 yeah
Markus Kiili
@Masd925
Nov 03 2016 08:27
@typdragon Yeah, sorry
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:28
@abjoker you should regex
typdragon
@typdragon
Nov 03 2016 08:28
I was a bit confused over how to get an array in a function tbh
I thought i'd need []
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:28
@abjoker you should use
```
Markus Kiili
@Masd925
Nov 03 2016 08:29
@typdragon JS variables and parameters don't have types. Only values do.
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:29
var regex='/[^a-zA-Z]/g'
Jeff Shapiro
@Jeff-Shapiro
Nov 03 2016 08:31
@Masd925 should be sum += num[i];
Markus Kiili
@Masd925
Nov 03 2016 08:32
@Jeff-Shapiro That is just a shorthand of the same thing.
Jeff Shapiro
@Jeff-Shapiro
Nov 03 2016 08:32
@Masd925 its good practice ;)
typdragon
@typdragon
Nov 03 2016 08:33
how would I then call this code? :blush:
Karan Bansal
@karanb23
Nov 03 2016 08:33
What is the solution of increment with the javascript
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:34
@typdragon it just simply means sum=sum+num[i];
Karan Bansal
@karanb23
Nov 03 2016 08:34
Cause what i know it should myVar++
but it is not getting accepted]
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:34
@karanb23 i didnt understand what are you saying ?
typdragon
@typdragon
Nov 03 2016 08:34
@aman-kumayu I mean, what would my console.log be?
Karan Bansal
@karanb23
Nov 03 2016 08:35

var myVar =87;

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

this was the code i had to change it using increment operator
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:35
@typdragon console.log(my_max);
Karan Bansal
@karanb23
Nov 03 2016 08:36
so var myVar=88;
and myVar++;
it increments myVar variable
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:36
@karanb23 you write myVar=myVar++;
Karan Bansal
@karanb23
Nov 03 2016 08:36
i tried that too but it is not getting accepted
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:37
or you should write myVar=myVar+1;
Karan Bansal
@karanb23
Nov 03 2016 08:38
it was written as it is in the code and in instructions it is written that you have to change myVar=myVar
and i have tried that too
well myVar=myVar++ is not right as it ll return the no. as it is and than it'll increment after that
typdragon
@typdragon
Nov 03 2016 08:39
@aman-kumayu one more question about how to put an array into the code to try it out?
@karanb23 i believe you have to make a 'for' statement
kirbyedy
@kirbyedy
Nov 03 2016 08:42
@karanb23 why did you change this ?
var myVar =88;
reset the code and try again
that line should have the number 87
Karan Bansal
@karanb23
Nov 03 2016 08:42
ok
kirbyedy
@kirbyedy
Nov 03 2016 08:42
and when you try myVar++ it will be ok
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:44
@karanb23
var myVar = 87;

// Only change code below this line
myVar++;
use this
@typdragon yes
what you were asking about ?
Karan Bansal
@karanb23
Nov 03 2016 08:45
Well thanks for that i think i had brain freeze . My fault
i knew it but i was overthinking
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:45
@karanb23 mention @name for thanking
typdragon
@typdragon
Nov 03 2016 08:46

@aman-kumayu oh right

var my_max = function(arr){
for (var i = 0; i <= arr.length; i++) {
sum = i += arr[i];
}
};
console.log(my_max);

if that's the code where would I write an example array?

Aman Kumayu
@aman-kumayu
Nov 03 2016 08:48
var arr=[1,2,3,4];
you should declare arr before var my_max;
@karanb23 are you there ?
typdragon
@typdragon
Nov 03 2016 08:49
@aman-kumayu gottit, thankyou
CamperBot
@camperbot
Nov 03 2016 08:49
typdragon sends brownie points to @aman-kumayu :sparkles: :thumbsup: :sparkles:
:warning: typdragon already gave aman-kumayu points
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:49
np
Karan Bansal
@karanb23
Nov 03 2016 08:50
Thanks @aman-kumayu
CamperBot
@camperbot
Nov 03 2016 08:50
karanb23 sends brownie points to @aman-kumayu :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @aman-kumayu |http://www.freecodecamp.com/aman-kumayu
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 08:51
hey every one
how can i target the first letter of every word in an array
Dan Couper
@DanCouper
Nov 03 2016 08:52
@typdragon you are finding the sum of the values in the array, not the maximum value in the array, you should rename the function.
my_max implies you want the max value
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:53
@Dorcy-ndg3
```
function target_element(arr)
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 08:53
@DanCouper my-max is just the name of the var
Dan Couper
@DanCouper
Nov 03 2016 08:53
...which is the name of a function
my_max = function() { //blah blah }
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 08:54
@aman-kumayu would that get every single first letter of a sentence??
Buhari Nasir Ahmad
@buharinasir
Nov 03 2016 08:54
please this my code is not working i need help?
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 08:54
ohh @DanCouper i had misunderstood ur comment
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:54
@Dorcy-ndg3
function target_element(arr)
{
var str=arr.split(" ");
for(var i=0;i<str.length;i++)
{
first_char=str[i].charAt(0);
}
}
Buhari Nasir Ahmad
@buharinasir
Nov 03 2016 08:54

function smallestCommons(arr) {
// Sort array from greater to lowest
// This line of code was from Adam Doyle (http://github.com/Adoyle2014)
arr.sort(function(a, b) {
return b - a;
});

// Create new array and add all values from greater to smaller from the
// original array.
var newArr = [];
for (var i = arr[0]; i >= arr[1]; i--) {
newArr.push(i);
}

// Variables needed declared outside the loops.
var quot = 0;
var loop = 1;
var n;
// Run code while n is not the same as the array length.
do {
quot = newArr[0] loop newArr[1];
for (n = 2; n < newArr.length; n++) {
if (quot % newArr[n] !== 0) {
break;
}
}

loop++;

} while (n !== newArr.length);

return quot;
}

// test here
smallestCommons([1,5]);

Dan Couper
@DanCouper
Nov 03 2016 08:54
np ;)
Buhari Nasir Ahmad
@buharinasir
Nov 03 2016 08:55

function smallestCommons(arr) {
// Sort array from greater to lowest
// This line of code was from Adam Doyle (http://github.com/Adoyle2014)
arr.sort(function(a, b) {
return b - a;
});

// Create new array and add all values from greater to smaller from the
// original array.
var newArr = [];
for (var i = arr[0]; i >= arr[1]; i--) {
newArr.push(i);
}

// Variables needed declared outside the loops.
var quot = 0;
var loop = 1;
var n;
// Run code while n is not the same as the array length.
do {
quot = newArr[0] loop newArr[1];
for (n = 2; n < newArr.length; n++) {
if (quot % newArr[n] !== 0) {
break;
}
}
function smallestCommons(arr) {
// Sort array from greater to lowest
// This line of code was from Adam Doyle (http://github.com/Adoyle2014)
arr.sort(function(a, b) {
return b - a;
});

// Create new array and add all values from greater to smaller from the
// original array.
var newArr = [];
for (var i = arr[0]; i >= arr[1]; i--) {
newArr.push(i);
}

// Variables needed declared outside the loops.
var quot = 0;
var loop = 1;
var n;
// Run code while n is not the same as the array length.
do {
quot = newArr[0] loop newArr[1];
for (n = 2; n < newArr.length; n++) {
if (quot % newArr[n] !== 0) {
break;
}
}
loop++;
} while (n !== newArr.length);

return quot;
}

// test here
smallestCommons([1,5]);
} while (n !== newArr.length);

return quot;
}

// test here
smallestCommons([1,5]);

D O R C ¥
@Dorcy-ndg3
Nov 03 2016 08:56
thanks @aman-kumayu
CamperBot
@camperbot
Nov 03 2016 08:56
dorcy-ndg3 sends brownie points to @aman-kumayu :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @aman-kumayu |http://www.freecodecamp.com/aman-kumayu
Aman Kumayu
@aman-kumayu
Nov 03 2016 08:56
@Dorcy-ndg3 that function is written by me just for you
@Dorcy-ndg3 np
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 08:59
@aman-kumayu wont i need to join what i split at the end??
Aman Kumayu
@aman-kumayu
Nov 03 2016 09:00
@Dorcy-ndg3 no need for joining because you just asked for getting the first letter of each string
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 09:00
it says 0 is not defined
function titleCase(str) {
  var string = str.split(" ");
  for (var i=o; i<string.length; i++){
    firstChar=string[i].charAt(0).toUpperCase;
  }
  return firstChar;
}

titleCase("I'm a little tea pot");
Ademola Adegbuyi
@ooade
Nov 03 2016 09:01
@Dorcy-ndg3 var i=o.. :wink: Should be number 0
Matej
@Purgarama
Nov 03 2016 09:02
hello
typdragon
@typdragon
Nov 03 2016 09:02
@DanCouper I see that, my_max is the name they gave me to use and i'm not too bothered it doesn't make sense right now 'cause it's still not working :sob:
Dan Couper
@DanCouper
Nov 03 2016 09:03
You haven’t copied what @aman-kumayu wrote
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 09:03
@marhyorh that was helpful and thanks, tho it still doesnt pass the test
CamperBot
@camperbot
Nov 03 2016 09:03
dorcy-ndg3 sends brownie points to @marhyorh :sparkles: :thumbsup: :sparkles:
:cookie: 769 | @marhyorh |http://www.freecodecamp.com/marhyorh
Matej
@Purgarama
Nov 03 2016 09:03
can someone help me with chalenge 171 i dont understand something
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 09:03
whats the name of the challenge
Matej
@Purgarama
Nov 03 2016 09:03
Access MultiDimensional Arrays With Indexes
typdragon
@typdragon
Nov 03 2016 09:04
@DanCouper I've been tinkering with it, I'm trying it with a real array
Ademola Adegbuyi
@ooade
Nov 03 2016 09:04
@Dorcy-ndg3 .toUpperCase is a function method... should be toUpperCase()
Dan Couper
@DanCouper
Nov 03 2016 09:04
@typdragon
var my_max = function(arr){
  for (var i = 0; i <= arr.length; i++) {
    sum = i += arr[i];
  }
};
this isn’t going to work
Jaswanth Chadalavada
@intrnt-sud-b-free
Nov 03 2016 09:04
/// Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.
Ademola Adegbuyi
@ooade
Nov 03 2016 09:04
@Dorcy-ndg3 And besides, it won't still pass
Jaswanth Chadalavada
@intrnt-sud-b-free
Nov 03 2016 09:04
help me with that please !
CamperBot
@camperbot
Nov 03 2016 09:04
no wiki entry for: me with that please
Jaswanth Chadalavada
@intrnt-sud-b-free
Nov 03 2016 09:05
Been stuck here
Dan Couper
@DanCouper
Nov 03 2016 09:05
@typdragon
var my_max = function(arr){
  // initialise a variable `sum`
  var sum = 0;
  // loop through the array
  for (var i = 0; i <= arr.length; i++) {
   // add the values to `sum`
    sum += arr[i];
  }
  // return the final sum
  return sum;
};
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 09:06
@marhyorh yuh it doesnt, it brings the first letter in upper case though i want the whole sentence
what should i return then
Dan Couper
@DanCouper
Nov 03 2016 09:06
@typdragon this still won’t work though
Ademola Adegbuyi
@ooade
Nov 03 2016 09:06
@Dorcy-ndg3 You need to add the remaining part of the characters
D O R C ¥
@Dorcy-ndg3
Nov 03 2016 09:07
asin
typdragon
@typdragon
Nov 03 2016 09:07
@DanCouper aye, why's that?
Ademola Adegbuyi
@ooade
Nov 03 2016 09:07
@Dorcy-ndg3 like
string[i].charAt(0).toUpperCase() + string[i].slice(1);
Dan Couper
@DanCouper
Nov 03 2016 09:07
<=
typdragon
@typdragon
Nov 03 2016 09:08
ohhhhh
Jaswanth Chadalavada
@intrnt-sud-b-free
Nov 03 2016 09:08
can anyone help me with manipulating complex objects taks ?
Dan Couper
@DanCouper