These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Apr 2016
llamatarianism
@llamatarianism
Apr 24 2016 00:00 UTC
help format
CamperBot
@camperbot
Apr 24 2016 00:00 UTC

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

CaffeineQueen
@CaffeineQueen
Apr 24 2016 00:20 UTC
Hello World
CamperBot
@camperbot
Apr 24 2016 00:20 UTC

welcome to FreeCodeCamp @CaffeineQueen!

CaffeineQueen
@CaffeineQueen
Apr 24 2016 00:20 UTC
So friendly... <3 @camperbot
Stephane
@overmelo
Apr 24 2016 00:35 UTC
anyone has done confirm the ending challenge?
Joseph
@revisualize
Apr 24 2016 00:35 UTC
Hehe
Base link?
heymark
@heymark
Apr 24 2016 00:36 UTC
@overmelo yep
Stephane
@overmelo
Apr 24 2016 00:37 UTC
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor

  var words= str.substr(-1);



  return words===target;
}

confirmEnding("Bastian", "n");
this is my code
can you guys guide on how i can finish it?
heymark
@heymark
Apr 24 2016 00:40 UTC
@overmelo using the negative index with substr is a good start
you want to find out whether the last n characters of str === target, right?
so instead of str.substr(-1), you'd want to check str.substr(the length of target). Yes?
Stephane
@overmelo
Apr 24 2016 00:42 UTC
@heymark i guess yes
heymark
@heymark
Apr 24 2016 00:43 UTC
so what would you use instead of -1 to get the length of target?
Stephane
@overmelo
Apr 24 2016 00:45 UTC
string.lenght-1?
heymark
@heymark
Apr 24 2016 00:46 UTC
not quite. Your target string is called target, so the length of it would be target.length
Stephane
@overmelo
Apr 24 2016 00:47 UTC
ok let me try that
llamatarianism
@llamatarianism
Apr 24 2016 00:47 UTC
actually you'd need -target.length
heymark
@heymark
Apr 24 2016 00:48 UTC
yep
getting there :)
llamatarianism
@llamatarianism
Apr 24 2016 00:48 UTC
str.substr(target.length) would be from the BEGINNING of the string
you need to make it negative, so it's from the end
Mike Olie
@SwiftMike
Apr 24 2016 00:49 UTC

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], 2)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Stephane
@overmelo
Apr 24 2016 00:49 UTC
wow thanks to @heymark AND @llamatarianism
CamperBot
@camperbot
Apr 24 2016 00:49 UTC
overmelo sends brownie points to @heymark and @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 211 | @heymark | http://www.freecodecamp.com/heymark
:star: 428 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
Mike Olie
@SwiftMike
Apr 24 2016 00:49 UTC
this is my code and i need help with the queue challenge
I'm confused as to how i can add the number to the end of the array, then remove the first element of array.
llamatarianism
@llamatarianism
Apr 24 2016 00:50 UTC
@FreshSteak use the push method to add elements to the end of the array
arr.push(item) pushes item to the end of the array
then use shift to remove the first item
Stephane
@overmelo
Apr 24 2016 00:51 UTC
@llamatarianism can you explain why you put "-" at the beginning?
llamatarianism
@llamatarianism
Apr 24 2016 00:51 UTC
arr.shift()
@overmelo - makes it negative
if the argument supplied to substr is negative, then it counts backwards from the end of the string
if it was positive, we'd be slicing the BEGINNING off the string. we want the ENDING.
Mike Olie
@SwiftMike
Apr 24 2016 00:51 UTC
which var am i .push?
llamatarianism
@llamatarianism
Apr 24 2016 00:51 UTC
@FreshSteak use push on arr
push is a property of arrays
arr.push(item)
then use shift to remove the first item
arr.shift()
Stephane
@overmelo
Apr 24 2016 00:52 UTC
nice one
llamatarianism
@llamatarianism
Apr 24 2016 00:52 UTC
it also wants you to return the value that you remove
and since shift returns the value that it removes from the array, you can just write this: return arr.shift();
function nextInLine(arr, item) {
  arr.push(item);
  return arr.shift();
}
nextInLine([1,2,3,4,5], 6);
=> [1,2,3,4,5].push(6)
=> [1,2,3,4,5,6].shift()
=> 1
Himanshu Batra
@manshu
Apr 24 2016 00:54 UTC
function largestOfFour(arr) {
  var result = [];
  for (i = 0; i > arr.length; i++){
    result.push(Math.max.apply(Math, arr[i]));
  }
  return result;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Rachel
@noeladd
Apr 24 2016 00:54 UTC
@llamatarianism I'm working on the same one and I keep getting the message arr.shift is not a function. Any idea why?
llamatarianism
@llamatarianism
Apr 24 2016 00:54 UTC
@noeladd post your code?
@manshu you've written i > arr.length instead of i < arr.length
your loop breaks if i <= arr.length, and since 0 <= 4, then it breaks immediately.
Himanshu Batra
@manshu
Apr 24 2016 00:56 UTC
@llamatarianism Kill me now
llamatarianism
@llamatarianism
Apr 24 2016 00:56 UTC
also writing Math.max.apply(Math, arr[i]) looks weird to me. there's no real problem with it, it's just sorta odd
Himanshu Batra
@manshu
Apr 24 2016 00:56 UTC
I keep making these silly mistakes
llamatarianism
@llamatarianism
Apr 24 2016 00:56 UTC
I'd probably write Math.max.apply([], arr[i]) just for clarity's sake
Himanshu Batra
@manshu
Apr 24 2016 00:56 UTC
i seem to endup googling every answer. What’s the best way to mentally challenge myself
llamatarianism
@llamatarianism
Apr 24 2016 00:57 UTC
@manshu there's no shame in googling stuff! 90% of professional programming is googling
@manshu http://exercism.io/ has some nice challenges if you want to try and improve though
Himanshu Batra
@manshu
Apr 24 2016 00:57 UTC
let me c
Mike Olie
@SwiftMike
Apr 24 2016 00:58 UTC
dope i just completed it thanks @llamatarianism !!
CamperBot
@camperbot
Apr 24 2016 00:58 UTC
freshsteak sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Apr 24 2016 00:58 UTC
@manshu I'd recommend doing the challenges labelled ecmascript rather than javascript
CamperBot
@camperbot
Apr 24 2016 00:58 UTC
:star: 429 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
Himanshu Batra
@manshu
Apr 24 2016 00:58 UTC
okay perfect
llamatarianism
@llamatarianism
Apr 24 2016 00:58 UTC
ecmascript refers to ES2015, which is basically the latest version of javascript
Himanshu Batra
@manshu
Apr 24 2016 00:59 UTC
@llamatarianism yup got it.
llamatarianism
@llamatarianism
Apr 24 2016 00:59 UTC
javascript is ES5, which is outdated and missing a bunch of great features that make javascript way better, like let and const
Himanshu Batra
@manshu
Apr 24 2016 01:00 UTC
Is this some type of time bound quiz ?
heymark
@heymark
Apr 24 2016 01:00 UTC
not timed, just social
other folks review your code, and vice versa
Himanshu Batra
@manshu
Apr 24 2016 01:01 UTC
Perfect
llamatarianism
@llamatarianism
Apr 24 2016 01:01 UTC
@manshu it's useful for learning to write more efficient, concise, readable code.
having a bunch of people giving you tips is very helpful
Himanshu Batra
@manshu
Apr 24 2016 01:01 UTC
yes, i agree.
Kyle Morton
@kmorton1988
Apr 24 2016 01:04 UTC
anybody REALLY good at CSS?
I'm having trouble figuring something out.
Himanshu Batra
@manshu
Apr 24 2016 01:04 UTC
not really good, but can identify problem
Kyle Morton
@kmorton1988
Apr 24 2016 01:04 UTC
the game being played is way off, and I can't figure out why.
Himanshu Batra
@manshu
Apr 24 2016 01:08 UTC
.game {
  float: left;
  width: 50%;
here you go
Kyle Morton
@kmorton1988
Apr 24 2016 01:08 UTC
does that really do it?
heymark
@heymark
Apr 24 2016 01:08 UTC
@llamatarianism fwiw, my helper functions work sensibly now :) > http://codepen.io/anon/pen/QNBYmZ?editors=0012
Kyle Morton
@kmorton1988
Apr 24 2016 01:08 UTC
ahh, I should have clarified. I need it to be to the RIGHT of the div that it is in.
Himanshu Batra
@manshu
Apr 24 2016 01:12 UTC
you want everything to be on the right ?
or display just the game on right and level it
DJ
@qualitymanifest
Apr 24 2016 01:14 UTC
@kmorton1988 maybe give .link display:inline-block
Kyle Morton
@kmorton1988
Apr 24 2016 01:15 UTC
I want just the game to the right @manshu
and I'll try it, @qualitymanifest
krisluu5695
@krisluu5695
Apr 24 2016 01:16 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  var booleanVal = true;
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i][firstName] === firstName && contacts[i].prop === prop) {
      booleanVal = true;
    }
    if (contacts[i][firstName] !== firstName) {
      booleanVal = false;
    }
    if (contacts[i].prop !== prop) {
      booleanVal = false;
    }
  }
  if (booleanVal !== false) {
    return contacts[i][firstName] + contacts[i][prop];
  } else {
    return "No such contact or No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
need some help tyvm ^^
Kyle Morton
@kmorton1988
Apr 24 2016 01:16 UTC
no dice @qualitymanifest
DJ
@qualitymanifest
Apr 24 2016 01:16 UTC
@kmorton1988 you sure? works for me
Selection_152.png
oh i see
you gave it to .game. give it to .link
krisluu5695
@krisluu5695
Apr 24 2016 01:17 UTC
what did u guy doing ??? @kmorton1988 @qualitymanifest
Stephen Fox
@stevemasta34
Apr 24 2016 01:17 UTC
Anybody done "smallest common multiple", in the intermediate algorithms section?
A little stuck on something
Stephen James
@sjames1958gm
Apr 24 2016 01:18 UTC
@stevemasta34 yes, what do you have
Kyle Morton
@kmorton1988
Apr 24 2016 01:19 UTC
OH!
Stephen Fox
@stevemasta34
Apr 24 2016 01:19 UTC
I'm solving the problem recursively (Array.prototype.reduce()) and I keep producing a number too large for the large step
krisluu5695
@krisluu5695
Apr 24 2016 01:19 UTC
i got stuck at Profile Lookup ??? can someone help me ?
Kyle Morton
@kmorton1988
Apr 24 2016 01:19 UTC
@qualitymanifest Yes! you did it, thanks a ton!
CamperBot
@camperbot
Apr 24 2016 01:19 UTC
kmorton1988 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
Kyle Morton
@kmorton1988
Apr 24 2016 01:19 UTC
lol.
CamperBot
@camperbot
Apr 24 2016 01:19 UTC
:star: 1140 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Stephen James
@sjames1958gm
Apr 24 2016 01:20 UTC
@krisluu5695 What you are returning doesn't match the instructions. Since prop is a variable .prop is not correct syntax.
DJ
@qualitymanifest
Apr 24 2016 01:20 UTC
np :+1:
Stephen Fox
@stevemasta34
Apr 24 2016 01:20 UTC
"smallestCommons([1, 13]) should return 360360." but I'm returning 1081080
@sjames1958gm
Stephen James
@sjames1958gm
Apr 24 2016 01:20 UTC
@stevemasta34 Show your code -
@stevemasta34 Sounds like you are going too far
Stephen Fox
@stevemasta34
Apr 24 2016 01:21 UTC

```let range = (from, to) => {
let big, small;
if (to > from) {
big = to;
small = from;
} else {
big = from;
small = to;
}
console.log("Big =", big, "& small =", small);
let retRange = [];
for (let i = small; i <= big; i += 1) {
retRange.push(i);
}

return retRange;
};

let makeRange = (array) => {
return range(array[0], array[1]);
};

let trace = (val) => {
console.log("Trace:",val);
return val;
};

function smallestCommons(arr) {
let arrRange = makeRange(arr);
console.log("Built range:", arrRange);
return trace(arrRange.reduce((prev, current, ind, list) => {
if (prev % current === 0) return prev;
if (prev % 2 === 0 && current % 2 === 0) return prev * current / 2;

return prev * current; // worst case, multiply them together

}, 1));
}

smallestCommons([1,5]);
smallestCommons([1,13]);
```

That looks terrible...
Markdown has failed me
Stephen James
@sjames1958gm
Apr 24 2016 01:23 UTC
@stevemasta34 Press shift-return after the first ```
A H
@allenhsieh
Apr 24 2016 01:23 UTC
help chunky monkey
CamperBot
@camperbot
Apr 24 2016 01:23 UTC

:point_right: algorithm chunky monkey [wiki]

Explanation

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the Algorithm title and read the helpful links if you haven't yet.

:pencil: read more about algorithm chunky monkey on the FCC Wiki

Stephen Fox
@stevemasta34
Apr 24 2016 01:23 UTC
let range = (from, to) => {
  let big, small;
  if (to > from) {
    big = to;
    small = from;
  } else {
    big = from;
    small = to;
  }
  console.log("Big =", big, "& small =", small);
  let retRange = [];
  for (let i = small; i <= big; i += 1) {
    retRange.push(i);
  }

  return retRange;
};

let makeRange = (array) => {
  return range(array[0], array[1]);
};

let trace = (val) => {
  console.log("Trace:",val);
  return val;
};

function smallestCommons(arr) {
  let arrRange = makeRange(arr);
  console.log("Built range:", arrRange);
  return trace(arrRange.reduce((prev, current, ind, list) => {
    if (prev % current === 0) return prev;
    if (prev % 2 === 0 && current % 2 === 0) return prev * current / 2;

    return prev * current; // worst case, multiply them together
  }, 1));
}


smallestCommons([1,5]);
smallestCommons([1,13]);
@sjames1958gm Any thoughts
Stephen James
@sjames1958gm
Apr 24 2016 01:26 UTC
@stevemasta34 I think your code in the smallestCommon does consider enough values before you jump to prev*current
Stephen Fox
@stevemasta34
Apr 24 2016 01:26 UTC
"Doesn't" perhaps?
Stephen James
@sjames1958gm
Apr 24 2016 01:27 UTC
@stevemasta34 Duh - yes
Stephen Fox
@stevemasta34
Apr 24 2016 01:27 UTC
I think I agree with you, but there isn't much room to keep from being grossly specific
Stephen James
@sjames1958gm
Apr 24 2016 01:28 UTC
@stevemasta34 You mean a loop until you find % == 0
Stephen Fox
@stevemasta34
Apr 24 2016 01:29 UTC
@sjames1958gm I don't understand what you meant by that statement
Tyler
@tylergross
Apr 24 2016 01:29 UTC
var Person = function(firstAndLast) {
  var arr = firstAndLast.split(" ");
  var firstName = arr[0];
  var lastName = arr[1];

  Person.prototype.setFirstName = function(first){
    firstName = first;
  };
  Person.prototype.setLastName = function(last){
    lastName = last;
  };
  Person.prototype.setFullName = function(firstLast){
    firstName = firstLast.split(" ")[0];
    lastName = firstLast.split(" ")[1];
  };
  Person.prototype.getFirstName = function(){
    return firstName;
  };
  Person.prototype.getLastName = function(){
    return lastName;
  };
  Person.prototype.getFullName= function(){
    return firstName+" "+lastName;
  };

};



var bob = new Person('Bob Ross');
alert(Object.keys(bob).length);
returns okay on everything besides Object.keys(bob).length should return a value of 6 and i'm getting 0, ideas?
Stephen James
@sjames1958gm
Apr 24 2016 01:30 UTC
@stevemasta34 Test every value from prev to prev * current (increment by prev) to find the first where % current == 0
A H
@allenhsieh
Apr 24 2016 01:30 UTC

still working through Chunky Monkey but getting an error i've never seen before in the log

function chunkArrayInGroups(arr, size) {
  var n = [];
  for (var i = 0; i < arr.length; i++){
    n=arr.push(arr.slice(0,size));
  }
  return n;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

error: Potential infinite loop.
I don't see how my code will cause it to loop infinitely.

Stephen Fox
@stevemasta34
Apr 24 2016 01:30 UTC
@tylergross define your functions with "this.set" instead of overwriting the prototype like crazy
Tyler
@tylergross
Apr 24 2016 01:31 UTC
@stevemasta34 not sure why that worked, but it did. Thanks
CamperBot
@camperbot
Apr 24 2016 01:31 UTC
tylergross sends brownie points to @stevemasta34 :sparkles: :thumbsup: :sparkles:
krisluu5695
@krisluu5695
Apr 24 2016 01:31 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  var booleanVal = true;
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i][firstName] === firstName && contacts[i].prop === prop) {
      booleanVal = true;
    }
    if (contacts[i][firstName] !== firstName) {
      booleanVal = false;
    }
    if (contacts[i].prop !== prop) {
      booleanVal = false;
    }
  }
  if (booleanVal !== false) {
    return contacts[i][firstName] + contacts[i][prop];
  } else {
    return "No such contact or No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
can someone help me ty
CamperBot
@camperbot
Apr 24 2016 01:31 UTC
:star: 301 | @stevemasta34 | http://www.freecodecamp.com/stevemasta34
Stephen Fox
@stevemasta34
Apr 24 2016 01:32 UTC
@tylergross it's about where the function Object.keys() looks. No problem :) Glad I could help
krisluu5695
@krisluu5695
Apr 24 2016 01:32 UTC
@stevemasta34 steve can u help me ?
i got stuck
Tyler
@tylergross
Apr 24 2016 01:33 UTC
@stevemasta34 gotcha
Stephen Fox
@stevemasta34
Apr 24 2016 01:34 UTC
@krisluu5695 I can try. What's your problem?
krisluu5695
@krisluu5695
Apr 24 2016 01:34 UTC
Profile Lookup
A H
@allenhsieh
Apr 24 2016 01:35 UTC
@krisluu5695 It looks like you're missing the word else
Stephen James
@sjames1958gm
Apr 24 2016 01:35 UTC
@stevemasta34 I think in your reduce.
while (prev % curr !== 0) { prev += prev} return prev;
A H
@allenhsieh
Apr 24 2016 01:36 UTC
It should be if/else if/else
krisluu5695
@krisluu5695
Apr 24 2016 01:36 UTC
@allenhsieh let me try ...
Stephen Fox
@stevemasta34
Apr 24 2016 01:36 UTC
@sjames1958gm I'm giving that a shot now
Stephen James
@sjames1958gm
Apr 24 2016 01:37 UTC
@stevemasta34 Curr should be current for your code
krisluu5695
@krisluu5695
Apr 24 2016 01:37 UTC
@allenhsieh nth happen :smile:
Ekultek
@Ekultek
Apr 24 2016 01:37 UTC
Who's good with multi dimensional arrays?
krisluu5695
@krisluu5695
Apr 24 2016 01:38 UTC
i thought the problem at these [i][firstName] or [i].prop
Stephen Fox
@stevemasta34
Apr 24 2016 01:38 UTC
@sjames1958gm that seems to cause an infinite loop. I see what you're getting at now, though
Stephen James
@sjames1958gm
Apr 24 2016 01:39 UTC
@stevemasta34 Yeah, sorry - just saw that -
var test = prev;
while (test % curr !== 0) { test += prev} 
return test;
Stephen James
@sjames1958gm
Apr 24 2016 01:44 UTC
@stevemasta34 Scan multiples of prev until you hit a multiple of curr, stops at most at curr * prev
Kevin
@KevinBruland
Apr 24 2016 01:51 UTC
I have a couple of very basic jquery questions
I have a click event which creates divs, and I want to have an event happen when those created divs are clicked... but it doesnt seem to be working?
Stephen Fox
@stevemasta34
Apr 24 2016 01:53 UTC
@sjames1958gm that did it. Thanks :)
CamperBot
@camperbot
Apr 24 2016 01:53 UTC
stevemasta34 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 771 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Kevin
@KevinBruland
Apr 24 2016 01:53 UTC
is there something I have to do different to make the jquery work for an object that did not begin at the start of the page load?
Kevin Mulligan
@kmulligan
Apr 24 2016 01:53 UTC
I am blanking out on Map the Debris... how do I replace avgAlt with orbitalPeriod:?
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var averageAlt = arr[0].avgAlt;
  var x = ((Math.pow((earthRadius + averageAlt),3))/GM);
  var orbital = Math.round(((2*Math.PI) * (Math.sqrt(x))));



  return orbital;

  //T = 2*pi -/sqrt(a^3/u) 
  // u = GM
  //a = orbit's semi-major axis in meters... so earthRadius + avgAlt?
  //Math.sqrt(x)
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
Rory Avant
@roryavant8
Apr 24 2016 01:55 UTC
Hi everyone, I am working on the Twitch Stream app and I am having a complication. I am trying to access divs that are dynamically created when the page loads. My code trying to access the said divs is from lines 84-86, which simply is a statement to alert to the screen. When I hard code a few divs into the HTML it works fine. How do I work around this issue?
http://codepen.io/roryavant8/pen/ZWxPyv?editors=1010
Nvm I figured it out using $(window).load
Dhyey Thakore
@dhyey35
Apr 24 2016 01:59 UTC
@Benalron can u paste the code which creates a new div and assigns ann event to it?
@dhyey35 currently, I have it so when you click the test button it creates 100 divs... for testing purpose I was trying to set it up so when you click one of those, it created 100 more in the same way
@dhyey35 but when I click them, nothing happens... I am guessing its because it is dynamically created content?
Tyler
@tylergross
Apr 24 2016 02:00 UTC
@kmulligan make a new array with an object
Kevin Mulligan
@kmulligan
Apr 24 2016 02:04 UTC
@tylergross and just pull the old object's .name out?
Kevin
@KevinBruland
Apr 24 2016 02:06 UTC
@dhyey35 I think I actually figured it out...
A H
@allenhsieh
Apr 24 2016 02:10 UTC
help slasher flick
CamperBot
@camperbot
Apr 24 2016 02:10 UTC

:point_right: algorithm slasher flick [wiki]

Problem Explanation:

Return the remaining elements of an array after chopping off n elements from the head.

For example: slasher([1, 2, 3], 2); must return [3]

:pencil: read more about algorithm slasher flick on the FCC Wiki

Dhyey Thakore
@dhyey35
Apr 24 2016 02:11 UTC
@Benalron right now ur code only appends one div when one of those 100 clicked
Kevin Mulligan
@kmulligan
Apr 24 2016 02:11 UTC
@tylergross is this what you had in mind?
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var averageAlt = arr[0].avgAlt;
  var x = ((Math.pow((earthRadius + averageAlt),3))/GM);
  var orbital = Math.round(((2*Math.PI) * (Math.sqrt(x))));
  var myObject = {};
  myObject.name = arr[0].name;
  myObject.orbitalPeriod = orbital;
  var myArray = [];
  myArray.push(myObject);


  return myArray;

  //T = 2*pi -/sqrt(a^3/u) 
  // u = GM
  //a = orbit's semi-major axis in meters... so earthRadius + avgAlt?
  //Math.sqrt(x)
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
Kevin
@KevinBruland
Apr 24 2016 02:11 UTC
@dhyey35 yeah, I just switched it to a (this).toggleClass... so it running so it toggles that one specifically
Stephen Fox
@stevemasta34
Apr 24 2016 02:15 UTC
Just started "Binary Agents" and I've just got say...
What the hell man
help binary agents
CamperBot
@camperbot
Apr 24 2016 02:16 UTC

:point_right: algorithm binary agents [wiki]

Explanation:

This problem is very straight forward, you will get a string that will represent a sentence in binary code, and you need to translate that into words. There is not direct way to do this so you will have to translate twice.

:pencil: read more about algorithm binary agents on the FCC Wiki

Anandu B Ajith
@anandubajith
Apr 24 2016 02:17 UTC
help missing letters
CamperBot
@camperbot
Apr 24 2016 02:17 UTC

:point_right: algorithm missing letters [wiki]

Problem Explanation:

  • You will create a program that will find the missing letter from a string and add it. If there is not missing letter it will return undefined. There is currently no test case for it missing more than one letter, but if anything recursion can be implemented or a second or more calls to the same function as needed. Also the letters are always provided in order so there is no need to sort them.
:pencil: read more about algorithm missing letters on the FCC Wiki
Dhyey Thakore
@dhyey35
Apr 24 2016 02:17 UTC
@Benalron have u solved it?
Kevin
@KevinBruland
Apr 24 2016 02:17 UTC
yeah
Ekultek
@Ekultek
Apr 24 2016 02:18 UTC
I'm so confused..
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.
Kevin
@KevinBruland
Apr 24 2016 02:18 UTC
its not very exciting... but its my first use of jquery... so I am excited lol
Erik Maurer
@MauPow
Apr 24 2016 02:18 UTC
Hi guys, I'm developing the weather checker project, and I'm having troubles with the API... I have my appid set and it was working fine yesterday, but now it's returning a 401 error. I've reset my app ID and waited a few hours, but it still isn't working. Has anyone dealt with this before with the Open weather API/
Ekultek
@Ekultek
Apr 24 2016 02:19 UTC

Okay so something like this:
function nextInLine(arr, item){
array = [arr, item];
array.push(item);
array.unshift(arr);
return arr;
}

???

Or would I make an empty array?
Frank XC
@tenkdayz
Apr 24 2016 02:22 UTC
@Ekultek I think you have to shift() .
TanYiXun
@TanYiXun
Apr 24 2016 02:23 UTC
var arr = [10,9,8,7,6];
for (var i=0; i < arr.length; i++) {
   console.log(arr[i]);
}
why is this "Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1. Our condition for this loop is i < arr.length, which stops when i is at length - 1." like that?
Ekultek
@Ekultek
Apr 24 2016 02:24 UTC
Shift doesn't work either
A H
@allenhsieh
Apr 24 2016 02:26 UTC
@TanYiXun because the loop will run up to but not include the last number
Stephen James
@sjames1958gm
Apr 24 2016 02:26 UTC
@Ekultek Return the value from the shift
TanYiXun
@TanYiXun
Apr 24 2016 02:27 UTC
@allenhsieh ? i dont know wht the last index of the array is length -1
A H
@allenhsieh
Apr 24 2016 02:28 UTC

@TanYiXun so for

for (var i=0; i  <  3; i++)

the loop will start at 0, run at i=1, run again at i=2, but NOT run i = 3

@TanYiXun using arr.length, on a given array

var arr = [10,9,8,7,6];

The length of the array is 5

@TanYiXun if you use arr.length, you are saying i < 5 so it will stop at i= 4
TanYiXun
@TanYiXun
Apr 24 2016 02:31 UTC
@allenhsieh oh i seee... THanks!!
CamperBot
@camperbot
Apr 24 2016 02:31 UTC
tanyixun sends brownie points to @allenhsieh :sparkles: :thumbsup: :sparkles:
:star: 272 | @allenhsieh | http://www.freecodecamp.com/allenhsieh
A H
@allenhsieh
Apr 24 2016 02:31 UTC
You're welcome! Free Code Camp is my third attempt at learning to program, and that concept took me forever to understand
krisluu5695
@krisluu5695
Apr 24 2016 02:32 UTC
```

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (firstName === contacts[i][firstName] && prop === contacts[i][prop]) {
console.log(contacts[i][firstName] + contacts[i][prop]);
} else {
if (firstName !== contacts[i][firstName]) {
console.log("No such contact");
} else {
console.log("No such property");
}
}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristan", "lastName");

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i][firstName] && prop === contacts[i][prop]) {
      console.log(contacts[i][firstName] + contacts[i][prop]);
    } else {
      if (firstName !== contacts[i][firstName]) {
        console.log("No such contact");
      } else {
        console.log("No such property");
      }
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristan", "lastName");
TanYiXun
@TanYiXun
Apr 24 2016 02:32 UTC
@allenhsieh me too... but i had the help of friendly people like you :)
krisluu5695
@krisluu5695
Apr 24 2016 02:33 UTC
help :worried:
CamperBot
@camperbot
Apr 24 2016 02:33 UTC
no wiki entry for: worried
krisluu5695
@krisluu5695
Apr 24 2016 02:35 UTC
still can't out this area ......
can someone help me .... ?
Coby-T
@Coby-T
Apr 24 2016 02:35 UTC
You need to put properties in quotes
so to call firstName
it should be contacts[2]["firstName"]
Anandu B Ajith
@anandubajith
Apr 24 2016 02:36 UTC
can anyone tell me why this adds null to the array?
function uniteUnique(arr1, arr2, arr3) {
  var arr = arr1.concat(arr2, arr3),
      uniqueArr = [];
  for ( var i = 0; i < arr.length; i++) {
    if ( uniqueArr.indexOf(arr[i]) < 0) {
      uniqueArr.push(arr[i]);

    }
  }
  return uniqueArr;
}

uniteUnique([1, 2, 3], [5, 2, 1]);
krisluu5695
@krisluu5695
Apr 24 2016 02:36 UTC
let me try ...
Coby-T
@Coby-T
Apr 24 2016 02:37 UTC
@anandubajith What output are you getting?
krisluu5695
@krisluu5695
Apr 24 2016 02:38 UTC
@Coby-T ```
Anandu B Ajith
@anandubajith
Apr 24 2016 02:38 UTC
@Coby-T [1,2,3,5,null]
krisluu5695
@krisluu5695
Apr 24 2016 02:38 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i]["firstName"] && prop === contacts[i]["prop"]) {
      console.log(contacts[i]["firstName"] + contacts[i]["prop"]);
    } else {
      if (firstName !== contacts[i]["firstName"]) {
        console.log("No such contact");
      } else {
        console.log("No such property");
      }
    }
  }
// Only change code above this line
}
your mean ?
Coby-T
@Coby-T
Apr 24 2016 02:38 UTC
@krisluu5695 prop should not have quotes
prop is a variable
Or else it is going to look for the "prop" property of the object which doesn't exist
A H
@allenhsieh
Apr 24 2016 02:42 UTC
help mutations
CamperBot
@camperbot
Apr 24 2016 02:42 UTC

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
krisluu5695
@krisluu5695
Apr 24 2016 02:46 UTC
help Profile Lookup
CamperBot
@camperbot
Apr 24 2016 02:46 UTC

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Laura
@lauradb
Apr 24 2016 02:53 UTC
@fmfarinacci
fmfarinacci
@fmfarinacci
Apr 24 2016 02:53 UTC
aha I found you!!
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:08 UTC
Having problems with Counting Cards. Maybe I'm not understanding the concept. Not passing a single test (laughable) with this:

var count = 0;

function cc(card) {
// Only change code below this line
if (card === 2) {
console.log([count + 1] + [" Bet"]);
} else if (card === 3) {
console.log([count + 1] + [" Bet"]);
} else if (card === 4) {
console.log([count + 1] + [" Bet"]);
} else if (card === 5) {
console.log([count + 1] + [" Bet"]);
} else if (card === 6) {
console.log([count + 1] + [" Bet"]);
} else if (card === 7) {
console.log([count + 0] + [" Hold"]);
} else if (card === 8) {
console.log([count + 0] + [" Hold"]);
} else if (card === 9) {
console.log([count + 0] + [" Hold"]);
} else if (card === 10) {
console.log([count - 1] + [" Hold"]);
} else if (card === 'J') {
console.log([count - 1] + [" Hold"]);
} else if (card === 'Q') {
console.log([count - 1] + [" Hold"]);
} else if (card === 'K') {
console.log([count - 1] + [" Hold"]);
} else {
console.log([count - 1] + [" Hold"]);
}

// Only change code above this line
}

Norvin Burrus
@ndburrus
Apr 24 2016 03:09 UTC
@icartusacrimea HI, Traci....
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:09 UTC
Hi.
fmfarinacci
@fmfarinacci
Apr 24 2016 03:10 UTC
Hi Traci
Norvin Burrus
@ndburrus
Apr 24 2016 03:10 UTC
@icartusacrimea I used a switch statement, along with an if, else statement for the counting cards challenge
krisluu5695
@krisluu5695
Apr 24 2016 03:11 UTC
thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
Apr 24 2016 03:11 UTC
krisluu5695 sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 489 | @leftynaut | http://www.freecodecamp.com/leftynaut
Norvin Burrus
@ndburrus
Apr 24 2016 03:11 UTC
@icartusacrimea I don't see u using an if statement to produce the results...
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:11 UTC
Hmm... For the switch statement, what would be the expression?
Norvin Burrus
@ndburrus
Apr 24 2016 03:12 UTC
js
<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 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
    case 7:  
      break;
    case 8:  
      break;
    case 9:  
      break;


  }
  if (count > 0) {
        myStr = "Bet";
  } else {
        myStr = "Hold";
  }

  return count + " " + myStr;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc("J"); cc(9);cc(2); cc(7);>
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:13 UTC
Very nice solution. Wish I'd thought of it.
Thank you very much @ndburrus
CamperBot
@camperbot
Apr 24 2016 03:14 UTC
:star: 240 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 24 2016 03:14 UTC
@icartusacrimea I see ur evaluating the card count, u just need to bring it all together...
CamperBot
@camperbot
Apr 24 2016 03:14 UTC
icartusacrimea sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
Apr 24 2016 03:14 UTC
@icartusacrimea does it make sense to u?
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:15 UTC
Yeah. I'm at the point where the correct code often feels "on the tip of my fingers."
Norvin Burrus
@ndburrus
Apr 24 2016 03:16 UTC
@icartusacrimea I know what u mean... Also, someone mentioned to me when I was working on that one that the code can be cleaned up for the letter cards by using an else category...
@icartusacrimea ...if ur going the if/else route...
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:17 UTC
Ah.
Kyle Morton
@kmorton1988
Apr 24 2016 03:20 UTC
can anyone help me figure out why the part where I'm trying to addClass("notstreaming") isn't working? (line 44-50)
http://codepen.io/kmisterk/pen/VaMOdL
Norvin Burrus
@ndburrus
Apr 24 2016 03:30 UTC
...any challenge questions up to (& including) Accessing Nested Arrays in JSON?
Kyle Morton
@kmorton1988
Apr 24 2016 03:32 UTC
huh?
TanYiXun
@TanYiXun
Apr 24 2016 03:39 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
  if(firstName===contacts[i].firstName){return contacts[i].firstName;}
  else if(prop===contacts[i]){return contacts[i][prop];}
  else if(firstName!==contacts[i].firstName){return 'No such contact';}
  else {return "No such property";}
    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

Can Someone help me ?
A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

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

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

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

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

Coby-T
@Coby-T
Apr 24 2016 03:44 UTC
@TanYiXun You are comparing first name every time. A function will read the first return in the function. Yours will be be in the first loop when the first names don't match
snrydr
@snrydr
Apr 24 2016 03:45 UTC
hi , I'm having trouble with the test result of "Falsy Bouncer", I wonder what I did wrong below:
Falsy values in JavaScript are false, null, 0, "", undefined, and NaN.

function bouncer(arr) {
var newArr = [];
for(var i=0; i<arr.length; i++){
if(!isFalsy(arr[i])){
newArr.push(arr[i]);
}
}
return newArr;
}

function isFalsy(val){
var result = false;
switch(val){
case false:
case null:
case 0:
case "":
case undefined:
case NaN:
result = true; break;
default:
result = false; break;
}
return result;
}

Coby-T
@Coby-T
Apr 24 2016 03:46 UTC
Run through your loop again, your first call will be be contacts0.firstName or "Akira", which will give you the no such contact
snrydr
@snrydr
Apr 24 2016 03:47 UTC

one of my test case works:
bouncer([7, "ate", "", false, 9]) returns [7, "ate", 9]

but for my other case
bouncer([false, null, 0, NaN, undefined, ""]) returns [null] instead of the expected value of []

Dylan
@dhcodes
Apr 24 2016 03:50 UTC
@snrydr did you test for !== null?
TanYiXun
@TanYiXun
Apr 24 2016 03:52 UTC
@Coby-T how do i change it?
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afor(var%20i%3D0%3Bi%3Ccontacts.length%3Bi%2B%2B)%7B%0A%20%20if(firstName%3D%3D%3Dcontacts%5Bi%5D.firstName)%7Breturn%20contacts%5Bi%5D.firstName%3B%7D%0A%20%20else%20if(prop%3D%3D%3Dcontacts%5Bi%5D)%7Breturn%20contacts%5Bi%5D%5Bprop%5D%3B%7D%0A%20%20else%20if(firstName!%3D%3Dcontacts%5Bi%5D.firstName)%7Breturn%20'No%20such%20contact'%3B%7D%0A%20%20else%20%7Breturn%20%22No%20such%20property%22%3B%7D%0A%20%20%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Kristian%22%2C%20%22lastName%22)%3B%0A
snrydr
@snrydr
Apr 24 2016 03:58 UTC
@dhcodes thanks , I think it worked for the case, using !== null check instead of === null (I just have to flip the cases)
CamperBot
@camperbot
Apr 24 2016 03:58 UTC
snrydr sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 682 | @dhcodes | http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Apr 24 2016 04:03 UTC
@snrydr after looking at some solutions later I found the secret to falsy bouncer and it's a lot easier than you'd think. Check out the solutions on the FCC wiki on github
after you solve it of course
Artur Sęp
@a-sep
Apr 24 2016 04:07 UTC
Hi, do You know a better (shorter) solution of this challenge : "Where art thou". I havn't use Object.keys(), although it was in a description.
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

    function comper(e) {
        var test;
        for (var p in source) {
            // console.log(p);
            if (!e.hasOwnProperty(p) || e[p] !== source[p]) {
                test = false;
            } else if (e.hasOwnProperty(p) || e[p] === source[p]) {
                test = true;
            }
        }
        if (test) {
            // console.log("test OK");
            return true;
        }
    }

    arr = collection.filter(comper);
    // console.log(arr);

  // Only change code above this line
  return arr;
}
whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Frank XC
@tenkdayz
Apr 24 2016 04:09 UTC
can anyone try to break my memory game.. or just play it to test if everything works . thanks!! http://cygnusix.com/memgame/memgame.html
Joseph
@revisualize
Apr 24 2016 04:11 UTC
@tenkdayz It looks pretty good to me.
Coby-T
@Coby-T
Apr 24 2016 04:12 UTC
@TanYiXun Ah sorry, I had to take care of something
Just play through your loop; I really don't like telling people exactly what to do, but I will say you should check the inside of the loop, and think about when you want to return "no contact" or "no property"
heymark
@heymark
Apr 24 2016 04:13 UTC
@tenkdayz seems to work fine, might want to adjust incentives though
Coby-T
@Coby-T
Apr 24 2016 04:15 UTC
@a-sep You can get it a little shorter with keys.
Artur Sęp
@a-sep
Apr 24 2016 04:16 UTC
@dhcodes I didn't know that there are solutions on FCC wiki github :)
Coby-T
@Coby-T
Apr 24 2016 04:16 UTC
I'm trying to remember what I did. It was a filter with keys, but I don't remember the specifics
Artur Sęp
@a-sep
Apr 24 2016 04:17 UTC
This message was deleted
revisualize @revisualize is ignoring this answer.
Joseph
@revisualize
Apr 24 2016 04:18 UTC
I haven't completed that lesson yet.
Artur Sęp
@a-sep
Apr 24 2016 04:19 UTC
after I have found a solution :smile: of course
Coby-T
@Coby-T
Apr 24 2016 04:19 UTC
Always solve it first then learn about better ways to do it
My first solution to that was ugly as hell
acgillette
@acgillette
Apr 24 2016 04:21 UTC
Hi guys! I'm doing the palindrome algorithm challenge. I am very close, I pass almost all tests except for the almostomla one and I was wondering if someone can take a peek at my code and let me know where my logic is flawed
Ali Hammad
@alihammad-gist
Apr 24 2016 04:22 UTC
@acgillette share your code please
acgillette
@acgillette
Apr 24 2016 04:23 UTC
function palindrome(str) {
  str = str.replace(/\W/g, '').toLowerCase().split("");
  for (var i = 0; i < str.length; i++) {
    for (var j = str.length-1; j > 0; j--) {
      if (str[i] != str[j]) {
        return false;
      }
      return true;
    }
  }


}



palindrome("thIS is a TesT");
Joseph
@revisualize
Apr 24 2016 04:23 UTC
@acgillette You're not removing _s
Artur Sęp
@a-sep
Apr 24 2016 04:23 UTC
@Coby-T I've spendt last 3 mornings ( x 3h) on that, and I have almost give up
Joseph
@revisualize
Apr 24 2016 04:24 UTC
@acgillette With \W it still keeps in the _ character.
Coby-T
@Coby-T
Apr 24 2016 04:25 UTC
@acgillette That double loop isn't checking correctly
Joseph
@revisualize
Apr 24 2016 04:26 UTC
@acgillette
The \W metacharacter is used to find a non-word character.
A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.
acgillette
@acgillette
Apr 24 2016 04:27 UTC
@Coby-T yeah I figured the problem would be in the loop. But I couldn't think of another way to structure the logic
Coby-T
@Coby-T
Apr 24 2016 04:27 UTC
the loop is calling like:
i j
0 8
0 7
0 6
...
Joseph
@revisualize
Apr 24 2016 04:27 UTC
@acgillette If you solve it.. I will show you my code.
acgillette
@acgillette
Apr 24 2016 04:27 UTC
ohhh that makes sense. I see the flaw now
it's always something obvious I miss haha
Coby-T
@Coby-T
Apr 24 2016 04:28 UTC
It's always the loops
Especially loops with embedded ifs
Joseph
@revisualize
Apr 24 2016 04:29 UTC
@acgillette Why are you using a for loop?
acgillette
@acgillette
Apr 24 2016 04:29 UTC
I couldn't figure out another way of comparing elements of an array @revisualize
Coby-T
@Coby-T
Apr 24 2016 04:30 UTC
There are two ways of doing it
I did it by halving the string
and reversing it
Joseph
@revisualize
Apr 24 2016 04:30 UTC
@acgillette Why are you using an array?
Coby-T
@Coby-T
Apr 24 2016 04:30 UTC
The other way is to loop the array and compare each char
Joseph
@revisualize
Apr 24 2016 04:31 UTC
@acgillette I'll let you finish. And I'll show you my code.
Ali Hammad
@alihammad-gist
Apr 24 2016 04:31 UTC
@acgillette you don't need to convert string to array. if you remove the .split('') the code should still work. This should be your main check (at least it was in my solution) str[i] === str[str.length-i] so for 'abba' you are check a === a then b == b after this point the loop should terminate .
string are already array of characters. you can loop over each character like you would a normal array
Joseph
@revisualize
Apr 24 2016 04:33 UTC
Strings are not arrays.
Coby-T
@Coby-T
Apr 24 2016 04:33 UTC
It's better not to use the string[n] call
it doesn't work for some of the older browsers
and strings can be called like arrays
Joseph
@revisualize
Apr 24 2016 04:33 UTC
@Coby-T Check your PM.
Sure, you can call a character index.
Ali Hammad
@alihammad-gist
Apr 24 2016 04:34 UTC
@revisualize why are they accessible like a numeric array?
Joseph
@revisualize
Apr 24 2016 04:36 UTC
@alihammad-gist Strings have indexes.
Arrays also have indexes.
@alihammad-gist Hence the reason that you're also able to use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
Ali Hammad
@alihammad-gist
Apr 24 2016 04:40 UTC
right. I just realized strings and arrays don't share some functions like map. thanks for clarification.
Lavie Ruan
@Lavioli
Apr 24 2016 04:44 UTC
find Mutations
CamperBot
@camperbot
Apr 24 2016 04:44 UTC

find mutations

:zero: algorithm mutations
:one: permutations

Joseph
@revisualize
Apr 24 2016 04:48 UTC
function map (arr, func) {
    var result = [];
    for (var i = 0; i > arr.length(); i++) {
        restult.push(func(arr[i]));
    }
    return result;
}
heymark
@heymark
Apr 24 2016 04:50 UTC
Is the last test in the Palindrome challenge even correct?
First of all, the challenge says to disregard punctuation, and the test is palindrome("0_0 (: /-\ :) 0-0") should return true. Second, mirroring a forward slash to a backslash (etc) is way out of scope. Third, even if it weren't, the 0_0 is not a mirror of 0-0, so it shouldn't return true anyway. Am I missing something?
Ali Hammad
@alihammad-gist
Apr 24 2016 04:53 UTC
@heymark you ought to remove any characters other then alphabets and digits
00 will be equal to 00 for that case
heymark
@heymark
Apr 24 2016 04:56 UTC
Oh, gotcha.
Joseph
@revisualize
Apr 24 2016 04:59 UTC
@heymark The challenge is correct.
heymark
@heymark
Apr 24 2016 05:01 UTC
Yeah, sorry. They must've added that last test since I completed it, because my solution didn't look at numbers.
Joseph
@revisualize
Apr 24 2016 05:01 UTC
Wait what?
What is your regex?
acgillette
@acgillette
Apr 24 2016 05:04 UTC
hi it's me again lol. I decided to try halving and reversing half of the string, but I'm not sure how to do it correctly with strings with odd numbers of characters in it
TanYiXun
@TanYiXun
Apr 24 2016 05:06 UTC
can anyone help me? https://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afor(var%20i%3D0%3Bi%3Ccontacts.length%3Bi%2B%2B)%7B%7B%0A%20%20if(contacts%5Bi%5D.firstName.hasOwnProperty(firstName))%7Breturn%20contacts%5Bi%5D.firstName%3B%7D%0A%20%20else%20%7Breturn%20'No%20such%20contact'%3B%7D%7D%0A%20%7B%20if(contacts%5Bi%5D.hasOWnProperty(prop))%7Breturn%20contacts%5Bi%5D%5Bprop%5D%3B%7D%0A%20%20else%20%7Breturn%20%22No%20such%20property%22%3B%7D%0A%20%7D%20%20%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Harry%22%2C%20%22likes%22)%3B%0A
Joseph
@revisualize
Apr 24 2016 05:06 UTC
@acgillette Okay. can I see your code?
heymark
@heymark
Apr 24 2016 05:06 UTC
@revisualize actually, no. My solution didn't handle the underscore, because \w captures underscores, so it picked up 000_0.
Fixed it now with [^\W_]
acgillette
@acgillette
Apr 24 2016 05:07 UTC

```
function palindrome(str) {
str = str.replace(/[^A-Za-z]/g, "").toLowerCase();
str1 = str.slice(0, str.length/2);
str2 = str.slice(str.length/2, str.length).split("").reverse().join('');

return str1;
}
``` ignore the return I was using it to test

Joseph
@revisualize
Apr 24 2016 05:08 UTC
@acgillette Okay.. Let's look at this.
@acgillette You're on the right track.. Kind of.
David Parsons
@davidjparsons
Apr 24 2016 05:08 UTC
stuck on Accessing Objects Properties with Variables
my answer so far is var playerNumber = testObj[16]; // Change this Line
var player = testObj.Montana; // Change
Joseph
@revisualize
Apr 24 2016 05:08 UTC
@acgillette Before you had \W in your regex.. Which I think is better. Or you could do..
[^A-Za-z0-9]
or [\W_]
@acgillette So, yes. First you should do the regex for the replacement and then turn them to lowercase.
@acgillette But, what if you then just used part of your code.
@acgillette and just did the comparison on .split("").reverse().join('');
@acgillette using the str variable that you create after the replacement.
You clearly understand str.split("").reverse().join('');
@acgillette Am I making sense?
acgillette
@acgillette
Apr 24 2016 05:12 UTC

so like

function palindrome(str) {
  str = str.replace(/[^A-Za-z]/g, "").toLowerCase();
  str2 = str.split("").reverse().join('');

  return str1;
  }

and then just compare the two strings? That seems a lot easier

Joseph
@revisualize
Apr 24 2016 05:12 UTC
how about
return str === str2
But, you want to keep the numbers.
TanYiXun
@TanYiXun
Apr 24 2016 05:13 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){{
  if(contacts[i].firstName.hasOwnProperty(firstName)){return contacts[i].firstName;}
  else {return 'No such contact';}}
 { if(contacts[i].hasOwnProperty(prop)){return contacts[i][prop];}
  else {return "No such property";}
 }    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
can anyone help me understand how to solve this?
Joseph
@revisualize
Apr 24 2016 05:13 UTC
@acgillette Right? Because you're doing a comparison and a comparison only returns .. true or false (most of the time)
@TanYiXun Use pythontutor and you'll see your issue.
@TanYiXun You'll realize why your loop isn't actually looping.
acgillette
@acgillette
Apr 24 2016 05:16 UTC
it almost works except for the "0_0 (: /-\ :) 0-0" but I think that has to do with the replace function I'm using
Joseph
@revisualize
Apr 24 2016 05:16 UTC
It is.
@acgillette What is your regex?
acgillette
@acgillette
Apr 24 2016 05:17 UTC
oh its because it;s not removing the underscore
just tested it
Joseph
@revisualize
Apr 24 2016 05:17 UTC
The \W metacharacter is used to find a non-word character.
A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.
acgillette
@acgillette
Apr 24 2016 05:17 UTC
i went back to the str.replace(/\W/g, "")
Joseph
@revisualize
Apr 24 2016 05:17 UTC
[\W_]
regex is a pain.
http://regexone.com/ is really good for learning regex.
BUT! You have to slow down and do it.
You can easily rush through it.
@acgillette Fixed?
acgillette
@acgillette
Apr 24 2016 05:19 UTC
Yep! got it! Thanks for putting up with my baby brain haha
Joseph
@revisualize
Apr 24 2016 05:20 UTC
Can I see your code?
acgillette
@acgillette
Apr 24 2016 05:20 UTC
thanks for the resource, I'll read up on it. stackoverflow was useful but I was having a hard time understand it
Joseph
@revisualize
Apr 24 2016 05:20 UTC
@acgillette Here's my solution:
function palindrome(str) {
  str = str.toLowerCase().replace(/[\W_]/g, "");
  return str === str.split("").reverse().join("");
}
acgillette
@acgillette
Apr 24 2016 05:20 UTC
```
whoops
function palindrome(str) {
  str = str.replace(/[^0-9a-z]/gi, '').toLowerCase();
  str2 = str.split("").reverse().join('');


  return str == str2;

  }
Joseph
@revisualize
Apr 24 2016 05:22 UTC
Anyhow.. Time for me to get to bed.
acgillette
@acgillette
Apr 24 2016 05:22 UTC
thanks for the help @revisualize :)
CamperBot
@camperbot
Apr 24 2016 05:22 UTC
acgillette sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 960 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 24 2016 05:22 UTC
WOOO! Thanks for the brownie!
nom nom nom nom
Frank XC
@tenkdayz
Apr 24 2016 05:28 UTC
it is possible to detect if a page is being inspected or rightclicked
Rada
@Radascript
Apr 24 2016 05:29 UTC
does codePen not recognize .on()?
kirbyedy
@kirbyedy
Apr 24 2016 05:30 UTC
@Radascript it should
David Parsons
@davidjparsons
Apr 24 2016 05:31 UTC
why does it say " // Only change code above this line"
when we actually have to change it to solve the problem
/ end rant
rphares
@rphares
Apr 24 2016 05:32 UTC
Which Challenge, @davidjparsons ?
David Parsons
@davidjparsons
Apr 24 2016 05:33 UTC
Using Objects for Lookups @rphares
rphares
@rphares
Apr 24 2016 05:33 UTC
you shouldn't have to change anything below the line on that one,
most likely, you didn't store the lookup part in result before you returned result...?
instead of changing return result you could reset result = right before that line...
Rada
@Radascript
Apr 24 2016 05:34 UTC
@kirbyedy yeah nvm, codePen just doesn't read my mind as well as I'd like it to
David Parsons
@davidjparsons
Apr 24 2016 05:34 UTC
ah gotcha
rphares
@rphares
Apr 24 2016 05:34 UTC
:blush:
David Parsons
@davidjparsons
Apr 24 2016 05:34 UTC
thanks
rphares
@rphares
Apr 24 2016 05:34 UTC
anytime~
Deepak Yadav
@ydeepk
Apr 24 2016 05:42 UTC

challange : slasher flick

Where I'm GOing wrong?

function slasher(arr, howMany) {
// it doesn't always pay to be first
var temp = [];

if(howMany > 0 && howMany <= arr.length) {

for(var a = 0; a < arr.length; a++) {

  temp = arr.splice(a,howMany,arr.slice(a,howMany));


}

return temp;

} else if(howMany === 0) {

return arr;

} else {

return temp;

}

}

slasher(["burgers", "fries", "shake"], 1);

for this instruction -> slasher(["burgers", "fries", "shake"], 1) should return ["fries", "shake"].

Deepak Yadav
@ydeepk
Apr 24 2016 05:47 UTC
no body ???
come on folks.. :worried:
:worried:
kirbyedy
@kirbyedy
Apr 24 2016 05:48 UTC
with splice
splice your array with howmany
and use array.length
Deepak Yadav
@ydeepk
Apr 24 2016 05:50 UTC
@kirbyedy where to use array length?
kirbyedy
@kirbyedy
Apr 24 2016 05:50 UTC
in the splice method
array.splice(start, deleteCount[, item1[, item2[, ...]]])
d wilder
@alhazen1
Apr 24 2016 05:50 UTC
@ydeepk Hi. Read the MDN on slice carefully. You can do this in one line
Coby-T
@Coby-T
Apr 24 2016 06:03 UTC
@ydeepk Think it through, you can actually do it with just slice.
TanYiXun
@TanYiXun
Apr 24 2016 06:08 UTC
@revisualize thank you!!
CamperBot
@camperbot
Apr 24 2016 06:08 UTC
tanyixun sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 961 | @revisualize | http://www.freecodecamp.com/revisualize
Kevin
@KevinBruland
Apr 24 2016 06:14 UTC
is there a way to store an elements CSS value as a variable?
Frank XC
@tenkdayz
Apr 24 2016 06:20 UTC
@Benalron var sty = document.getElementById("id").style.opacity;
Kevin
@KevinBruland
Apr 24 2016 06:23 UTC
@tenkdayz thanks
CamperBot
@camperbot
Apr 24 2016 06:23 UTC
benalron sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 440 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Luis
@zdrifted
Apr 24 2016 06:40 UTC
I'm confused on how to start for the Falsy Bouncer algorithm. At first, I thought maybe a for loop would work but it looks like they want me to use arr.filter() and boolean(). Should the end of my code call the function like so?
function bouncer(arr) {


  }

arr.filter( bouncer(arr) );
Eldar Tinjić
@EldarT90
Apr 24 2016 06:48 UTC
https://codepen.io/EldarT/pen/YqjJBx need help with JS calculator
my function is trying to remember the input
but it just remember number of inputs and convert every input to the first one
Kevin
@KevinBruland
Apr 24 2016 06:51 UTC
anyone have a second to help me with a jquery problem
Frank XC
@tenkdayz
Apr 24 2016 06:52 UTC
@EldarT90 I dont understand the problem you described.
@Benalron go
Eldar Tinjić
@EldarT90
Apr 24 2016 06:53 UTC
@tenkdayz try to do 53 + 25 and click equal sign
for exmaple
@tenkdayz line 14 in the JS.... I am expecting that to turn a color to white in the event that one of the boxes already has the same color as the selected color
Frank XC
@tenkdayz
Apr 24 2016 06:54 UTC
@EldarT90 ooh just use Number() it thinks they're strings .. well they are stirng..
@Benalron is this the game of life project?
Kevin
@KevinBruland
Apr 24 2016 06:55 UTC
@tenkdayz no
Eldar Tinjić
@EldarT90
Apr 24 2016 06:56 UTC
@tenkdayz yes, but problem is not that they are not displaying in corect format, problem is im not getting input i put there
Frank XC
@tenkdayz
Apr 24 2016 06:56 UTC
@Benalron can you rephrase that?
Brendon
@Balvamar
Apr 24 2016 06:57 UTC
anyone point me in the right direction here please
Eldar Tinjić
@EldarT90
Apr 24 2016 06:57 UTC
@tenkdayz i go12+34 and i get input 1212 after equal sign
Brendon
@Balvamar
Apr 24 2016 06:57 UTC

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
for(var j=0;j<contacts[i].length;j++){
if(firstName!==contacts.firstName){
return "No such contact";

}else if(prop!==contacts[i][j]){
return "No such property";

}else{
return contacts.prop;
}
}
}
// Only change code above this line
}

Kevin
@KevinBruland
Apr 24 2016 06:58 UTC
@tenkdayz You select a color above the grid. When you click on a square, it changes the color of the square to the selected color. I am trying to make it so if you have a color selected, such as black, if you click on a black square it will become white.
@Benalron on lines 14-18 in the JS... I created an if else statement that is supposed to achieve this, by changing the color to white if the selected color is == to the background color of the square being clicked.
Frank XC
@tenkdayz
Apr 24 2016 07:00 UTC
@Benalron I know how to do that in pure js not so sure in jquery...
@Balvamar if(firstName!==contacts[i].firstName){
Brendon
@Balvamar
Apr 24 2016 07:05 UTC
@tenkdayz nope, just can't get this to work
Michal Sadowski
@micsad
Apr 24 2016 07:32 UTC
Is it normal to feel uneasy about what you actually learned from the JS challenges even though you solved them correctly? Just curious what level of comfort others had going through the course ;)
the doer
@ewathedoer
Apr 24 2016 07:43 UTC
@micsad it's normal, especially after some algorithmic tasks
Zoher Ali
@Zoher-ali
Apr 24 2016 07:46 UTC
can any1 help me with spinal tap case challenge
i m not getting the logic for capital letters
here is my code
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  str = str.replace(/[\s_]/g,"-");
    str = str.toLowerCase();
  return str;
}
spinalCase("AllThe_small Things");
Michal Sadowski
@micsad
Apr 24 2016 08:03 UTC
Struggling with Nesting for Loops (235). How far am I from the solution?
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (i=0; i < arr.length; i++) {
    for (b=0; b < arr[i].length; b++) 
 product *= arr[i].length;

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Michal Sadowski
@micsad
Apr 24 2016 08:34 UTC
Still no luck

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (var i=0; i < arr.length; i++) {
    for (var b=0; b < arr[i].length; b++) 
 product *= arr[i][b];

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Vivek
@vivek28111992
Apr 24 2016 08:42 UTC
does anybody know how to get paid font for free, I want cielo font
AbdHan
@abdhan
Apr 24 2016 08:42 UTC
@micsad Hi what are you supposed to output?
Michal Sadowski
@micsad
Apr 24 2016 08:44 UTC
multiplication of product and all the numbers in the sub arrays
AbdHan
@abdhan
Apr 24 2016 08:46 UTC
So the o/p should be an array of products or just one number which is the product of all numbers?
Michal Sadowski
@micsad
Apr 24 2016 08:46 UTC
one number
AbdHan
@abdhan
Apr 24 2016 08:46 UTC
okay try using curly brackets to seperate your loops
Michal Sadowski
@micsad
Apr 24 2016 08:46 UTC
will do
V Arun Kumar
@arunvkumr
Apr 24 2016 08:47 UTC
@micsad remove return statement and write it after the i loop
or remove the braces of the i loop, that would also work.
Yinka Adesesan
@yadesesan
Apr 24 2016 08:49 UTC
Hi guys
I need help with the Roman Numerals Converter?
Michal Sadowski
@micsad
Apr 24 2016 08:49 UTC
braces was the problem kudos @arunkumrv @abdhan thanks
CamperBot
@camperbot
Apr 24 2016 08:49 UTC
micsad sends brownie points to @arunkumrv and @abdhan :sparkles: :thumbsup: :sparkles:
:star: 512 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
:star: 301 | @abdhan | http://www.freecodecamp.com/abdhan
Yinka Adesesan
@yadesesan
Apr 24 2016 08:49 UTC
Can someone help?
Brendan Kinahan
@BKinahan
Apr 24 2016 08:50 UTC
@yadesesan what problem are you having?
Yinka Adesesan
@yadesesan
Apr 24 2016 08:51 UTC
@yadesesan I can't seem to be able to assign the values to the letters and I can't set the rules to make up the final numeral @Bkinahan
@BKinahan I'm basically clueless but all I need is a prode in the right direction
Brendan Kinahan
@BKinahan
Apr 24 2016 08:54 UTC
@yadesesan many people use two arrays; one containing the letters for the various roman numerals as strings, ie [I,IV,V,IX...] and the other containing the corresponding number values [1,4,5,9...] note that many numbers can be skipped because they can be generated by combinations of others, as in 3 -> III
Yinka Adesesan
@yadesesan
Apr 24 2016 08:55 UTC
@BKinahan Okay... That makes sense. And then use if / else to set the rules for arrangement yes?
Brendan Kinahan
@BKinahan
Apr 24 2016 08:56 UTC
@yadesesan you can use if, or for, or while.. I've seen it done multiple ways :)
Yinka Adesesan
@yadesesan
Apr 24 2016 08:57 UTC
@BKinahan Ok. Thank you. I'd try that. But if I am still having problems, wdo you think pair programming would help?
CamperBot
@camperbot
Apr 24 2016 08:57 UTC
yadesesan sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1377 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Apr 24 2016 09:00 UTC
@yadesesan I don't see why not :D
Two heads are better than one.
Yinka Adesesan
@yadesesan
Apr 24 2016 09:01 UTC
@BKinahan Can I reach out to you for that?
Brendan Kinahan
@BKinahan
Apr 24 2016 09:02 UTC
I think the idea of pair programming is to find someone on around the same level of experience as you who hasn't done the challenge yet either, so you can figure it out together. There's a chatroom just for it here so you can find more info: https://gitter.im/FreeCodeCamp/LetsPair
karim khalfaoui
@Kaiiim
Apr 24 2016 09:04 UTC
hi all , someone can help me with '' Falsy Bouncer '' ? i dont know why i have to do

' function bouncer(arr) {
// Don't show a false ID to this bouncer.

var noString = ""; Boolean(noString);
var noZeroNumber = 0; Boolean(noZeroNumber);
var noZroSecond = -0; Boolean(noZroSecond);
var noNull = null;Boolean(noNull);
var noNaN = 10 / "H"; Boolean(noNaN);
var noUndefined ; Boolean(noUndefined);
var noFalse = false ;Boolean(noFalse);

if ( arr !== noString,noZeroNumber,noZroSecond,noNull,noNaN,noUndefined,noFalse)  
{
  return true;
}

var finalArr = arr.filter(arr);

}

bouncer([7, "ate", "", false, 9]);
'

Yinka Adesesan
@yadesesan
Apr 24 2016 09:11 UTC
@BKinahan Ok. I have a better understanding of Pair Programming now
lindsy
@lindsymoran
Apr 24 2016 09:13 UTC
thanks @Rafase282 for your help with Checkpoint: Word Blanks
CamperBot
@camperbot
Apr 24 2016 09:13 UTC
lindsymoran sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star: 1178 | @rafase282 | http://www.freecodecamp.com/rafase282
V Arun Kumar
@arunvkumr
Apr 24 2016 09:23 UTC

@Kaiiim
This is what you have to do... take the array that is passed to the function bouncer and check each array for falsy value if it is a false value, remove the element and if it is not keep the value in the array.
Problems with your code..

var noString = ""; Boolean(noString);

you are creating a variable noString and assign empty string to it and then passing noString to Boolean constructor which returns false, which is not stored anywhere in your code. and you are hardcoding all the falsy and truty values.. don't do that.

if ( arr !== noString,noZeroNumber,noZroSecond,noNull,noNaN,noUndefined,noFalse)

arr is an array.. and noString is an empty string you cannot compare them like that and as you are using comma operator only the last vale i.e. noFalse is compared with arr.
Try using a for loop to loop through the array or some built-in function which take one value of an array and does some operations(like map, filter, etc.). Here some links for reference. Read about Boolean Objects.
Boolean, Filter Function, Map function

Alex
@alexstelmakh
Apr 24 2016 09:33 UTC
I am get stuck. Can anybody help me with this https://www.freecodecamp.com/challenges/record-collection
This is my code :
function updateRecords(id, prop, value) {
  if (prop == "tracks" && value !== ""){
    collection[id].prop.push(value);
    } else if (value !==""){
     collection[id].prop = value;
       } else if (value === ""){
         delete collection[id].prop;
       } 
  return collection;
}
karim khalfaoui
@Kaiiim
Apr 24 2016 09:33 UTC
@arunkumrv thank you ! i have find the solution lol, my english is not very good so sometime i dont understand really what i need to do :)
CamperBot
@camperbot
Apr 24 2016 09:33 UTC
kaiiim sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 514 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 24 2016 09:34 UTC
You're welcome. :smile: ~Happy coding.
@alexstelmakh prop doesn't exist in the object so dot operator will not work. try using bracket notation. and you need one more conditoin in your first else-if.

If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop

This should be in your first else-if statement.

Bane Tepavcevic
@banet
Apr 24 2016 09:41 UTC
Hi guys, need help here...What I doing wrong here...Lesson Word Blanks JS
Alex
@alexstelmakh
Apr 24 2016 09:41 UTC
@arunkumrv First time I wrote code as you say, but it doesn't work. And I tried to change . to [ ] and nothing.
V Arun Kumar
@arunvkumr
Apr 24 2016 09:44 UTC
@alexstelmakh post you code with changes
Bane Tepavcevic
@banet
Apr 24 2016 09:45 UTC
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line


  result += "The " + myAdjective + myNoun + myVerb + myAdverb;

  // Your code above this line
  return result;
}

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

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to provide additional strings, which will not change, in between the provided words.

negyvenketto
@negyvenketto
Apr 24 2016 09:46 UTC
@banet you need at least spaces between the words
V Arun Kumar
@arunvkumr
Apr 24 2016 09:46 UTC
@banet add spaces between the words like. word1 + " " + word2
Alex
@alexstelmakh
Apr 24 2016 09:47 UTC
@arunkumrv
function updateRecords(id, prop, value) {
  if (value !=="") {
     collection[id][prop] = value; 
    } else if (prop == "tracks" && value !== "") {
      collection[id][prop].push(value);
    } else if (value === ""){
         delete collection[id][prop];
    } 
  return collection;
}
V Arun Kumar
@arunvkumr
Apr 24 2016 09:48 UTC
dont add spaces in the original word and use = instead of +=.
incredible-aj
@incredible-aj
Apr 24 2016 09:48 UTC
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
V Arun Kumar
@arunvkumr
Apr 24 2016 09:48 UTC
@banet :point_up_2:
incredible-aj
@incredible-aj
Apr 24 2016 09:48 UTC
var myStr = \ \t \t \r \n ;
Bane Tepavcevic
@banet
Apr 24 2016 09:48 UTC
@arunkumrv sorry I am testing that what you said..
V Arun Kumar
@arunvkumr
Apr 24 2016 09:49 UTC
@incredible-aj backslach is \\ your entire string should be \\ \t \t \r \n
Bane Tepavcevic
@banet
Apr 24 2016 09:50 UTC
@arunkumrv I tried like you said: result += myAdjective + "" + myNoun +""+ myVerb +""+ myAdverb;
negyvenketto
@negyvenketto
Apr 24 2016 09:50 UTC
@banet you are not adding spaces
incredible-aj
@incredible-aj
Apr 24 2016 09:50 UTC
Thnks @arunkumrv
CamperBot
@camperbot
Apr 24 2016 09:50 UTC
incredible-aj sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 515 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
negyvenketto
@negyvenketto
Apr 24 2016 09:50 UTC
@banet put spaces in the quotes
V Arun Kumar
@arunvkumr
Apr 24 2016 09:50 UTC
@banet you are missing spaces in the quotes.
Bane Tepavcevic
@banet
Apr 24 2016 09:51 UTC
@negyvenketto Thank you man and cheers!
CamperBot
@camperbot
Apr 24 2016 09:51 UTC
banet sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 384 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
negyvenketto
@negyvenketto
Apr 24 2016 09:51 UTC
@banet :thumbsup:
V Arun Kumar
@arunvkumr
Apr 24 2016 09:52 UTC

@alexstelmakh there should be 2 conditins in if and 2 in first else if and 1 in last else if.
First if..

If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.

Then Else-if

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

Last else-if

If value is blank, delete that prop.

Bane Tepavcevic
@banet
Apr 24 2016 09:53 UTC
@arunkumrv Thank you!
CamperBot
@camperbot
Apr 24 2016 09:53 UTC
banet sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 516 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 24 2016 09:53 UTC
You're welcome :smile:
Pabba Shiva Ram Kaushil
@PabbaShivaRamKaushil
Apr 24 2016 09:57 UTC
Storing Values with the Assignment Operator
can anyone help me with this code
javascript
V Arun Kumar
@arunvkumr
Apr 24 2016 09:58 UTC
@PabbaShivaRamKaushil Post your code.. someone will definitely help you out..
negyvenketto
@negyvenketto
Apr 24 2016 10:00 UTC
@PabbaShivaRamKaushil code would be fine, except that you wrote it above the line that says "Only change code below this line"
copy your code, reset the challenge, paste your code :) @PabbaShivaRamKaushil
Pabba Shiva Ram Kaushil
@PabbaShivaRamKaushil
Apr 24 2016 10:01 UTC
:p it worked @negyvenketto
negyvenketto
@negyvenketto
Apr 24 2016 10:02 UTC
fcc is strict that way :D
Abdul-Samii Ajala Olalekan
@jalasem
Apr 24 2016 10:08 UTC
this works but i dont understand how
function XO(str) {
    //code here
    if((str.match(/x/gi) || []).length === (str.match(/o/gi) || []).length || str.match(/x/gi) == str.match(/o/gi)){
      return true
    } else {
      return false;
    }
}
//(temp.match(/is/g) ).length
Alex
@alexstelmakh
Apr 24 2016 10:36 UTC
Somebody help me, I am still struggling with this https://www.freecodecamp.com/challenges/record-collection
This is my code :
function updateRecords(id, prop, value) {
  if (value !=="" && prop !== "tracks") {
     collection[id][prop] = value; 
    } else if (prop == "tracks" && value !== "") {
      collection[id][prop].push(value);
    } else if (value === ""){
         delete collection[id][prop];
    } 
  return collection;
}
Emanuele Santoro
@esantoro
Apr 24 2016 10:38 UTC
hi, I am having some troubles with the "Escape sequences in strings" challenge
I've coded var myStr = "\b \t \t \r \n" ;
UtkarshShukla7
@UtkarshShukla7
Apr 24 2016 10:39 UTC
@esantoro var myStr= "\ \t \t \r \n";
Emanuele Santoro
@esantoro
Apr 24 2016 10:39 UTC
and the sequence should be "backslash tab tab carriage-return new-line"
@UtkarshShukla7 why the missing b ?
UtkarshShukla7
@UtkarshShukla7
Apr 24 2016 10:40 UTC
@esantoro \\
to escape \
Emanuele Santoro
@esantoro
Apr 24 2016 10:40 UTC
OH
it's backslash, not backspace
silly me
UtkarshShukla7
@UtkarshShukla7
Apr 24 2016 10:40 UTC
yes
Emanuele Santoro
@esantoro
Apr 24 2016 10:40 UTC
sorry guys :smile:
this was a dumb question
thank you @UtkarshShukla7
CamperBot
@camperbot
Apr 24 2016 10:41 UTC
esantoro sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:star: 364 | @utkarshshukla7 | http://www.freecodecamp.com/utkarshshukla7
Eldar Tinjić
@EldarT90
Apr 24 2016 10:41 UTC
https://codepen.io/EldarT/pen/YqjJBx - i want #calc to be shown, regardless if it contains element or not
UtkarshShukla7
@UtkarshShukla7
Apr 24 2016 10:42 UTC
@esantoro np
Emanuele Santoro
@esantoro
Apr 24 2016 10:43 UTC
@EldarT90 : #calc {
background-color: green;
border-radius: 12px;
min-height: 25px;
}
set min-height :)
Eldar Tinjić
@EldarT90
Apr 24 2016 10:44 UTC
@esantoro yeah tnx for that ... jeez i was into JS for last 15 days or so and i forgot some basic syntaxes from css and bs as well :(
CamperBot
@camperbot
Apr 24 2016 10:44 UTC
eldart90 sends brownie points to @esantoro :sparkles: :thumbsup: :sparkles:
:star: 165 | @esantoro | http://www.freecodecamp.com/esantoro
Emanuele Santoro
@esantoro
Apr 24 2016 10:44 UTC
np @EldarT90 :)
Hector Castro
@heccas
Apr 24 2016 11:04 UTC
Hello guys
got a simple question about Caesars Cipher challenge
classact1
@classact1
Apr 24 2016 11:05 UTC
hey guys. I cant for the life of me figure out why my sum all primes algorithm doesnt work as it should. Its correct when you pass it a 10 but completely wrong when passed 977
function sumPrimes(num) {
  var arr=[];
  var sum=0;
  var divisible=0;
  //looping through all the numbers up to provided number
  for(var i=2 ; i<=num ; i++){
    arr=[1,2,3,i];
    divisible=0;
    //if a number is 2 or 3 just add it to sum and skip iteration
    if(i == 2 || i == 3){
      sum+=i;  
      continue;
    }
    //checking whether number is divisible by given number from arr, and if it is just increment divisible
    for(var j=0 ; j<arr.length ; j++){
      if(i%arr[j] === 0)  
        divisible++;
    }
    //add number to the sum if it was divisible by 2 numbers in arr
    if(divisible==2)
      sum+=i;
  }
  return sum;
}

sumPrimes(977);
Hector Castro
@heccas
Apr 24 2016 11:05 UTC
I need to 'shift' the value of letter 13 places
but the unicodes chars doesn't follow a linear arrangement
I need to code it on a case basis (letter by letter0?
Ivan Georgiev
@ivangeorgiew
Apr 24 2016 11:14 UTC
Guys is it only me or do the Intermidiate Algorithm Challanges seem easier than the Begginer ones?
Eldar Tinjić
@EldarT90
Apr 24 2016 11:14 UTC
why is my memory button not working
scottmike0
@scottmike0
Apr 24 2016 11:15 UTC
@ivangeorgiew you are just getting better at learning. practice and time is key to do well in coding
Eldar Tinjić
@EldarT90
Apr 24 2016 11:16 UTC
and i mean MR button
which should paste memorized value
Ivan Georgiev
@ivangeorgiew
Apr 24 2016 11:19 UTC
@scottmike0 function booWho(bool) { if(bool !== true && bool !== false) return false; else return true; } booWho(null);
@scottmike0 for Boo Who challange. Are you kidding me :D
Artur Sęp
@a-sep
Apr 24 2016 11:23 UTC
wiki Caesars Cipher
CamperBot
@camperbot
Apr 24 2016 11:23 UTC

:point_right: algorithm caesars cipher [wiki]

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :memo:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Stephen James
@sjames1958gm
Apr 24 2016 11:35 UTC
@EldarT90 It looks like you memory button isn't storing anything - Uncaught TypeError: mem.html is not a function I couldn't find where you define mem
$("#mem").html
Eldar Tinjić
@EldarT90
Apr 24 2016 11:36 UTC
p with id mem
in html
ok now it works
i forgot to assign jquery
@sjames1958gm tnx mate
CamperBot
@camperbot
Apr 24 2016 11:37 UTC
eldart90 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 772 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Eldar Tinjić
@EldarT90
Apr 24 2016 11:38 UTC
now on to whati think will be big challenge to fix
i want using operator NOT to erase current html when i click operator but when i click next number
and this will be very tricky , because i cant do it for any "case" since then it will remove every digit i input instead of last one
except the last one*
Stephen James
@sjames1958gm
Apr 24 2016 11:41 UTC
@EldarT90 Do you have devtools console open while working on codepen? That will show any obvious javascript errors like the one I found.
glorious1688
@glorious1688
Apr 24 2016 11:42 UTC
who's on falsy bouncer
Eldar Tinjić
@EldarT90
Apr 24 2016 11:42 UTC
@sjames1958gm unfortunately very often i forget to use it, but im trying to get used to it, ofc it will take some time to fully embrace its concept
Stephen James
@sjames1958gm
Apr 24 2016 11:43 UTC
@EldarT90 There is a lot there, but having it open and seeing red in the console can save time in many situations.
Eldar Tinjić
@EldarT90
Apr 24 2016 11:43 UTC
@sjames1958gm i agree
Stephen James
@sjames1958gm
Apr 24 2016 11:44 UTC
I think it is not covered in the challenges because of the differences between browsers.
Eldar Tinjić
@EldarT90
Apr 24 2016 11:44 UTC
@sjames1958gm what approach would you recommend me in order to achieve what i asked min ago ? i would like not to change code alot, but rather add onto it, if tats the possible
Stephen James
@sjames1958gm
Apr 24 2016 11:45 UTC
@EldarT90 I think you need to have a variable in your javascript that the last key was an operator. Then you can adjust your behavior on a number press based on that
Eldar Tinjić
@EldarT90
Apr 24 2016 11:47 UTC
@sjames1958gm to add if statement to all numeral cases to check whether last click was operator orn ot ?
would that mean i will have to add additional variable that will track every last input
regardless of its type
that sounds like big load on my script
faraz
@silentarrowz
Apr 24 2016 11:49 UTC
working on my wikipedia viewer and I get a response back, but I am not sure how to get the titles and page information from the response I am receiving -- could you take a look ??
here's the link -- http://codepen.io/silentarrowz/pen/yOEGjE
Stephen James
@sjames1958gm
Apr 24 2016 11:49 UTC
@heccas This maybe only for ascii (latin) use str.charCodeAt(i) to get the numeriv value
@EldarT90 You could give different buttons different classes based on function and then only do at top of click handler. Right now you are using button type
Eldar Tinjić
@EldarT90
Apr 24 2016 11:51 UTC
@sjames1958gm good idea
@sjames1958gm tnx for that, let me see if i can do something with it
CamperBot
@camperbot
Apr 24 2016 11:51 UTC
eldart90 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave sjames1958gm points
Stephen James
@sjames1958gm
Apr 24 2016 11:53 UTC
@classact1 you are only checking a few numbers to see if they divide into i, you need to check all the numbers less than the sqrt(i).
llamatarianism
@llamatarianism
Apr 24 2016 11:55 UTC
@silentarrowz you should be able to use JSON.parse to turn xhttp.requestText into a javascript object
then you can access its properties like any other object
so you can display the info more nicely
faraz
@silentarrowz
Apr 24 2016 11:56 UTC
@llamatarianism when I am using JSON.parse, i see an error saying VM2385:1 Uncaught SyntaxError: Unexpected token /
llamatarianism
@llamatarianism
Apr 24 2016 11:57 UTC
@silentarrowz oh yeah, it appears to have a comment in it. annoying.
faraz
@silentarrowz
Apr 24 2016 11:58 UTC
@llamatarianism , so. any ideas??
llamatarianism
@llamatarianism
Apr 24 2016 11:58 UTC
@silentarrowz uhh...a bit of a hacky solution
but you could use String.prototype.slice to slice the comment and () off the start and end
then parse it
yep, seems to work :thumbsup:
faraz
@silentarrowz
Apr 24 2016 12:00 UTC
@llamatarianism ok, let me check String.prototype.slice
but I am not sure if all responses will have this kind of comment at the start, what then??
llamatarianism
@llamatarianism
Apr 24 2016 12:02 UTC
shrug
@silentarrowz just had a bit of a look
looks like all JSON requests from that site have a comment at the start and () around the object
so you're good
Eldar Tinjić
@EldarT90
Apr 24 2016 12:04 UTC
@sjames1958gm i did some changes, but it looks like i did more harm than good https://codepen.io/EldarT/pen/YqjJBx
my equal sign isnt working now
Stephen James
@sjames1958gm
Apr 24 2016 12:05 UTC
@silentarrowz It is because you told it to use jsonp without a callback name. If you change callback=func then the data will be /**/func(json) so this isn't raw json, but a jsonp callback. Since you are using a cors proxy remove callback=? and you won't have this issue.
faraz
@silentarrowz
Apr 24 2016 12:06 UTC
@llamatarianism ah, that's okay then. so, I just remove all these using prototype.slice right and it will all be good
llamatarianism
@llamatarianism
Apr 24 2016 12:06 UTC
@silentarrowz yeah like
JSON.parse(xhttp.request.slice(5, -1)) should work
faraz
@silentarrowz
Apr 24 2016 12:06 UTC
@sjames1958gm ah, let me try that
llamatarianism
@llamatarianism
Apr 24 2016 12:06 UTC
oooh @sjames1958gm nice catch
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:07 UTC
I know this sounds stupid, but even after reading the documentation on w3schools, i still don't get Storing Values with the Assignment Operator.
This is my code:

// Setup
var a;
var b = 2;

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

I know I'm being obtuse...can someone help me with my logic?
faraz
@silentarrowz
Apr 24 2016 12:08 UTC
@sjames1958gm yeah, i removed teh callback and now those slashes at the beginning are gone?? but I dont understand the reason why it happened
Eldar Tinjić
@EldarT90
Apr 24 2016 12:09 UTC
i didnt even touch equal sign
Stephen James
@sjames1958gm
Apr 24 2016 12:09 UTC
@silentarrowz callback=? is telling the far end you want to use jsonp so it forms the response as a function call. If you use jquery jquery changes =? to =functionname and the code comes back as a function call that can be evaluated.
Eldar Tinjić
@EldarT90
Apr 24 2016 12:09 UTC
i dont get it
faraz
@silentarrowz
Apr 24 2016 12:10 UTC
@sjames1958gm this is going a little above my head. could you tell me where to read about these things you are saying?? maybe a link to a tutorial or something??
Stephen James
@sjames1958gm
Apr 24 2016 12:10 UTC
@silentarrowz google jsonp - wikipedia has some about it. jquery site has info as well
faraz
@silentarrowz
Apr 24 2016 12:11 UTC
ok, let me do that then. thanks @sjames1958gm @llamatarianism
CamperBot
@camperbot
Apr 24 2016 12:11 UTC
silentarrowz sends brownie points to @sjames1958gm and @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 773 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 430 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
Stephen James
@sjames1958gm
Apr 24 2016 12:15 UTC
@EldarT90 Did you lose your first value. I entry 5 + 3 = and it is trying to eval("+3") like 5 was being stored somewhere and now isn't
greg
@wearenotgroot
Apr 24 2016 12:15 UTC
@lauralstephenson you were supposed to set b equal a
Eldar Tinjić
@EldarT90
Apr 24 2016 12:15 UTC
@sjames1958gm if statement with count is somehow screwing it , now im trying to make it work only for class=num not all buttnos
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:16 UTC
how do I do that?
Stephen James
@sjames1958gm
Apr 24 2016 12:16 UTC
@EldarT90 Make sure you have a way to clear that
greg
@wearenotgroot
Apr 24 2016 12:16 UTC
@lauralstephenson this are unnecessary
var a = myVar;
var b = myNum;
myVar = myNum;
@lauralstephenson use the equal operator =
@lauralstephenson you already declared the variables with var
@
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:17 UTC
so var a = var b;
greg
@wearenotgroot
Apr 24 2016 12:17 UTC
@lauralstephenson so no need to declare them again
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:17 UTC
I tried var a = var b; and it won't let me do that.
Eldar Tinjić
@EldarT90
Apr 24 2016 12:18 UTC
@sjames1958gm ok now this is working, so thast is 1 problem less on my list
greg
@wearenotgroot
Apr 24 2016 12:18 UTC
@lauralstephenson var is for declaring variable
@lauralstephenson just write b equals a

@lauralstephenson

var a = 7; //<-------whenever you see var that means variable declaration
var b = 7;

now to use that variable just type the variable name without var

example
var c = 10; // declared variable c with initial value 10
var d = 1; //declared variable d with initial value 1

d = c; // d will be equal 10(setting d equal c)
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:22 UTC
got it, sjames1958gm ! Thanks so much!
Stephen James
@sjames1958gm
Apr 24 2016 12:23 UTC
@lauralstephenson It was @wearenotgroot
@EldarT90 problems-- ?
greg
@wearenotgroot
Apr 24 2016 12:23 UTC
@sjames1958gm :smile: it's fine as long as they learn :+1:
iigmir
@iigmir
Apr 24 2016 12:23 UTC

Hi there, have a problem:

function foo(foostr)
{
    for (var i=0; foostr.length; i++)
    {
        var poi = typeof( foostr[i] );
        if ( poi == "object" )
        {
            return false;
        }
    }
    return true;
}
var bar = [1,3,84,3,5,3513,35,4,38,5,1,2,62,2,2,6677,58,9999];
var foobar = foo(bar);
console.log( foobar );

I expect foobar will be ture or false. However, it crush because infinity loop. Where do I wrong?

Laura Stephenson
@lauralstephenson
Apr 24 2016 12:24 UTC
Thanks, wearnotgroot!
greg
@wearenotgroot
Apr 24 2016 12:24 UTC
@lauralstephenson np
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:24 UTC
@wearenotgroot Thanks!! How do I give brownie points?
CamperBot
@camperbot
Apr 24 2016 12:24 UTC
lauralstephenson sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 1047 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:24 UTC
Did it, yay!
greg
@wearenotgroot
Apr 24 2016 12:25 UTC
@iigmir check the second arg for the for loop. did you want something like
i < foostr.length
Eldar Tinjić
@EldarT90
Apr 24 2016 12:25 UTC
@sjames1958gm im adding new class for every element except equal sign, and changing additional counter to 0 unless its equal button, than its 1, and this will influence whether the input will clear the html, so i think i am on good track, but still writing code, tnx for asking ^^
CamperBot
@camperbot
Apr 24 2016 12:25 UTC
eldart90 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave sjames1958gm points
iigmir
@iigmir
Apr 24 2016 12:26 UTC
@wearenotgroot Ah thanks, I missed!
greg
@wearenotgroot
Apr 24 2016 12:26 UTC
@iigmir np
Eldar Tinjić
@EldarT90
Apr 24 2016 12:34 UTC
@sjames1958gm but its not working https://codepen.io/EldarT/pen/YqjJBx
Stephen James
@sjames1958gm
Apr 24 2016 12:36 UTC
Seems a lot is working - except when you press = it doesn't process the next number correctly
Eldar Tinjić
@EldarT90
Apr 24 2016 12:37 UTC
@sjames1958gm yes, that is what for i added variable "newone"
add if statements, if newone is 1, it should clear html
but it doesnt
which means could be syntax error
craaakk
@craaakk
Apr 24 2016 12:37 UTC
guys, help please
i cant pass task 'Check for Palindromes'.
This is my code:
\\\\\\\\
function palindrome(str) {
str = str.toLowerCase().replace(/\s/g, '').replace(/./g, '').replace(/\,/g, '');
var newstr = str.split('').reverse().join('');
if (newstr === str) {
return true;
} else {return false;}
}
\\\\\\\\
1) its work for everyone inputs except for this:
palindrome("0_0 (: /-\ :) 0-0");
2) i think that i can use 1 .replace function in my code instead of 3.
glorious1688
@glorious1688
Apr 24 2016 12:38 UTC
is there a java function to remove the first element of an array
.shift() doesn't seem to work
Stephen James
@sjames1958gm
Apr 24 2016 12:38 UTC
@EldarT90 You don't have to assign your click handler to a variable var newie = $("#equal").click( - just $("#equal").click(, also if you are not counting use true/false rather than == 1 / if === 1 etc.
greg
@wearenotgroot
Apr 24 2016 12:38 UTC
@craaakk try another regex->https://regex101.com/
Stephen James
@sjames1958gm
Apr 24 2016 12:38 UTC
@glorious1688 Shift does exactly that.
Eldar Tinjić
@EldarT90
Apr 24 2016 12:39 UTC
@sjames1958gm it would make it look nicer, but would it make it work ?
Stephen James
@sjames1958gm
Apr 24 2016 12:39 UTC
@EldarT90 just look nicer, maybe easier to reason about.
cmf89
@cmf89
Apr 24 2016 12:39 UTC
@craaakk in regexp, a dot matches ANY character, so you are replacing every character /./g with ''. If you want to replace only periods, then use /./g
Eldar Tinjić
@EldarT90
Apr 24 2016 12:39 UTC
@sjames1958gm ok i did that
greg
@wearenotgroot
Apr 24 2016 12:40 UTC
@craaakk maybe filter out non-word characters(non-alphanummeric, special charactes ... etc)
Eldar Tinjić
@EldarT90
Apr 24 2016 12:40 UTC
@sjames1958gm could it be that when i click , it already changes it to false
and than it will never be true
cmf89
@cmf89
Apr 24 2016 12:40 UTC
@craaakk sorry i mean . not ., you have to backslash-escape the .
@craaakk \. ugh gitter formatting is removing the backslash lol
Eldar Tinjić
@EldarT90
Apr 24 2016 12:40 UTC
YES @sjames1958gm thats it, i dont need new class
i only need to put it to true after its false
Stephen James
@sjames1958gm
Apr 24 2016 12:41 UTC
@cmf89 Use `` to block gitter inline
craaakk
@craaakk
Apr 24 2016 12:46 UTC
@cmf89 lol sorry i paste the wrong code. i know that i need to use backslash with dot in this case, but even so doesnt work.
@wearenotgroot ok i'll try it, thank you
CamperBot
@camperbot
Apr 24 2016 12:47 UTC
craaakk sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 1048 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Rohit Kumar Jena
@rohitrango
Apr 24 2016 12:58 UTC
any suggestions for roman numeral challenge
its kind of lengthy
Stephen James
@sjames1958gm
Apr 24 2016 12:59 UTC
@craaakk FYI, there are Regexp that can specify what you want, but there are some that match the negative of that. for example \s matches whitespace \S matches not whitespace. So if you want to match all non-alphanumeric characters check for a regexp selector for that.
@rohitrango I kind of brute forced my way through that one with a test for each letter starting from M
Rohit Kumar Jena
@rohitrango
Apr 24 2016 13:01 UTC
im doing the same
is there a better way ? @sjames1958gm
Stephen James
@sjames1958gm
Apr 24 2016 13:02 UTC
@rohitrango Possibly. But there isn't really a strong pattern, esp. with things like IX IV CM etc
Rohit Kumar Jena
@rohitrango
Apr 24 2016 13:02 UTC
thats the flaw with roman numerals @sjames1958gm
to reduce the amount of typing, im making a js object and will take values from it
Timothy Davis
@timothycdavis
Apr 24 2016 13:06 UTC
Can anyone help me with the return largest numbers in an array lesson?
I don't even know what to do
Stephen James
@sjames1958gm
Apr 24 2016 13:07 UTC
@timothycdavis It that the one with arrays in arrays?
Marc Schöni
@marcschoeni
Apr 24 2016 13:07 UTC
i got stuck on Accessing Nested Objects in JSON when i try use bracket notation
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = "maps"; // Change this line
Timothy Davis
@timothycdavis
Apr 24 2016 13:08 UTC
@sjames1958gm It's the one where I have to make an array of the largest numbers in other arrays. Honestly I don't think I'm ever going to get javascript :(
Stephen James
@sjames1958gm
Apr 24 2016 13:09 UTC
@timothycdavis Break it down by steps.
@marcschoeni Start with myStorage and work your way inwards. Bracket notations requires "" if the property is not in a variable. Dot notations does not but dot notation cannot be used with variables.
@timothycdavis You have an array that likely means a for loop (there are other loops for arrays, but you have not been exposed to them.
Timothy Davis
@timothycdavis
Apr 24 2016 13:12 UTC
@sjames1958gm ok, I've set up a for loop
Stephen James
@sjames1958gm
Apr 24 2016 13:13 UTC
@timothycdavis so assuming you used i for your loop variable arr[i] is your inside array that you have to find the largest of, yes?
Timothy Davis
@timothycdavis
Apr 24 2016 13:14 UTC
@sjames1958gm yes
Alex
@alexstelmakh
Apr 24 2016 13:14 UTC
Can somebody help me with solving this problem? The code seems to be correct, but it doesn't work. I have added double brackets by one camper's advice. Without them it doesn't work too. This is the link to excersize https://www.freecodecamp.com/challenges/record-collection. And this is my code
function updateRecords(id, prop, value) {
   if ((value !== "") && (prop !== "tracks")) {
      collection[id][prop] = value;
    } else if ((prop == "tracks") && (value !== "")) {
      collection[id].tracks.push(value);
    } else if (value === "") {
      delete collection[id][prop];
    }
  return collection;
}
Stephen James
@sjames1958gm
Apr 24 2016 13:14 UTC
@timothycdavis Hmm another array - another for loop ?
llamatarianism
@llamatarianism
Apr 24 2016 13:15 UTC
@timothycdavis you mean, the "largest of four" one?
Timothy Davis
@timothycdavis
Apr 24 2016 13:15 UTC
@llamatarianism yes
@sjames1958gm ok
llamatarianism
@llamatarianism
Apr 24 2016 13:15 UTC
@timothycdavis ok I'm gonna teach you a neat trick
Stephen James
@sjames1958gm
Apr 24 2016 13:15 UTC
@timothycdavis Since you have to remember the largest from arr[i] for loop, add a variable before that loop to store the largest in.
llamatarianism
@llamatarianism
Apr 24 2016 13:15 UTC
.apply() is a property of all functions
its first argument can be pretty much anything for most purposes
the second argument is an ARRAY of arguments, rather than a list of arguments.
so you can basically iterate over each array
and use Max.math.apply([], arr[i]) to find the largest number in each array
much easier than using another for loop
Timothy Davis
@timothycdavis
Apr 24 2016 13:18 UTC
@llamatarianism Do I need to store that in a variable, and then return it?
llamatarianism
@llamatarianism
Apr 24 2016 13:18 UTC
@timothycdavis yeah
Stephen James
@sjames1958gm
Apr 24 2016 13:18 UTC
@alexstelmakh Try refreshing the browser - the code worked for me
llamatarianism
@llamatarianism
Apr 24 2016 13:18 UTC
I'd push the Math.max of each sub-array into one array, and then return that
.apply() is really useful for a lot of things regarding arrays
you can flatten arrays really easily using [].concat.apply([], /* array */);
Stephen James
@sjames1958gm
Apr 24 2016 13:20 UTC
@rohitrango Turns out if you just consider IV == 4, XC == 90, it can be done pretty simply
llamatarianism
@llamatarianism
Apr 24 2016 13:21 UTC
or [].push.apply([], /*array*/);
Timothy Davis
@timothycdavis
Apr 24 2016 13:21 UTC
@llamatarianism what do you mean by flatten an array?
llamatarianism
@llamatarianism
Apr 24 2016 13:21 UTC
@timothycdavis making a 2d array into a flat array
[[1,2],[3,4],[5,6],[7,8]] => [1,2,3,4,5,6,7,8]
Timothy Davis
@timothycdavis
Apr 24 2016 13:21 UTC
@llamatarianism ok
Alex
@alexstelmakh
Apr 24 2016 13:22 UTC
@sjames1958gm It's not so simple. It's wrote :
Type Error: Cannot read property 'push' of undefined.
llamatarianism
@llamatarianism
Apr 24 2016 13:22 UTC
[].concat.apply([], [[1,2],[3,4],[5,6],[7,8]]) === [1,2,3,4,5,6,7,8]
basically it iterates over the array and concatenates each sub array into []
Timothy Davis
@timothycdavis
Apr 24 2016 13:24 UTC
@llamatarianism And I push the math.math inside a for loop? Honestly, Javascript just goes in one ear and out the other. I just can't get my head around it
llamatarianism
@llamatarianism
Apr 24 2016 13:24 UTC
here let me show you
@timothycdavis https://jsfiddle.net/
whoopsie daisie
didn't save
@timothycdavis https://jsfiddle.net/s92pvado/1/ another one to show a really simple use of .apply() so you can understand it better
Marc Schöni
@marcschoeni
Apr 24 2016 13:28 UTC
@sjames1958gm it will not work
llamatarianism
@llamatarianism
Apr 24 2016 13:29 UTC
@marcschoeni show us your code again?
Stephen James
@sjames1958gm
Apr 24 2016 13:29 UTC
@marcschoeni I don't know what it is ?
Timothy Davis
@timothycdavis
Apr 24 2016 13:29 UTC
@llamatarianism ok, I get it now. Thanks. How long does it take to really understand Javascript because I'm struggling
CamperBot
@camperbot
Apr 24 2016 13:29 UTC
timothycdavis sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 433 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Apr 24 2016 13:29 UTC
@timothycdavis ehhh, depends
Stephen James
@sjames1958gm
Apr 24 2016 13:30 UTC
@timothycdavis Do you have experience with other programming languages?
ZAM666
@ZAM666
Apr 24 2016 13:31 UTC
Hello. Could you help me with "Selecting from many options with Switch Statements?"?
Timothy Davis
@timothycdavis
Apr 24 2016 13:31 UTC
@sjames1958gm I only recently started, but I've been doing some courses on codeacademy for PHP, Javasript, and jQuery, but my strongest are just HTML and CSS
llamatarianism
@llamatarianism
Apr 24 2016 13:31 UTC
@ZAM666 sure
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 13:31 UTC
@alexstelmakh you could try testing if "value" is blank 1st.
remember sometimes the order in which you write an IF statement can make a difference :-)
llamatarianism
@llamatarianism
Apr 24 2016 13:32 UTC
@timothycdavis I don't wanna be THAT guy who always talks smack about PHP when it's not actually that bad
but I'd probably stay away from it until you're more experienced
ZAM666
@ZAM666
Apr 24 2016 13:32 UTC
Guys, I have got one question. In you opinion is this possible to get any job (even for free, just for experience) remote with HTML,CSS, Bootstrap and a bit JS, jQuery?
llamatarianism
@llamatarianism
Apr 24 2016 13:32 UTC
not because it's a hard language to learn. because it's bloody ANNOYING
Marc Schöni
@marcschoeni
Apr 24 2016 13:33 UTC
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = inside["glove box"].maps;// Change this line
llamatarianism
@llamatarianism
Apr 24 2016 13:33 UTC
@ZAM666 you'd probably need more than "a bit" of javascript
but you could become a front-end developer
Timothy Davis
@timothycdavis
Apr 24 2016 13:33 UTC
@llamatarianism All the languages seem very different to me
Stephen James
@sjames1958gm
Apr 24 2016 13:33 UTC
@marcschoeni You need to use myStorage not inside
@timothycdavis That they are
llamatarianism
@llamatarianism
Apr 24 2016 13:33 UTC
@timothycdavis nah, they're mostly quite similar.
at least, the imperative ones
ZAM666
@ZAM666
Apr 24 2016 13:33 UTC
@llamatarianism yes. But I live in small town and good option for me would be remote job... Do you think is this possible on this level?
llamatarianism
@llamatarianism
Apr 24 2016 13:33 UTC
artificially, they look very different, due to differences in syntax
@ZAM666 you'd probably still need more knowledge of actual programming
Dontavious Sanders
@sanddc318
Apr 24 2016 13:34 UTC

var myArray = [1,2,3]; //Test array.

function addThemUp() {
var myTotal = 0;
for(var i = 0, len = myArray.length; i < len; i++) {
myTotal += myArray[i];
}
return myTotal;
}

addThemUp(); //Need it to work with any array that is passed.

This function returns 6 but I need a way for it to return the sum of any array (i.e. [1,2,3,4,5]) that is passed. I hope my explanation makes sense because I am stuck and any help would be greatly appreciated.

Stephen James
@sjames1958gm
Apr 24 2016 13:34 UTC
help format
CamperBot
@camperbot
Apr 24 2016 13:34 UTC

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

llamatarianism
@llamatarianism
Apr 24 2016 13:35 UTC
@timothycdavis if you want a good language to learn when you've got to grips with JS, try python
Marc Schöni
@marcschoeni
Apr 24 2016 13:35 UTC
@sjames1958gm same issue
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = myStorage["glove box"].maps;// Change this line
llamatarianism
@llamatarianism
Apr 24 2016 13:35 UTC
@marcschoeni you need to access the glove box property of the inside of the car, which is inside mystorage
Stephen James
@sjames1958gm
Apr 24 2016 13:35 UTC
@marcschoeni maps is not a property it is the contents.
Alex
@alexstelmakh
Apr 24 2016 13:36 UTC
@taneipoo Thank's for attempt,but not.
function updateRecords(id, prop, value) {
      if (prop == "tracks" && value !== "") {
      collection[id].tracks.push(value);
    } else if (value !== "" && prop !== "tracks") {
      collection[id][prop] = value;
    }  else if (value === "") {
      delete collection[id][prop];
    }
  return collection;
}
CamperBot
@camperbot
Apr 24 2016 13:36 UTC
alexstelmakh sends brownie points to @taneipoo :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Apr 24 2016 13:36 UTC
start from myStorage, then work your way down
CamperBot
@camperbot
Apr 24 2016 13:36 UTC
:star: 250 | @taneipoo | http://www.freecodecamp.com/taneipoo
llamatarianism
@llamatarianism
Apr 24 2016 13:36 UTC
like a tree
Stephen James
@sjames1958gm
Apr 24 2016 13:36 UTC
@sanddc318 Your code works - at least in the devtools console - is this a challenge?
llamatarianism
@llamatarianism
Apr 24 2016 13:37 UTC
@sanddc318
function addThemUp(arr) {
  var myTotal = 0;
  for (var i=0; i < arr.length; i++) {
    myTotal += arr[i];
  }
  return myTotal;
}
or alternatively, a solution that works WITHOUT mutability thank-you-very-much!
function addThemUp(arr) {
  return arr.reduce(function(previous, current) {
    return previous + current;
  });
}
Dontavious Sanders
@sanddc318
Apr 24 2016 13:38 UTC
Not for FCC. This is a code challenge for something else.
Stephen James
@sjames1958gm
Apr 24 2016 13:38 UTC
@sanddc318 YOur code works, but using a global is not recommended - @llamatarianism shows how to do the same with parameters
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 13:39 UTC

@alexstelmakh
I mean like this

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

return collection;
}

Timothy Davis
@timothycdavis
Apr 24 2016 13:39 UTC
@llamatarianism ok, this is my code so far, not sure what to do
function largestOfFour(arr) {

  var maxArr = [];

  for (var i = 0; i < arr.length; i++) {
    maxArr.push(Max.math.apply([], arr[i]));
  }
  return maxArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
llamatarianism
@llamatarianism
Apr 24 2016 13:40 UTC
@timothycdavis should work fine
Timothy Davis
@timothycdavis
Apr 24 2016 13:40 UTC
@llamatarianism it says max is not defined
llamatarianism
@llamatarianism
Apr 24 2016 13:40 UTC
oh I see
oops
Stephen James
@sjames1958gm
Apr 24 2016 13:40 UTC
@timothycdavis Math.max not Max.math
llamatarianism
@llamatarianism
Apr 24 2016 13:40 UTC
you wrote Max.math
@timothycdavis @sjames1958gm :thumbsup:
@sanddc318 https://jsfiddle.net/5zkqp62p/ just so you understand how reduce works
Timothy Davis
@timothycdavis
Apr 24 2016 13:41 UTC
@llamatarianism @sjames1958gm ok, thanks
CamperBot
@camperbot
Apr 24 2016 13:41 UTC
timothycdavis sends brownie points to @llamatarianism and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: timothycdavis already gave llamatarianism points
:star: 775 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 24 2016 13:41 UTC
@timothycdavis Math is a set of functions of which max is just one.
Dontavious Sanders
@sanddc318
Apr 24 2016 13:41 UTC
That reduce method seems much cleaner than a for loop. I'll try that.
llamatarianism
@llamatarianism
Apr 24 2016 13:41 UTC
@sanddc318 indeed. also notice that both arr and sum are ES6 constants
no need to change any variables
Timothy Davis
@timothycdavis
Apr 24 2016 13:41 UTC
@llamatarianism Now, I'm onto the next lesson. Hopefully this one is easier :stuck_out_tongue:
llamatarianism
@llamatarianism
Apr 24 2016 13:41 UTC
immutability bestutability
evolutionus
@evolutionus
Apr 24 2016 13:41 UTC

```
function ourFunction(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourFunction(1, 9);
``` Does anyone know what the + ourMine; at the end of this return statement does?

llamatarianism
@llamatarianism
Apr 24 2016 13:42 UTC
@evolutionus it adds a minimum value.
Stephen James
@sjames1958gm
Apr 24 2016 13:42 UTC
@sanddc318 If you end up working with existing code you are likely to run into more for loops, than apply or reduce.
llamatarianism
@llamatarianism
Apr 24 2016 13:42 UTC
@evolutionus imagine you randomly generate a number between 0 and 1
Frank XC
@tenkdayz
Apr 24 2016 13:42 UTC
can anyone try to break my memory game or just play it to see if everything is good.. finished it last night.. http://cygnusix.com/memgame/memgame.html Thanks!
Stephen James
@sjames1958gm
Apr 24 2016 13:42 UTC
@evolutionus Adjusts the range from 0 - num to ourMin - num + ourMin
llamatarianism
@llamatarianism
Apr 24 2016 13:42 UTC
if you add 1 to that, you now have a value between 1 and 2
Alex
@alexstelmakh
Apr 24 2016 13:43 UTC
@taneipoo No it slill doesn't works
evolutionus
@evolutionus
Apr 24 2016 13:44 UTC
ok let me go stare at this code somemore. thanks for your help.
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 13:44 UTC
hmmm... that's interesting
llamatarianism
@llamatarianism
Apr 24 2016 13:45 UTC
@tenkdayz mashed all the buttons to try and break it but it seems to still work
:thumbsup: nice work!
Dontavious Sanders
@sanddc318
Apr 24 2016 13:45 UTC
@sjames1958gm I guess I should better my understanding of for loops then.
Stephen James
@sjames1958gm
Apr 24 2016 13:45 UTC
@alexstelmakh Which test case is failing and post all of the code including the collection.
llamatarianism
@llamatarianism
Apr 24 2016 13:45 UTC
@sanddc318 keep in mind that just because it's more common doesn't mean it's better ;)
Stephen James
@sjames1958gm
Apr 24 2016 13:47 UTC
Sometimes clarity is better than trickiness
Alex
@alexstelmakh
Apr 24 2016 13:47 UTC
@sjames1958gm
2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line

function updateRecords(id, prop, value) {
if (value === "") {
delete collection[id][prop];
} else if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
} else if (id !== "" && prop !== "tracks") {
collection[id][prop] = value;
} 
return collection;
}
// Alter values below to test your code
updateRecords(5439, "tracks", "ABBA");
Stephen James
@sjames1958gm
Apr 24 2016 13:48 UTC
If you change the test, then you have to change the data - add tracks: [] to 5439
Timothy Davis
@timothycdavis
Apr 24 2016 13:49 UTC
@llamatarianism What even is this! The confirm the ending lesson. How?
llamatarianism
@llamatarianism
Apr 24 2016 13:50 UTC
@timothycdavis you can do it in 1 line
use .substr or .slice to cut the ending off
then compare it to target
Alex
@alexstelmakh
Apr 24 2016 13:53 UTC
@sjames1958gm Should I add numbers[ 5439] without quotes?
Marc Schöni
@marcschoeni
Apr 24 2016 13:53 UTC
@sjames1958gm i don`t now why but its go^^
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = myStorage.car.inside["glove box"]; // Change this line
thanks @sjames1958gm
CamperBot
@camperbot
Apr 24 2016 13:53 UTC
marcschoeni sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 776 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
llamatarianism
@llamatarianism
Apr 24 2016 13:54 UTC
@marcschoeni it works now because you're accessing all the variables correctly
you're accessing the "glove box" property of the inside object, which is a property of the car object, which is a property of the myStorage object
Stephen James
@sjames1958gm
Apr 24 2016 13:55 UTC
    5439: {
      album: "ABBA Gold",
     tracks: []
    }
Punith K
@kpunith8
Apr 24 2016 13:55 UTC

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

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

llamatarianism
@llamatarianism
Apr 24 2016 13:55 UTC
help format
CamperBot
@camperbot
Apr 24 2016 13:55 UTC

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

llamatarianism
@llamatarianism
Apr 24 2016 13:55 UTC
imo the bot should just say that every five minutes ;P
Stephen James
@sjames1958gm
Apr 24 2016 13:56 UTC
@kpunith8 a property in a variable must use bracket notation.
@llamatarianism Why it has you to do it :smile:
llamatarianism
@llamatarianism
Apr 24 2016 13:56 UTC
@kpunith8 @sjames1958gm :thumbsup:
if you write contacts[id].prop it looks for a property called prop inside contacts[id]
Gelman Solomon
@gelmans91
Apr 24 2016 13:57 UTC
var Bike = function() {
var gear ;// Private variable
this.getGear=function(){
gear=3;
};
this.setGear=function(){
gear=1;
} ;
};
llamatarianism
@llamatarianism
Apr 24 2016 13:57 UTC
if you write contacts[id][prop], it first EVALUATES prop
so let's say prop was tracks
it would evaluate prop and look for contacts[id].tracks
@gelmans91 .getGear is a GET function
so it's not meant to change gear (gear = 3), just return it (return gear;)
additionally
I think you need to use the this keyword, don't you?
return this.gear;
Tyler
@tylergross
Apr 24 2016 14:00 UTC
 for(var i = 0; i < arr.length; i++){ //run through loop checking each variable
    var valA = arr[i];
    for(var j = i+1; j < arr.length; j++){ //run through loop checking all variables in front 
      var valB = arr[j];
      if(valA + valB == arg){
        alert(i + " " + j);
      }
    }


  }
can anyone explain why this creates a possible infinite loop? im not seeing it, i only see it running the duration of the array
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 14:01 UTC
@llamatarianism I tried .getGear with THIS when returning... it returns undefined. just "gear" is adequate.
Lucky charm
@luckycharm223
Apr 24 2016 14:01 UTC
can someone help me please, i'm going crazy just guessing things :/
var count = 0;

function cc(card) {
  // Only change code below this line
  2, 3, 4, 5, 6

  return "5 Bet";

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
llamatarianism
@llamatarianism
Apr 24 2016 14:01 UTC
@taneipoo alrighty
this is weird. hard to understand how it works sometimes
Dardan Demiri
@dardandemiri
Apr 24 2016 14:02 UTC
Can someone tell me about Convert HTML Entities
llamatarianism
@llamatarianism
Apr 24 2016 14:02 UTC
@luckycharm223 you need to use a switch statement to either increment or decrement (+1 or -1) count
Tyler
@tylergross
Apr 24 2016 14:02 UTC
@taneipoo it would benefit you to make a switch(val){
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 14:02 UTC
lol @llamatarianism yea it is, what I do is write my code in sublime & test each line to see how it works with a print out to console
llamatarianism
@llamatarianism
Apr 24 2016 14:03 UTC
switch (card) {
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
    // do stuff
    break;
...
RLKRLK
@RLKRLK
Apr 24 2016 14:03 UTC
hello lads
llamatarianism
@llamatarianism
Apr 24 2016 14:03 UTC
basically you need to do different stuff depending on what input you get
@dardandemiri sure go ahead
@RLKRLK hello
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 14:03 UTC
g'day @RLKRLK
RLKRLK
@RLKRLK
Apr 24 2016 14:03 UTC
i'm oh so new to coding, and i'm currently taking the challenges for javascript
i'm stuck at this point (oh so new i said)
Stephen James
@sjames1958gm
Apr 24 2016 14:04 UTC
@tylergross Don't see any infinite loop there
RLKRLK
@RLKRLK
Apr 24 2016 14:04 UTC
(mmh how do i copy paste my code ?)
Punith K
@kpunith8
Apr 24 2016 14:05 UTC
how to push values to existing prop in JavaScript?
Tyler
@tylergross
Apr 24 2016 14:05 UTC
@sjames1958gm that's what i was thinking, I keep getting an alert though
Dardan Demiri
@dardandemiri
Apr 24 2016 14:05 UTC
How am I supposed to use RegExp for this challenge
Tyler
@tylergross
Apr 24 2016 14:05 UTC
code is working fine though
Stephen James
@sjames1958gm
Apr 24 2016 14:05 UTC
@taneipoo Did you set the gear with this.gear = something; before getting it?
Dardan Demiri
@dardandemiri
Apr 24 2016 14:05 UTC
should I define the regex with te elements that need to be replaced
Stephen James
@sjames1958gm
Apr 24 2016 14:05 UTC
@RLKRLK
Dardan Demiri
@dardandemiri
Apr 24 2016 14:05 UTC
or what
Stephen James
@sjames1958gm
Apr 24 2016 14:05 UTC
help format
CamperBot
@camperbot
Apr 24 2016 14:05 UTC

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

llamatarianism
@llamatarianism
Apr 24 2016 14:06 UTC
@dardandemiri yeah I'd use regular expressions and .match
Dardan Demiri
@dardandemiri
Apr 24 2016 14:06 UTC
Yes but how did you made the regex
where did you learn about them
Stephen James
@sjames1958gm
Apr 24 2016 14:07 UTC
@dardandemiri I would / i did, or .replace - MDN is a good place
Alex
@alexstelmakh
Apr 24 2016 14:07 UTC
@kpunith8 uhh I finished at last. this is the correct code :
function updateRecords(id, prop, value) {
  if (value !== "" && prop != "tracks") {
    collection[5439][prop] = value;
    collection[1245][prop] = value;
    collection[2468][prop] = value;
    collection[2548][prop] = value;
  } else if (value !== "" && prop == "tracks") {
    collection[id].tracks.push(value);
  } else if (value === "") {
    delete collection[id][prop];
  }
llamatarianism
@llamatarianism
Apr 24 2016 14:07 UTC
whoops
^ the correct link.
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 14:07 UTC
@sjames1958gm I tested that too :-)
so let's say I pass myBike.setGear(10);
when I do console.log("The Bike I built: ", myBike.getGear());
the response is 4
which tells me @sjames1958gm that it's calling var gear = 4;
instead of using what I passed
Dardan Demiri
@dardandemiri
Apr 24 2016 14:08 UTC
hahahha that was good joke @llamatarianism
RLKRLK
@RLKRLK
Apr 24 2016 14:08 UTC

function converToF(celsius) {
// Only change code below this line

// Only change code above this line
 return fahrenheit;

}

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

well that did not come out as expected
Lucky charm
@luckycharm223
Apr 24 2016 14:09 UTC
@llamatarianism like this?
var count = 0;

function cc(card) {
  // Only change code below this line
switch (card) {

  case 2:  
  case 3:
  case 4:
  case 5:
  case 6:
    }
  return "5 Bet";

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
llamatarianism
@llamatarianism
Apr 24 2016 14:09 UTC
@luckycharm223 your } is in the wrong place.
RLKRLK
@RLKRLK
Apr 24 2016 14:09 UTC

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

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

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

Stephen James
@sjames1958gm
Apr 24 2016 14:09 UTC
@luckycharm223 What do the instructions say to do when the value is 2-6?
Alex
@alexstelmakh
Apr 24 2016 14:09 UTC
@sjames1958gm Thank's Stephen you have sent me to the right thoughts
CamperBot
@camperbot
Apr 24 2016 14:09 UTC
alexstelmakh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Apr 24 2016 14:09 UTC
switch (card) {
  case 2:
 ...
  case 6:
    ++count;
  break;
}
CamperBot
@camperbot
Apr 24 2016 14:09 UTC
:star: 777 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
llamatarianism
@llamatarianism
Apr 24 2016 14:09 UTC
I'm PRETTY sure you're meant to increment count
not 100% certain
so don't just copy/paste
dennis-noah
@dennis-noah
Apr 24 2016 14:10 UTC
hey
can anyone help me
with the factorialize a number challenge?
Stephen James
@sjames1958gm
Apr 24 2016 14:10 UTC
@RLKRLK Aren't you supposed to use the parameter celsius to calc. F
Lucky charm
@luckycharm223
Apr 24 2016 14:10 UTC
thank you @llamatarianism
CamperBot
@camperbot
Apr 24 2016 14:10 UTC
luckycharm223 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 434 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
Stephen James
@sjames1958gm
Apr 24 2016 14:11 UTC
@alexstelmakh :+1:
@dennis-noah Post your code or ask your question.
Dardan Demiri
@dardandemiri
Apr 24 2016 14:11 UTC
@llamatarianism thanks for that link
CamperBot
@camperbot
Apr 24 2016 14:11 UTC
dardandemiri sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 435 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
Lucky charm
@luckycharm223
Apr 24 2016 14:11 UTC
@sjames1958gm it should return the string "5 Bet"
dennis-noah
@dennis-noah
Apr 24 2016 14:12 UTC

function factorialize(num) {
var result = num;

while (num !== 0){
result = num * (num - 1);
num--;
}
num=result;
return num;

}

factorialize(5);

I really dont get why this part always gives me 0: result = num * (num - 1);
Dardan Demiri
@dardandemiri
Apr 24 2016 14:12 UTC
People
does the Certificates contain our Name or our Username ?
llamatarianism
@llamatarianism
Apr 24 2016 14:13 UTC
@dardandemiri username
dennis-noah
@dennis-noah
Apr 24 2016 14:13 UTC
and if I say result = num * (num - 1) + result; it gives me 45
but if I say result = num (num - 1) or result = num (num - 1) * result it gives me zero
llamatarianism
@llamatarianism
Apr 24 2016 14:13 UTC
@dennis-noah I'm pretty sure the problem is
RLKRLK
@RLKRLK
Apr 24 2016 14:13 UTC
@sjames1958gm I thought i was supposed to tell the code that my variable fahrenheit was equel to 30°C, multiplied by 9/5 plus 32
llamatarianism
@llamatarianism
Apr 24 2016 14:14 UTC
you're reassigning result every time you go through the loop
rather than adding to it
Dardan Demiri
@dardandemiri
Apr 24 2016 14:14 UTC
@llamatarianism can you change that ?
to My Name for example
RLKRLK
@RLKRLK
Apr 24 2016 14:14 UTC
(The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.) <= is what is written
llamatarianism
@llamatarianism
Apr 24 2016 14:14 UTC
@dardandemiri not sure.
Dardan Demiri
@dardandemiri
Apr 24 2016 14:14 UTC
Because that's Wrong !
dennis-noah
@dennis-noah
Apr 24 2016 14:14 UTC
@llamatarianism how can I change that?
@llamatarianism taking away var?
llamatarianism
@llamatarianism
Apr 24 2016 14:14 UTC
no
gimme a sec
Stephen James
@sjames1958gm
Apr 24 2016 14:14 UTC
@RLKRLK No you are supposed return the F value for the C value of 30 - but using celsius instead of hardcoded 30
llamatarianism
@llamatarianism
Apr 24 2016 14:14 UTC
gonna have a fiddle with it
loops make my head hurt sometimes. I prefer recursion.
Stephen James
@sjames1958gm
Apr 24 2016 14:15 UTC
var result = num--;
while (num > 0) { result *= num; }
@dennis-noah
@dennis-noah When num is 1 num - 1 is zero
@RLKRLK You have the formula Fahrenheit is Celsius times 9/5, plus 32.
RLKRLK
@RLKRLK
Apr 24 2016 14:17 UTC
yup
Stephen James
@sjames1958gm
Apr 24 2016 14:18 UTC
@RLKRLK Just put that in your function as code not words
RLKRLK
@RLKRLK
Apr 24 2016 14:18 UTC
so i am supposed to initialize a variable celsius
implemented with this formula as code right ?
Stephen James
@sjames1958gm
Apr 24 2016 14:19 UTC
@RLKRLK You have a variable celsius
@RLKRLK It is the parameter to your function
@RLKRLK I might be spelling it wrong
llamatarianism
@llamatarianism
Apr 24 2016 14:20 UTC
celsius is right
Kevin Kindorf
@kkindorf
Apr 24 2016 14:20 UTC
I'm having a little trouble with the palindrome problem. I'm getting everything correct except the last test which is this: palindrome("0_0 (: /-\ :) 0-0")
RLKRLK
@RLKRLK
Apr 24 2016 14:21 UTC
si
so*
why is this wrong ? ; celsius = 30*9/5+32;
dennis-noah
@dennis-noah
Apr 24 2016 14:21 UTC
@sjames1958gm now it tells me infinitife loop potential
Kevin Kindorf
@kkindorf
Apr 24 2016 14:22 UTC
I didn't mean to add the smiley face in there :-)
dennis-noah
@dennis-noah
Apr 24 2016 14:22 UTC

function factorialize(num) {
var result = num--;

while (num !== 0){
result *= num;
}
num=result;
return num;

}

factorialize(5);
if I do it like that

Lucky charm
@luckycharm223
Apr 24 2016 14:22 UTC
@llamatarianism could you please tell me what i'm doing wrong with this code
switch (card) {

    case 10:
    case J:
    case Q:
    case K:
    case A:
     return "-5 Hold";
Stephen James
@sjames1958gm
Apr 24 2016 14:22 UTC
@dennis-noah dummy me result *= num--;
llamatarianism
@llamatarianism
Apr 24 2016 14:22 UTC
@luckycharm223 ok 2 things
first of all you've written J, Q, K, A by themselves
rather than in quotation marks
Tyler
@tylergross
Apr 24 2016 14:22 UTC
wiki pairwise
CamperBot
@camperbot
Apr 24 2016 14:22 UTC

:point_right: algorithm pairwise [wiki]

Explanation:

The program should look for the numbers in the array which would add to make the number from the arg. Then instead of adding those numbers up, you will add their indices which is the reason why you get 11 on the example from detail.

Remember that arrays start at index 0 and go from there so from [1,4,2,3,0,5] if we switch to their indices it would be [0,1,2,3,4,5] then we add indices 1 + 2 + 3 + 5 and we get 11. That is what we need to return.

:pencil: read more about algorithm pairwise on the FCC Wiki

Stephen James
@sjames1958gm
Apr 24 2016 14:22 UTC
@sjames1958gm @dennis-noah got to reduce num by one each time.
llamatarianism
@llamatarianism
Apr 24 2016 14:22 UTC
so the interpreter treats those as variable names
dennis-noah
@dennis-noah
Apr 24 2016 14:23 UTC
@sjames1958gm okay only one mistake: factorialize (0) should return 1
llamatarianism
@llamatarianism
Apr 24 2016 14:23 UTC
rather than strings: 'J', 'Q', 'K', 'A'
secondly, you're returning the same thing regardless of count
Stephen James
@sjames1958gm
Apr 24 2016 14:24 UTC
@dennis-noah Either add a special case or rework you loop slightly.
var result = 1;
while (num !== 0){
result *= num;
}
llamatarianism
@llamatarianism
Apr 24 2016 14:24 UTC
the exercise wants you to return count, followed by Hold, Bet or Stay (iirc) based on whether count is positive, negative or 0
not -5 Hold
dennis-noah
@dennis-noah
Apr 24 2016 14:24 UTC
@sjames1958gm Thanks a lot!!!!
CamperBot
@camperbot
Apr 24 2016 14:24 UTC
dennis-noah sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 778 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 24 2016 14:24 UTC
@RLKRLK You want to get F from celsius so celsius needs to be on the right side of = in place of 30
llamatarianism
@llamatarianism
Apr 24 2016 14:25 UTC
@kkindorf you have to ignore non-alphanumeric characters
Stephen James
@sjames1958gm
Apr 24 2016 14:25 UTC
@dennis-noah :+1:
llamatarianism
@llamatarianism
Apr 24 2016 14:25 UTC
like whitespace and slashes
Craig Morrison
@frogmorton
Apr 24 2016 14:25 UTC
wiki format
CamperBot
@camperbot
Apr 24 2016 14:25 UTC

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

dennis-noah
@dennis-noah
Apr 24 2016 14:25 UTC
@sjames1958gm one more question. So I put in 5 for example, then it calculates 1 * 4
Lucky charm
@luckycharm223
Apr 24 2016 14:26 UTC
@llamatarianism thank you :)
CamperBot
@camperbot
Apr 24 2016 14:26 UTC
luckycharm223 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:warning: luckycharm223 already gave llamatarianism points
Stephen James
@sjames1958gm
Apr 24 2016 14:26 UTC
@dennis-noah I forgot the num-- again inside th eloop
dennis-noah
@dennis-noah
Apr 24 2016 14:26 UTC

function factorialize(num) {
var result = 1;

while (num !== 0){
result *= num--;
}
num=result;
return num;

}

factorialize(5);

So if I put in 5 it calculates:

1 4 then goes on and calculates 43 and then 3 * 2 but what about the 5?

@sjames1958gm I think I dont understand the solution
Stephen James
@sjames1958gm
Apr 24 2016 14:27 UTC
@dennis-noah 5 is the first number 1* 5 (the -- after num means subtract after using num)
dennis-noah
@dennis-noah
Apr 24 2016 14:27 UTC
@sjames1958gm ah so it gets only subtracted after it has been count already?
Stephen James
@sjames1958gm
Apr 24 2016 14:28 UTC
1 * 5 , 5 * 4, 20 * 3, 60 * 2, 120 * 1 - done
@dennis-noah After it has been used in the *= multiply, yes
RLKRLK
@RLKRLK
Apr 24 2016 14:28 UTC
@sjames1958gm so i should try
fahrenheit = "celsius*9/5+32";
?
llamatarianism
@llamatarianism
Apr 24 2016 14:28 UTC
@RLKRLK no quotation marks
just celsius * 9 /5 + 32
RLKRLK
@RLKRLK
Apr 24 2016 14:29 UTC
arite
@sjames1958gm @llamatarianism thank you very much
CamperBot
@camperbot
Apr 24 2016 14:29 UTC
rlkrlk sends brownie points to @sjames1958gm and @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 779 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 436 | @llamatarianism | http://www.freecodecamp.com/llamatarianism