These are chat archives for FreeCodeCamp/HelpJavaScript

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

: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
Hello World
CamperBot
@camperbot
Apr 24 2016 00:20

welcome to FreeCodeCamp @CaffeineQueen!

CaffeineQueen
@CaffeineQueen
Apr 24 2016 00:20
So friendly... <3 @camperbot
Stephane
@overmelo
Apr 24 2016 00:35
anyone has done confirm the ending challenge?
Joseph
@revisualize
Apr 24 2016 00:35
Hehe
Base link?
heymark
@heymark
Apr 24 2016 00:36
@overmelo yep
Stephane
@overmelo
Apr 24 2016 00:37
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
@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
@heymark i guess yes
heymark
@heymark
Apr 24 2016 00:43
so what would you use instead of -1 to get the length of target?
Stephane
@overmelo
Apr 24 2016 00:45
string.lenght-1?
heymark
@heymark
Apr 24 2016 00:46
not quite. Your target string is called target, so the length of it would be target.length
Stephane
@overmelo
Apr 24 2016 00:47
ok let me try that
llamatarianism
@llamatarianism
Apr 24 2016 00:47
actually you'd need -target.length
heymark
@heymark
Apr 24 2016 00:48
yep
getting there :)
llamatarianism
@llamatarianism
Apr 24 2016 00:48
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

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
wow thanks to @heymark AND @llamatarianism
CamperBot
@camperbot
Apr 24 2016 00:49
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
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
@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
@llamatarianism can you explain why you put "-" at the beginning?
llamatarianism
@llamatarianism
Apr 24 2016 00:51
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
which var am i .push?
llamatarianism
@llamatarianism
Apr 24 2016 00:51
@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
nice one
llamatarianism
@llamatarianism
Apr 24 2016 00:52
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
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
@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
@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
@llamatarianism Kill me now
llamatarianism
@llamatarianism
Apr 24 2016 00:56
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
I keep making these silly mistakes
llamatarianism
@llamatarianism
Apr 24 2016 00:56
I'd probably write Math.max.apply([], arr[i]) just for clarity's sake
Himanshu Batra
@manshu
Apr 24 2016 00:56
i seem to endup googling every answer. What’s the best way to mentally challenge myself
llamatarianism
@llamatarianism
Apr 24 2016 00:57
@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
let me c
Mike Olie
@SwiftMike
Apr 24 2016 00:58
dope i just completed it thanks @llamatarianism !!
CamperBot
@camperbot
Apr 24 2016 00:58
freshsteak sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Apr 24 2016 00:58
@manshu I'd recommend doing the challenges labelled ecmascript rather than javascript
CamperBot
@camperbot
Apr 24 2016 00:58
:star: 429 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
Himanshu Batra
@manshu
Apr 24 2016 00:58
okay perfect
llamatarianism
@llamatarianism
Apr 24 2016 00:58
ecmascript refers to ES2015, which is basically the latest version of javascript
Himanshu Batra
@manshu
Apr 24 2016 00:59
@llamatarianism yup got it.
llamatarianism
@llamatarianism
Apr 24 2016 00:59
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
Is this some type of time bound quiz ?
heymark
@heymark
Apr 24 2016 01:00
not timed, just social
other folks review your code, and vice versa
Himanshu Batra
@manshu
Apr 24 2016 01:01
Perfect
llamatarianism
@llamatarianism
Apr 24 2016 01:01
@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
yes, i agree.
Kyle Morton
@kmorton1988
Apr 24 2016 01:04
anybody REALLY good at CSS?
I'm having trouble figuring something out.
Himanshu Batra
@manshu
Apr 24 2016 01:04
not really good, but can identify problem
Kyle Morton
@kmorton1988
Apr 24 2016 01:04
the game being played is way off, and I can't figure out why.
Himanshu Batra
@manshu
Apr 24 2016 01:08
.game {
  float: left;
  width: 50%;
here you go
Kyle Morton
@kmorton1988
Apr 24 2016 01:08
does that really do it?
heymark
@heymark
Apr 24 2016 01:08
@llamatarianism fwiw, my helper functions work sensibly now :) > http://codepen.io/anon/pen/QNBYmZ?editors=0012
Kyle Morton
@kmorton1988
Apr 24 2016 01:08
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
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
@kmorton1988 maybe give .link display:inline-block
Kyle Morton
@kmorton1988
Apr 24 2016 01:15
I want just the game to the right @manshu
and I'll try it, @qualitymanifest
krisluu5695
@krisluu5695
Apr 24 2016 01:16
//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
no dice @qualitymanifest
DJ
@qualitymanifest
Apr 24 2016 01:16
@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
what did u guy doing ??? @kmorton1988 @qualitymanifest
Stephen Fox
@stevemasta34
Apr 24 2016 01:17
Anybody done "smallest common multiple", in the intermediate algorithms section?
A little stuck on something
Stephen James
@sjames1958gm
Apr 24 2016 01:18
@stevemasta34 yes, what do you have
Kyle Morton
@kmorton1988
Apr 24 2016 01:19
OH!
Stephen Fox
@stevemasta34
Apr 24 2016 01:19
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
i got stuck at Profile Lookup ??? can someone help me ?
Kyle Morton
@kmorton1988
Apr 24 2016 01:19
@qualitymanifest Yes! you did it, thanks a ton!
CamperBot
@camperbot
Apr 24 2016 01:19
kmorton1988 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
Kyle Morton
@kmorton1988
Apr 24 2016 01:19
lol.
CamperBot
@camperbot
Apr 24 2016 01:19
:star: 1140 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Stephen James
@sjames1958gm
Apr 24 2016 01:20
@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
np :+1:
Stephen Fox
@stevemasta34
Apr 24 2016 01:20
"smallestCommons([1, 13]) should return 360360." but I'm returning 1081080
@sjames1958gm
Stephen James
@sjames1958gm
Apr 24 2016 01:20
@stevemasta34 Show your code -
@stevemasta34 Sounds like you are going too far
Stephen Fox
@stevemasta34
Apr 24 2016 01:21

```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
@stevemasta34 Press shift-return after the first ```
A H
@allenhsieh
Apr 24 2016 01:23
help chunky monkey
CamperBot
@camperbot
Apr 24 2016 01:23

: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
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
@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
"Doesn't" perhaps?
Stephen James
@sjames1958gm
Apr 24 2016 01:27
@stevemasta34 Duh - yes
Stephen Fox
@stevemasta34
Apr 24 2016 01:27
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
@stevemasta34 You mean a loop until you find % == 0
Stephen Fox
@stevemasta34
Apr 24 2016 01:29
@sjames1958gm I don't understand what you meant by that statement
Tyler
@tylergross
Apr 24 2016 01:29
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
@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

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
@tylergross define your functions with "this.set" instead of overwriting the prototype like crazy
Tyler
@tylergross
Apr 24 2016 01:31
@stevemasta34 not sure why that worked, but it did. Thanks
CamperBot
@camperbot
Apr 24 2016 01:31
tylergross sends brownie points to @stevemasta34 :sparkles: :thumbsup: :sparkles:
krisluu5695
@krisluu5695
Apr 24 2016 01:31
//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
:star: 301 | @stevemasta34 | http://www.freecodecamp.com/stevemasta34
Stephen Fox
@stevemasta34
Apr 24 2016 01:32
@tylergross it's about where the function Object.keys() looks. No problem :) Glad I could help
krisluu5695
@krisluu5695
Apr 24 2016 01:32
@stevemasta34 steve can u help me ?
i got stuck
Tyler
@tylergross
Apr 24 2016 01:33
@stevemasta34 gotcha
Stephen Fox
@stevemasta34
Apr 24 2016 01:34
@krisluu5695 I can try. What's your problem?
krisluu5695
@krisluu5695
Apr 24 2016 01:34
Profile Lookup
A H
@allenhsieh
Apr 24 2016 01:35
@krisluu5695 It looks like you're missing the word else
Stephen James
@sjames1958gm
Apr 24 2016 01:35
@stevemasta34 I think in your reduce.
while (prev % curr !== 0) { prev += prev} return prev;
A H
@allenhsieh
Apr 24 2016 01:36
It should be if/else if/else
krisluu5695
@krisluu5695
Apr 24 2016 01:36
@allenhsieh let me try ...
Stephen Fox
@stevemasta34
Apr 24 2016 01:36
@sjames1958gm I'm giving that a shot now
Stephen James
@sjames1958gm
Apr 24 2016 01:37
@stevemasta34 Curr should be current for your code
krisluu5695
@krisluu5695
Apr 24 2016 01:37
@allenhsieh nth happen :smile:
Ekultek
@Ekultek
Apr 24 2016 01:37
Who's good with multi dimensional arrays?
krisluu5695
@krisluu5695
Apr 24 2016 01:38
i thought the problem at these [i][firstName] or [i].prop
Stephen Fox
@stevemasta34
Apr 24 2016 01:38
@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
@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
@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
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
@sjames1958gm that did it. Thanks :)
CamperBot
@camperbot
Apr 24 2016 01:53
stevemasta34 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 771 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Kevin
@KevinBruland
Apr 24 2016 01:53
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
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
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
@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
@kmulligan make a new array with an object
Kevin Mulligan
@kmulligan
Apr 24 2016 02:04
@tylergross and just pull the old object's .name out?
Kevin
@KevinBruland
Apr 24 2016 02:06
@dhyey35 I think I actually figured it out...
A H
@allenhsieh
Apr 24 2016 02:10
help slasher flick
CamperBot
@camperbot
Apr 24 2016 02:10

: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
@Benalron right now ur code only appends one div when one of those 100 clicked
Kevin Mulligan
@kmulligan
Apr 24 2016 02:11
@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
@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
Just started "Binary Agents" and I've just got say...
What the hell man
help binary agents
CamperBot
@camperbot
Apr 24 2016 02:16

: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
help missing letters
CamperBot
@camperbot
Apr 24 2016 02:17

: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
@Benalron have u solved it?
Kevin
@KevinBruland
Apr 24 2016 02:17
yeah
Ekultek
@Ekultek
Apr 24 2016 02:18
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
its not very exciting... but its my first use of jquery... so I am excited lol
Erik Maurer
@MauPow
Apr 24 2016 02:18
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

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
@Ekultek I think you have to shift() .
TanYiXun
@TanYiXun
Apr 24 2016 02:23
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
Shift doesn't work either
A H
@allenhsieh
Apr 24 2016 02:26
@TanYiXun because the loop will run up to but not include the last number
Stephen James
@sjames1958gm
Apr 24 2016 02:26
@Ekultek Return the value from the shift
TanYiXun
@TanYiXun
Apr 24 2016 02:27
@allenhsieh ? i dont know wht the last index of the array is length -1
A H
@allenhsieh
Apr 24 2016 02:28

@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
@allenhsieh oh i seee... THanks!!
CamperBot
@camperbot
Apr 24 2016 02:31
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
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
```

//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
@allenhsieh me too... but i had the help of friendly people like you :)
krisluu5695
@krisluu5695
Apr 24 2016 02:33
help :worried:
CamperBot
@camperbot
Apr 24 2016 02:33
no wiki entry for: worried
krisluu5695
@krisluu5695
Apr 24 2016 02:35
still can't out this area ......
can someone help me .... ?
Coby-T
@Coby-T
Apr 24 2016 02:35
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
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
let me try ...
Coby-T
@Coby-T
Apr 24 2016 02:37
@anandubajith What output are you getting?
krisluu5695
@krisluu5695
Apr 24 2016 02:38
@Coby-T ```
Anandu B Ajith
@anandubajith
Apr 24 2016 02:38
@Coby-T [1,2,3,5,null]
krisluu5695
@krisluu5695
Apr 24 2016 02:38
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
@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
help mutations
CamperBot
@camperbot
Apr 24 2016 02:42

: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
help Profile Lookup
CamperBot
@camperbot
Apr 24 2016 02:46

: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
@fmfarinacci
fmfarinacci
@fmfarinacci
Apr 24 2016 02:53
aha I found you!!
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:08
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
@icartusacrimea HI, Traci....
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:09
Hi.
fmfarinacci
@fmfarinacci
Apr 24 2016 03:10
Hi Traci
Norvin Burrus
@ndburrus
Apr 24 2016 03:10
@icartusacrimea I used a switch statement, along with an if, else statement for the counting cards challenge
krisluu5695
@krisluu5695
Apr 24 2016 03:11
thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
Apr 24 2016 03:11
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
@icartusacrimea I don't see u using an if statement to produce the results...
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:11
Hmm... For the switch statement, what would be the expression?
Norvin Burrus
@ndburrus
Apr 24 2016 03:12
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
Very nice solution. Wish I'd thought of it.
Thank you very much @ndburrus
CamperBot
@camperbot
Apr 24 2016 03:14
:star: 240 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 24 2016 03:14
@icartusacrimea I see ur evaluating the card count, u just need to bring it all together...
CamperBot
@camperbot
Apr 24 2016 03:14
icartusacrimea sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
Apr 24 2016 03:14
@icartusacrimea does it make sense to u?
T. Lauren Cremeans
@icartusacrimea
Apr 24 2016 03:15
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
@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
Ah.
Kyle Morton
@kmorton1988
Apr 24 2016 03:20
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
...any challenge questions up to (& including) Accessing Nested Arrays in JSON?
Kyle Morton
@kmorton1988
Apr 24 2016 03:32
huh?
TanYiXun
@TanYiXun
Apr 24 2016 03:39
//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
@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
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
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

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
@snrydr did you test for !== null?
TanYiXun
@TanYiXun
Apr 24 2016 03:52
@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
@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
snrydr sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 682 | @dhcodes | http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Apr 24 2016 04:03
@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
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
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
@tenkdayz It looks pretty good to me.
Coby-T
@Coby-T
Apr 24 2016 04:12
@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
@tenkdayz seems to work fine, might want to adjust incentives though
Coby-T
@Coby-T
Apr 24 2016 04:15
@a-sep You can get it a little shorter with keys.
Artur Sęp
@a-sep
Apr 24 2016 04:16
@dhcodes I didn't know that there are solutions on FCC wiki github :)
Coby-T
@Coby-T
Apr 24 2016 04:16
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
This message was deleted
revisualize @revisualize is ignoring this answer.
Joseph
@revisualize
Apr 24 2016 04:18
I haven't completed that lesson yet.
Artur Sęp
@a-sep
Apr 24 2016 04:19
after I have found a solution :smile: of course
Coby-T
@Coby-T
Apr 24 2016 04:19
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
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
alihammad-gist
@alihammad-gist
Apr 24 2016 04:22
@acgillette share your code please
acgillette
@acgillette
Apr 24 2016 04:23
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
@acgillette You're not removing _s
Artur Sęp
@a-sep
Apr 24 2016 04:23
@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
@acgillette With \W it still keeps in the _ character.
Coby-T
@Coby-T
Apr 24 2016 04:25
@acgillette That double loop isn't checking correctly
Joseph
@revisualize
Apr 24 2016 04:26
@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
@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
the loop is calling like:
i j
0 8
0 7
0 6
...
Joseph
@revisualize
Apr 24 2016 04:27
@acgillette If you solve it.. I will show you my code.
acgillette
@acgillette
Apr 24 2016 04:27
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
It's always the loops
Especially loops with embedded ifs
Joseph
@revisualize
Apr 24 2016 04:29
@acgillette Why are you using a for loop?
acgillette
@acgillette
Apr 24 2016 04:29
I couldn't figure out another way of comparing elements of an array @revisualize
Coby-T
@Coby-T
Apr 24 2016 04:30
There are two ways of doing it
I did it by halving the string
and reversing it
Joseph
@revisualize
Apr 24 2016 04:30
@acgillette Why are you using an array?
Coby-T
@Coby-T
Apr 24 2016 04:30
The other way is to loop the array and compare each char
Joseph
@revisualize
Apr 24 2016 04:31
@acgillette I'll let you finish. And I'll show you my code.
alihammad-gist
@alihammad-gist
Apr 24 2016 04:31
@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
Strings are not arrays.
Coby-T
@Coby-T
Apr 24 2016 04:33
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
@Coby-T Check your PM.
Sure, you can call a character index.
alihammad-gist
@alihammad-gist
Apr 24 2016 04:34
@revisualize why are they accessible like a numeric array?
Joseph
@revisualize
Apr 24 2016 04:36
@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
alihammad-gist
@alihammad-gist
Apr 24 2016 04:40
right. I just realized strings and arrays don't share some functions like map. thanks for clarification.
Lavie Ruan
@LavieMaru
Apr 24 2016 04:44
find Mutations
CamperBot
@camperbot
Apr 24 2016 04:44

find mutations

:zero: algorithm mutations
:one: permutations

Joseph
@revisualize
Apr 24 2016 04:48
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
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?
alihammad-gist
@alihammad-gist
Apr 24 2016 04:53
@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
Oh, gotcha.
Joseph
@revisualize
Apr 24 2016 04:59
@heymark The challenge is correct.
heymark
@heymark
Apr 24 2016 05:01
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
Wait what?
What is your regex?
acgillette
@acgillette
Apr 24 2016 05:04
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
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
@acgillette Okay. can I see your code?
heymark
@heymark
Apr 24 2016 05:06
@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

```
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
@acgillette Okay.. Let's look at this.
@acgillette You're on the right track.. Kind of.
David Parsons
@davidjparsons
Apr 24 2016 05:08
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
@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

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
how about
return str === str2
But, you want to keep the numbers.
TanYiXun
@TanYiXun
Apr 24 2016 05:13
//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
@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
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
It is.
@acgillette What is your regex?
acgillette
@acgillette
Apr 24 2016 05:17
oh its because it;s not removing the underscore
just tested it
Joseph
@revisualize
Apr 24 2016 05:17
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
i went back to the str.replace(/\W/g, "")
Joseph
@revisualize
Apr 24 2016 05:17
[\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
Yep! got it! Thanks for putting up with my baby brain haha
Joseph
@revisualize
Apr 24 2016 05:20
Can I see your code?
acgillette
@acgillette
Apr 24 2016 05:20
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
@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
```
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
Anyhow.. Time for me to get to bed.
acgillette
@acgillette
Apr 24 2016 05:22
thanks for the help @revisualize :)
CamperBot
@camperbot
Apr 24 2016 05:22
acgillette sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 960 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 24 2016 05:22
WOOO! Thanks for the brownie!
nom nom nom nom
Frank XC
@tenkdayz
Apr 24 2016 05:28
it is possible to detect if a page is being inspected or rightclicked
Rada
@Radascript
Apr 24 2016 05:29
does codePen not recognize .on()?
kirbyedy
@kirbyedy
Apr 24 2016 05:30
@Radascript it should
David Parsons
@davidjparsons
Apr 24 2016 05:31
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
Which Challenge, @davidjparsons ?
David Parsons
@davidjparsons
Apr 24 2016 05:33
Using Objects for Lookups @rphares
rphares
@rphares
Apr 24 2016 05:33
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
@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
ah gotcha
rphares
@rphares
Apr 24 2016 05:34
:blush:
David Parsons
@davidjparsons
Apr 24 2016 05:34
thanks
rphares
@rphares
Apr 24 2016 05:34
anytime~
Deepak Yadav
@ydeepk
Apr 24 2016 05:42

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
no body ???
come on folks.. :worried:
:worried:
kirbyedy
@kirbyedy
Apr 24 2016 05:48
with splice
splice your array with howmany
and use array.length
Deepak Yadav
@ydeepk
Apr 24 2016 05:50
@kirbyedy where to use array length?
kirbyedy
@kirbyedy
Apr 24 2016 05:50
in the splice method
array.splice(start, deleteCount[, item1[, item2[, ...]]])
d wilder
@alhazen1
Apr 24 2016 05:50
@ydeepk Hi. Read the MDN on slice carefully. You can do this in one line
Coby-T
@Coby-T
Apr 24 2016 06:03
@ydeepk Think it through, you can actually do it with just slice.
TanYiXun
@TanYiXun
Apr 24 2016 06:08
@revisualize thank you!!
CamperBot
@camperbot
Apr 24 2016 06:08
tanyixun sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 961 | @revisualize | http://www.freecodecamp.com/revisualize
Kevin
@KevinBruland
Apr 24 2016 06:14
is there a way to store an elements CSS value as a variable?
Frank XC
@tenkdayz
Apr 24 2016 06:20
@Benalron var sty = document.getElementById("id").style.opacity;
Kevin
@KevinBruland
Apr 24 2016 06:23
@tenkdayz thanks
CamperBot
@camperbot
Apr 24 2016 06:23
benalron sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 440 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Luis
@zdrifted
Apr 24 2016 06:40
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
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
anyone have a second to help me with a jquery problem
Frank XC
@tenkdayz
Apr 24 2016 06:52
@EldarT90 I dont understand the problem you described.
@Benalron go
Eldar Tinjić
@EldarT90
Apr 24 2016 06:53
@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
@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
@tenkdayz no
Eldar Tinjić
@EldarT90
Apr 24 2016 06:56
@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
@Benalron can you rephrase that?
Brendon
@Balvamar
Apr 24 2016 06:57
anyone point me in the right direction here please
Eldar Tinjić
@EldarT90
Apr 24 2016 06:57
@tenkdayz i go12+34 and i get input 1212 after equal sign
Brendon
@Balvamar
Apr 24 2016 06:57

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
@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
@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
@tenkdayz nope, just can't get this to work
Michal Sadowski
@micsad
Apr 24 2016 07:32
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
@micsad it's normal, especially after some algorithmic tasks
Zoher Ali
@Zoher-ali
Apr 24 2016 07:46
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
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
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
does anybody know how to get paid font for free, I want cielo font
AbdHan
@abdhan
Apr 24 2016 08:42
@micsad Hi what are you supposed to output?
Michal Sadowski
@micsad
Apr 24 2016 08:44
multiplication of product and all the numbers in the sub arrays
AbdHan
@abdhan
Apr 24 2016 08:46
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
one number
AbdHan
@abdhan
Apr 24 2016 08:46
okay try using curly brackets to seperate your loops
Michal Sadowski
@micsad
Apr 24 2016 08:46
will do
V Arun Kumar
@arunvkumr
Apr 24 2016 08:47
@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
Hi guys
I need help with the Roman Numerals Converter?
Michal Sadowski
@micsad
Apr 24 2016 08:49
braces was the problem kudos @arunkumrv @abdhan thanks
CamperBot
@camperbot
Apr 24 2016 08:49
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
Can someone help?
Brendan Kinahan
@BKinahan
Apr 24 2016 08:50
@yadesesan what problem are you having?
Yinka Adesesan
@yadesesan
Apr 24 2016 08:51
@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
@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
@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
@yadesesan you can use if, or for, or while.. I've seen it done multiple ways :)
Yinka Adesesan
@yadesesan
Apr 24 2016 08:57
@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
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
@yadesesan I don't see why not :D
Two heads are better than one.
Yinka Adesesan
@yadesesan
Apr 24 2016 09:01
@BKinahan Can I reach out to you for that?
Brendan Kinahan
@BKinahan
Apr 24 2016 09:02
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
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
@BKinahan Ok. I have a better understanding of Pair Programming now
lindsy
@lindsymoran
Apr 24 2016 09:13
thanks @Rafase282 for your help with Checkpoint: Word Blanks
CamperBot
@camperbot
Apr 24 2016 09:13
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

@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
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
@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
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
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
Hi guys, need help here...What I doing wrong here...Lesson Word Blanks JS
Alex
@alexstelmakh
Apr 24 2016 09:41
@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
@alexstelmakh post you code with changes
Bane Tepavcevic
@banet
Apr 24 2016 09:45
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
@banet you need at least spaces between the words
V Arun Kumar
@arunvkumr
Apr 24 2016 09:46
@banet add spaces between the words like. word1 + " " + word2
Alex
@alexstelmakh
Apr 24 2016 09:47
@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
dont add spaces in the original word and use = instead of +=.
incredible-aj
@incredible-aj
Apr 24 2016 09:48
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
@banet :point_up_2:
incredible-aj
@incredible-aj
Apr 24 2016 09:48
var myStr = \ \t \t \r \n ;
Bane Tepavcevic
@banet
Apr 24 2016 09:48
@arunkumrv sorry I am testing that what you said..
V Arun Kumar
@arunvkumr
Apr 24 2016 09:49
@incredible-aj backslach is \\ your entire string should be \\ \t \t \r \n
Bane Tepavcevic
@banet
Apr 24 2016 09:50
@arunkumrv I tried like you said: result += myAdjective + "" + myNoun +""+ myVerb +""+ myAdverb;
negyvenketto
@negyvenketto
Apr 24 2016 09:50
@banet you are not adding spaces
incredible-aj
@incredible-aj
Apr 24 2016 09:50
Thnks @arunkumrv
CamperBot
@camperbot
Apr 24 2016 09:50
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
@banet put spaces in the quotes
V Arun Kumar
@arunvkumr
Apr 24 2016 09:50
@banet you are missing spaces in the quotes.
Bane Tepavcevic
@banet
Apr 24 2016 09:51
@negyvenketto Thank you man and cheers!
CamperBot
@camperbot
Apr 24 2016 09:51
banet sends brownie points to @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 384 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
negyvenketto
@negyvenketto
Apr 24 2016 09:51
@banet :thumbsup:
V Arun Kumar
@arunvkumr
Apr 24 2016 09:52

@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
@arunkumrv Thank you!
CamperBot
@camperbot
Apr 24 2016 09:53
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
You're welcome :smile:
Pabba Shiva Ram Kaushil
@PabbaShivaRamKaushil
Apr 24 2016 09:57
Storing Values with the Assignment Operator
can anyone help me with this code
javascript
V Arun Kumar
@arunvkumr
Apr 24 2016 09:58
@PabbaShivaRamKaushil Post your code.. someone will definitely help you out..
negyvenketto
@negyvenketto
Apr 24 2016 10:00
@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
:p it worked @negyvenketto
negyvenketto
@negyvenketto
Apr 24 2016 10:02
fcc is strict that way :D
Abdul-Samii Ajala Olalekan
@jalasem
Apr 24 2016 10:08
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
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
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
@esantoro var myStr= "\ \t \t \r \n";
Emanuele Santoro
@esantoro
Apr 24 2016 10:39
and the sequence should be "backslash tab tab carriage-return new-line"
@UtkarshShukla7 why the missing b ?
UtkarshShukla7
@UtkarshShukla7
Apr 24 2016 10:40
@esantoro \\
to escape \
Emanuele Santoro
@esantoro
Apr 24 2016 10:40
OH
it's backslash, not backspace
silly me
UtkarshShukla7
@UtkarshShukla7
Apr 24 2016 10:40
yes
Emanuele Santoro
@esantoro
Apr 24 2016 10:40
sorry guys :smile:
this was a dumb question
thank you @UtkarshShukla7
CamperBot
@camperbot
Apr 24 2016 10:41
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
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
@esantoro np
Emanuele Santoro
@esantoro
Apr 24 2016 10:43
@EldarT90 : #calc {
background-color: green;
border-radius: 12px;
min-height: 25px;
}
set min-height :)
Eldar Tinjić
@EldarT90
Apr 24 2016 10:44
@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
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
np @EldarT90 :)
Hector Castro
@heccas
Apr 24 2016 11:04
Hello guys
got a simple question about Caesars Cipher challenge
classact1
@classact1
Apr 24 2016 11:05
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
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
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
why is my memory button not working
scottmike0
@scottmike0
Apr 24 2016 11:15
@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
and i mean MR button
which should paste memorized value
Ivan Georgiev
@ivangeorgiew
Apr 24 2016 11:19
@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
wiki Caesars Cipher
CamperBot
@camperbot
Apr 24 2016 11:23

: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
@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
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
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
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
@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
who's on falsy bouncer
Eldar Tinjić
@EldarT90
Apr 24 2016 11:42
@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
@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
@sjames1958gm i agree
Stephen James
@sjames1958gm
Apr 24 2016 11:44
I think it is not covered in the challenges because of the differences between browsers.
Eldar Tinjić
@EldarT90
Apr 24 2016 11:44
@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
@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
@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
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
@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
@sjames1958gm good idea
@sjames1958gm tnx for that, let me see if i can do something with it
CamperBot
@camperbot
Apr 24 2016 11:51
eldart90 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave sjames1958gm points
Stephen James
@sjames1958gm
Apr 24 2016 11:53
@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
@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
@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
@silentarrowz oh yeah, it appears to have a comment in it. annoying.
faraz
@silentarrowz
Apr 24 2016 11:58
@llamatarianism , so. any ideas??
llamatarianism
@llamatarianism
Apr 24 2016 11:58
@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
@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
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
@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
@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
@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
@silentarrowz yeah like
JSON.parse(xhttp.request.slice(5, -1)) should work
faraz
@silentarrowz
Apr 24 2016 12:06
@sjames1958gm ah, let me try that
llamatarianism
@llamatarianism
Apr 24 2016 12:06
oooh @sjames1958gm nice catch
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:07
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
@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
i didnt even touch equal sign
Stephen James
@sjames1958gm
Apr 24 2016 12:09
@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
i dont get it
faraz
@silentarrowz
Apr 24 2016 12:10
@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
@silentarrowz google jsonp - wikipedia has some about it. jquery site has info as well
faraz
@silentarrowz
Apr 24 2016 12:11
ok, let me do that then. thanks @sjames1958gm @llamatarianism
CamperBot
@camperbot
Apr 24 2016 12:11
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
@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
@lauralstephenson you were supposed to set b equal a
Eldar Tinjić
@EldarT90
Apr 24 2016 12:15
@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
how do I do that?
Stephen James
@sjames1958gm
Apr 24 2016 12:16
@EldarT90 Make sure you have a way to clear that
greg
@wearenotgroot
Apr 24 2016 12:16
@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
so var a = var b;
greg
@wearenotgroot
Apr 24 2016 12:17
@lauralstephenson so no need to declare them again
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:17
I tried var a = var b; and it won't let me do that.
Eldar Tinjić
@EldarT90
Apr 24 2016 12:18
@sjames1958gm ok now this is working, so thast is 1 problem less on my list
greg
@wearenotgroot
Apr 24 2016 12:18
@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
got it, sjames1958gm ! Thanks so much!
Stephen James
@sjames1958gm
Apr 24 2016 12:23
@lauralstephenson It was @wearenotgroot
@EldarT90 problems-- ?
greg
@wearenotgroot
Apr 24 2016 12:23
@sjames1958gm :smile: it's fine as long as they learn :+1:
iigmir
@iigmir
Apr 24 2016 12:23

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
Thanks, wearnotgroot!
greg
@wearenotgroot
Apr 24 2016 12:24
@lauralstephenson np
Laura Stephenson
@lauralstephenson
Apr 24 2016 12:24
@wearenotgroot Thanks!! How do I give brownie points?
CamperBot
@camperbot
Apr 24 2016 12:24
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
Did it, yay!
greg
@wearenotgroot
Apr 24 2016 12:25
@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
@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
eldart90 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave sjames1958gm points
iigmir
@iigmir
Apr 24 2016 12:26
@wearenotgroot Ah thanks, I missed!
greg
@wearenotgroot
Apr 24 2016 12:26
@iigmir np
Eldar Tinjić
@EldarT90
Apr 24 2016 12:34
@sjames1958gm but its not working https://codepen.io/EldarT/pen/YqjJBx
Stephen James
@sjames1958gm
Apr 24 2016 12:36
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
@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
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
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
@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
@craaakk try another regex->https://regex101.com/
Stephen James
@sjames1958gm
Apr 24 2016 12:38
@glorious1688 Shift does exactly that.
Eldar Tinjić
@EldarT90
Apr 24 2016 12:39
@sjames1958gm it would make it look nicer, but would it make it work ?
Stephen James
@sjames1958gm
Apr 24 2016 12:39
@EldarT90 just look nicer, maybe easier to reason about.
cmf89
@cmf89
Apr 24 2016 12:39
@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
@sjames1958gm ok i did that
greg
@wearenotgroot
Apr 24 2016 12:40
@craaakk maybe filter out non-word characters(non-alphanummeric, special charactes ... etc)
Eldar Tinjić
@EldarT90
Apr 24 2016 12:40
@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
@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
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
@cmf89 Use `` to block gitter inline
craaakk
@craaakk
Apr 24 2016 12:46
@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
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
any suggestions for roman numeral challenge
its kind of lengthy
Stephen James
@sjames1958gm
Apr 24 2016 12:59
@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
im doing the same
is there a better way ? @sjames1958gm
Stephen James
@sjames1958gm
Apr 24 2016 13:02
@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
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
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
@timothycdavis It that the one with arrays in arrays?
Marc Schöni
@marcschoeni
Apr 24 2016 13:07
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
@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
@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
@sjames1958gm ok, I've set up a for loop
Stephen James
@sjames1958gm
Apr 24 2016 13:13
@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
@sjames1958gm yes
Alex
@alexstelmakh
Apr 24 2016 13:14
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
@timothycdavis Hmm another array - another for loop ?
llamatarianism
@llamatarianism
Apr 24 2016 13:15
@timothycdavis you mean, the "largest of four" one?
Timothy Davis
@timothycdavis
Apr 24 2016 13:15
@llamatarianism yes
@sjames1958gm ok
llamatarianism
@llamatarianism
Apr 24 2016 13:15
@timothycdavis ok I'm gonna teach you a neat trick
Stephen James
@sjames1958gm
Apr 24 2016 13:15
@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
.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
@llamatarianism Do I need to store that in a variable, and then return it?
llamatarianism
@llamatarianism
Apr 24 2016 13:18
@timothycdavis yeah
Stephen James
@sjames1958gm
Apr 24 2016 13:18
@alexstelmakh Try refreshing the browser - the code worked for me
llamatarianism
@llamatarianism
Apr 24 2016 13:18
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
@rohitrango Turns out if you just consider IV == 4, XC == 90, it can be done pretty simply
llamatarianism
@llamatarianism
Apr 24 2016 13:21
or [].push.apply([], /*array*/);
Timothy Davis
@timothycdavis
Apr 24 2016 13:21
@llamatarianism what do you mean by flatten an array?
llamatarianism
@llamatarianism
Apr 24 2016 13:21
@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
@llamatarianism ok
Alex
@alexstelmakh
Apr 24 2016 13:22
@sjames1958gm It's not so simple. It's wrote :
Type Error: Cannot read property 'push' of undefined.
llamatarianism
@llamatarianism
Apr 24 2016 13:22
[].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
@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
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
@sjames1958gm it will not work
llamatarianism
@llamatarianism
Apr 24 2016 13:29
@marcschoeni show us your code again?
Stephen James
@sjames1958gm
Apr 24 2016 13:29
@marcschoeni I don't know what it is ?
Timothy Davis
@timothycdavis
Apr 24 2016 13:29
@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
timothycdavis sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 433 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Apr 24 2016 13:29
@timothycdavis ehhh, depends
Stephen James
@sjames1958gm
Apr 24 2016 13:30
@timothycdavis Do you have experience with other programming languages?
ZAM666
@ZAM666
Apr 24 2016 13:31
Hello. Could you help me with "Selecting from many options with Switch Statements?"?
Timothy Davis
@timothycdavis
Apr 24 2016 13:31
@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
@ZAM666 sure
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 13:31
@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
@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
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
not because it's a hard language to learn. because it's bloody ANNOYING
Marc Schöni
@marcschoeni
Apr 24 2016 13:33
// 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
@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
@llamatarianism All the languages seem very different to me
Stephen James
@sjames1958gm
Apr 24 2016 13:33
@marcschoeni You need to use myStorage not inside
@timothycdavis That they are
llamatarianism
@llamatarianism
Apr 24 2016 13:33
@timothycdavis nah, they're mostly quite similar.
at least, the imperative ones
ZAM666
@ZAM666
Apr 24 2016 13:33
@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
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

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
help format
CamperBot
@camperbot
Apr 24 2016 13:34

: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
@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
@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
@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
@marcschoeni maps is not a property it is the contents.
Alex
@alexstelmakh
Apr 24 2016 13:36
@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
alexstelmakh sends brownie points to @taneipoo :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Apr 24 2016 13:36
start from myStorage, then work your way down
CamperBot
@camperbot
Apr 24 2016 13:36
:star: 250 | @taneipoo | http://www.freecodecamp.com/taneipoo
llamatarianism
@llamatarianism
Apr 24 2016 13:36
like a tree
Stephen James
@sjames1958gm
Apr 24 2016 13:36
@sanddc318 Your code works - at least in the devtools console - is this a challenge?
llamatarianism
@llamatarianism
Apr 24 2016 13:37
@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
Not for FCC. This is a code challenge for something else.
Stephen James
@sjames1958gm
Apr 24 2016 13:38
@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

@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
@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
@timothycdavis should work fine
Timothy Davis
@timothycdavis
Apr 24 2016 13:40
@llamatarianism it says max is not defined
llamatarianism
@llamatarianism
Apr 24 2016 13:40
oh I see
oops
Stephen James
@sjames1958gm
Apr 24 2016 13:40
@timothycdavis Math.max not Max.math
llamatarianism
@llamatarianism
Apr 24 2016 13:40
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
@llamatarianism @sjames1958gm ok, thanks
CamperBot
@camperbot
Apr 24 2016 13:41
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
@timothycdavis Math is a set of functions of which max is just one.
Dontavious Sanders
@sanddc318
Apr 24 2016 13:41
That reduce method seems much cleaner than a for loop. I'll try that.
llamatarianism
@llamatarianism
Apr 24 2016 13:41
@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
@llamatarianism Now, I'm onto the next lesson. Hopefully this one is easier :stuck_out_tongue:
llamatarianism
@llamatarianism
Apr 24 2016 13:41
immutability bestutability
evolutionus
@evolutionus
Apr 24 2016 13:41

```
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
@evolutionus it adds a minimum value.
Stephen James
@sjames1958gm
Apr 24 2016 13:42
@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
@evolutionus imagine you randomly generate a number between 0 and 1
Frank XC
@tenkdayz
Apr 24 2016 13:42
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
@evolutionus Adjusts the range from 0 - num to ourMin - num + ourMin
llamatarianism
@llamatarianism
Apr 24 2016 13:42
if you add 1 to that, you now have a value between 1 and 2
Alex
@alexstelmakh
Apr 24 2016 13:43
@taneipoo No it slill doesn't works
evolutionus
@evolutionus
Apr 24 2016 13:44
ok let me go stare at this code somemore. thanks for your help.
Taneisha S. Mitchell-Gayle
@taneipoo
Apr 24 2016 13:44
hmmm... that's interesting
llamatarianism
@llamatarianism
Apr 24 2016 13:45
@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
@sjames1958gm I guess I should better my understanding of for loops then.
Stephen James
@sjames1958gm
Apr 24 2016 13:45
@alexstelmakh Which test case is failing and post all of the code including the collection.
llamatarianism
@llamatarianism
Apr 24 2016 13:45
@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
Sometimes clarity is better than trickiness
Alex
@alexstelmakh
Apr 24 2016 13:47
@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
If you change the test, then you have to change the data - add tracks: [] to 5439
Timothy Davis
@timothycdavis
Apr 24 2016 13:49
@llamatarianism What even is this! The confirm the ending lesson. How?
llamatarianism
@llamatarianism
Apr 24 2016 13:50
@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
@sjames1958gm Should I add numbers[ 5439] without quotes?
Marc Schöni
@marcschoeni
Apr 24 2016 13:53
@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
marcschoeni sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 776 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
llamatarianism
@llamatarianism
Apr 24 2016 13:54
@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
    5439: {
      album: "ABBA Gold",
     tracks: []
    }
Punith K
@kpunith8
Apr 24 2016 13:55

// 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
help format
CamperBot
@camperbot
Apr 24 2016 13:55

: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
imo the bot should just say that every five minutes ;P
Stephen James
@sjames1958gm
Apr 24 2016 13:56
@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
@kpunith8 @sjames1958gm :thumbsup:
if you write contacts[id].prop it looks for a property called prop inside contacts[id]