18th
Jan 2017
Lydia Larae
@nevaIsDreaming
Jan 18 2017 00:00
@Shiverzz i think it's worth a try
Shiverzz
@Shiverzz
Jan 18 2017 00:00
@nevaIsDreaming I'll give you a BIG hint, so read carefully. For every item in your collection, you have to look at all the properties in source (and their values). This means that the for loops have to be one inside the other. Which one should be on the inside?
Lydia Larae
@nevaIsDreaming
Jan 18 2017 00:03
@Shiverzz alright. so nested for loops is the right approach. I keep trying different variations of that and thinking that there should be an easier way, but knowing that is REALLY helpful.
i think i have something close on my desktop at home. i'm out now, so i think i'm just gonna read some eloquent Javascript for now.
leruzal
@leruzal
Jan 18 2017 00:06
guys any one can help in word blanks challenge
Shiverzz
@Shiverzz
Jan 18 2017 00:07
@nevaIsDreaming yes, my problem was that i were using the wrong combination of loops but i didn't notice because i didn't even think about checking if the loops were inside the right ones and etc.
Lydia Larae
@nevaIsDreaming
Jan 18 2017 00:08
yeah. honestly the way my brain works, i think i need to sit down and draw a picture or something
@Shiverzz What are you working on now?
Shiverzz
@Shiverzz
Jan 18 2017 00:16
@nevaIsDreaming i'm working on the dna pairing algorithm.
Is three after the wherefore art thou
Lydia Larae
@nevaIsDreaming
Jan 18 2017 00:17
are they all this time-consuming after this?
Shiverzz
@Shiverzz
Jan 18 2017 00:19
@nevaIsDreaming Not all of them. The pig latin one was quite easy i thought
@nevaIsDreaming i literally rushed through the basic algorithm section but i'm having some big difficulties on the intermediate
Srinivas Gowda
@solancer
Jan 18 2017 00:20
hey guys
Shiverzz
@Shiverzz
Jan 18 2017 00:20
@solancer hey man
Srinivas Gowda
@solancer
Jan 18 2017 00:21
how can I replace all the currly braces in a string like {{0, 0}, {1024, 768}}
replace takes multiple iterations
Shiverzz
@Shiverzz
Jan 18 2017 00:22
replace the objects you mean ?
Srinivas Gowda
@solancer
Jan 18 2017 00:22
this.cordsParse = this.props.hotspotInfo.HotspotRect; this.cordsParse = this.cordsParse.replace('{{', ''); this.cordsParse = this.cordsParse.replace('}}', ''); this.cordsParse = this.cordsParse.replace('}', ''); this.cordsParse = this.cordsParse.replace('{', ''); console.log(this.cordsParse);
is there a better way to do something like this?
@Shiverzz its jus a string from a json payload
Lydia Larae
@nevaIsDreaming
Jan 18 2017 00:23
@Shiverzz i went pretty quickly through the basic ones too, but i had already learned some basic python and done a lot of those similar algorithms already, so it was just rewriting them in javascript. did you have experience before you started FCC?
Shiverzz
@Shiverzz
Jan 18 2017 00:24
@solancer i don't know man, sorry
Albert L. C.
@sirus3020
Jan 18 2017 00:25
guys how would I lowercase strings inside an array?
Shiverzz
@Shiverzz
Jan 18 2017 00:26
@nevaIsDreaming yeah, i've had some little experience with python too and also C and assembly which i used for automation in my technical course of mechatronics
@nevaIsDreaming i've watched a entire course of webdev on udemy too but didn't have algorithms to practice so i decided to get the fcc certificate
Joseph
@revisualize
Jan 18 2017 00:28
@sirus3020 .toLowerCase()
Shiverzz
@Shiverzz
Jan 18 2017 00:29
@sirus3020 arr[i].toLowerCase()
Travis Fantina
@tfantina
Jan 18 2017 00:29

I'm having trouble working through the Title Case A Sentence exercise:

 function titleCase(str) {

var lower = str.toLowerCase().split(" ");
var i=0;
while(i<= lower.length) {
lower[i] = lower[i].charAt(0).toUpperCase();
console.log(lower[i].charAt(0).toUpperCase());
i++;
}

return lower;
}

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

I get a TypeError saying that that property charAt can't be read. This works with the console.log but not my array and I'm not sure why.

Shiverzz
@Shiverzz
Jan 18 2017 00:30
@sirus3020 you would need to iterate through the array
Vik
@vvang044
Jan 18 2017 00:31
Hello all
has anyone completed validate us telephone number?
Johnny
@JohnnyBizzel
Jan 18 2017 00:39
@vvang044 Yes indeed
@vvang044 My code was a mess though!
shinichinsl110
@shinichinsl110
Jan 18 2017 00:39

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

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

Johnny
@JohnnyBizzel
Jan 18 2017 00:40
@vvang044 Have you learned how to use RegEx: https://regex101.com/
Vik
@vvang044
Jan 18 2017 00:40
yes i have
Joseph
@revisualize
Jan 18 2017 00:40
@shinichinsl110 Remove this line: myStr[0] = "H"; // Fix Me
@tfantina Strings are Immutable.
Vik
@vvang044
Jan 18 2017 00:41
i was able to pass all the cases i couldnt with this one telephoneCheck(555-5555);
TimLaing10
@TimLaing10
Jan 18 2017 00:41
Hi, I'm trying to get my head around escape sequences and I keep failing. Here is my code. var myStr = "Firstline\n\SecondLine\\rThirdline"; // Change this line
Joseph
@revisualize
Jan 18 2017 00:42
@TimLaing10 Thirdline is not the same as rThirdLine
@TimLaing10 Same as Firstline is not the same as FirstLine
@TimLaing10 Strings need to be exact.
TimLaing10
@TimLaing10
Jan 18 2017 00:44
@revisualize Thank you. Much appreciated.
CamperBot
@camperbot
Jan 18 2017 00:44
timlaing10 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3023 | @revisualize |http://www.freecodecamp.com/revisualize
tech-tron
@tech-tron
Jan 18 2017 00:45
<a class="button" id="tweet-quote" title="Tweet this quote!" target="_blank">
what is the title and target tags for; what do they do?!?!
Vik
@vvang044
Jan 18 2017 00:46
opens the link in a new page when you click on it
Margaret
@Margaret2
Jan 18 2017 00:46
@tech-tron target="_blank" makes it open in a new tab
Vik
@vvang044
Jan 18 2017 00:46
anyone wants to look at my code for validate US telephone numbers?
i am unable to pass two of those tests
Margaret
@Margaret2
Jan 18 2017 00:47
@tech-tron just looked it up, title looks like it's the text for a tooltip
tech-tron
@tech-tron
Jan 18 2017 00:47
thanks @Margaret2
CamperBot
@camperbot
Jan 18 2017 00:47
tech-tron sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1219 | @margaret2 |http://www.freecodecamp.com/margaret2
tech-tron
@tech-tron
Jan 18 2017 00:47
thanks again
Evan Kalvis
@evan17gr
Jan 18 2017 00:47
if (data.quote.length>=140){
}
Does anyone know why this won't work?
Johnny
@JohnnyBizzel
Jan 18 2017 00:49
@evan17gr selecting by class name you will have to use [0] ... because it returns an array
Evan Kalvis
@evan17gr
Jan 18 2017 00:49
Why does it return an array?
Margaret
@Margaret2
Jan 18 2017 00:50
bc there could be more than one element with the same class name
Evan Kalvis
@evan17gr
Jan 18 2017 00:50
Oh k
Vik
@vvang044
Jan 18 2017 00:51

function telephoneCheck(str) {
// Good luck!
var regEx = /^(?:(?:+?1\s(?:[.-]\s)?)?(?:(\s([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s(?:[.-]\s)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s(?:[.-]\s)?([0-9]{4})$/; return regEx.test(str); } telephoneCheck("5555555"); i couldnt pass this test Evan Kalvis @evan17gr Jan 18 2017 00:52 Ty johnh and Margaret dianajin @dianajin Jan 18 2017 00:56 Would anybody be able to help me step-by-step publish something on pages.github to preview? I'm trying to publish my first html page but think I broke my Github desktop app function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line result = myNoun + "is" + myAdjective + "and" + myVerb + myAdverb; // Your code above this line return result; } // Change the words here to test your function wordBlanks("dog", "big", "ran", "quickly"); wordBlanks("cat","little","hit","slowly"); Manish Giri @Manish-Giri Jan 18 2017 01:00 @shinichinsl110 add spaces in between. kamikan @kamikan Jan 18 2017 01:00 you need to add + " " + speaking about spaces, what is the diference between /\s/g and /\s+/g? it count doble or more spaces as one? Will @wwhite2011 Jan 18 2017 01:01 It just says tat it is not defined how do I fix this Stephen James @sjames1958gm Jan 18 2017 01:01 @kamikan + means match 1 or more of the previous. so \s+ matches one or more consecutive spaces as a single match Will @wwhite2011 Jan 18 2017 01:01 function nextInLine(arr, item) { // Your code here item = arr.shift(); arr[5] = arr.unshift(item); return item; // Change this line } // Test Setup var testArr = [1,2,3,4,5]; nextinLine(testArr, 6); // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr(arr,6))); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); Stephen James @sjames1958gm Jan 18 2017 01:02 @wwhite2011 The first step from the instructions is to add to the end of the array? Will @wwhite2011 Jan 18 2017 01:02 yea Margaret @Margaret2 Jan 18 2017 01:02 @wwhite2011 you're not supposed to use unshift because that will add to the beginning of the array. kamikan @kamikan Jan 18 2017 01:03 @sjames1958gm thanks CamperBot @camperbot Jan 18 2017 01:03 kamikan sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 5392 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Will @wwhite2011 Jan 18 2017 01:03 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. Stephen James @sjames1958gm Jan 18 2017 01:04 @wwhite2011 What function adds to the end of the array? @kamikan :) Will @wwhite2011 Jan 18 2017 01:06 arr.shift(item); yeah kamikan @kamikan Jan 18 2017 01:06 arr.push("brownie"); right? Will @wwhite2011 Jan 18 2017 01:08 so I need to add to the end and remove the first Stephen James @sjames1958gm Jan 18 2017 01:08 @wwhite2011 no, shift removes from the front. Will @wwhite2011 Jan 18 2017 01:08 that should be unshift and Stephen James @sjames1958gm Jan 18 2017 01:08 @wwhite2011 yes Will @wwhite2011 Jan 18 2017 01:08 push Stephen James @sjames1958gm Jan 18 2017 01:08 @wwhite2011 unshift adds to the front @wwhite2011 yes push Will @wwhite2011 Jan 18 2017 01:09 got it it still gives me a RefefrenceError arr.push(item); arr.shift(); return arr; should be this yeah? Margaret @Margaret2 Jan 18 2017 01:10 @wwhite2011 you aren't supposed to return the arr, supposed to return the item you removed from the array Will @wwhite2011 Jan 18 2017 01:11 item? it sitll gives me same error arr.push(item); item = arr.shift(); return item; Stephen James @sjames1958gm Jan 18 2017 01:13 @wwhite2011 can you show the whole function? And what error? kevinliu6102 @kevinliu6102 Jan 18 2017 01:13 Does anyone know why this makeFriendlyDates is returning null? function makeFriendlyDates(arr) { arr = dateFormatter(arr); return dayDiff(arr[0], arr[1]); } function dateFormatter(arr) { var dateSplit1 = arr[0].split('-'), dateSplit2 = arr[1].split('-'), date1 = new Date(Date.UTC(dateSplit1[0], dateSplit1[1] - 1, dateSplit1[2])), date2 = new Date(Date.UTC(dateSplit2[0], dateSplit2[1] - 1, dateSplit2[2])); return [date1, date2]; } function monthDiff(date1, date2) { var month2 = date2.getUTCFullYear() * 12 + date2.getUTCMonth(); var month1 = date1.getUTCFullYear() * 12 + date1.getUTCMonth(); return month2 - month1; } function dayDiff(date1, date2) { if (date2.getUTCMonth() === date1.getUTCMonth()) { return date1.getUTCDate - date2.getUTCDate; } return 0; } makeFriendlyDates(['2016-07-01', '2016-07-04']); Stephen James @sjames1958gm Jan 18 2017 01:15 @wwhite2011 The reference error is probably in the test. should be this (no arr) nextInLine(testArr,6) @kevinliu6102 It is likely NaN not null (the FCC console shows NaN as null as well - It is likely because you are trying to subtract two functions Farah Soltane @chokolate Jan 18 2017 01:20 i want a hint please on lesson Make Object Properties Private . who wants to see my code? Manish Giri @Manish-Giri Jan 18 2017 01:25 @chokolate :hand: Will @wwhite2011 Jan 18 2017 01:25 Thanks Brotha @sjames1958gm CamperBot @camperbot Jan 18 2017 01:25 wwhite2011 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 5393 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Farah Soltane @chokolate Jan 18 2017 01:26 @Manish-Giri how can i have private chat with yu? Manish Giri @Manish-Giri Jan 18 2017 01:27 @chokolate go here chuckcarr4 @chuckcarr4 Jan 18 2017 01:32 @wwhite2011 need to create a variable to store arr.shit(); then return the variable Stephen James @sjames1958gm Jan 18 2017 01:34 @wwhite2011 you could even just return arr.shift(); which returns the value that shift returns Joseph Chambers @imcodingideas Jan 18 2017 01:36 http://codepen.io/imcodingideas/pen/pRNxxq I'm working on the backend but I need help with some frontend. Basically appendTo is not working. :/ I cant get this to append to the span What am I doing wrong? Nataly C. @cstpk Jan 18 2017 01:39 Joseph Chambers @imcodingideas Jan 18 2017 01:39 Sure. I can Where are you at? What have you tried? Farah Soltane @chokolate Jan 18 2017 01:40 @Manish-Giri thanks CamperBot @camperbot Jan 18 2017 01:40 chokolate sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles: :star2: 3847 | @manish-giri |http://www.freecodecamp.com/manish-giri Joseph Chambers @imcodingideas Jan 18 2017 01:40 I will give you a hint: var myStr = "FirstLine\n"; chuckcarr4 @chuckcarr4 Jan 18 2017 01:42 remember to use \ to return a single \ use "\" to return a \ two backslashes... wth can't even type it on here lol Joseph Chambers @imcodingideas Jan 18 2017 01:43 haha. Ken Haduch @khaduch Jan 18 2017 01:44 @chuckcarr4 - you have to use backticks  to post your code because the browser will interpret \\ as a single backslash, and possibly other things. chuckcarr4 @chuckcarr4 Jan 18 2017 01:44 Yea, I'm new. lol Ken Haduch @khaduch Jan 18 2017 01:44 @chuckcarr4 - you can find the details of how to post code if you read the link that will post from camperbot after my note ''' CamperBot @camperbot Jan 18 2017 01:44 :bulb: to format code use backticks!  more info Stephen James @sjames1958gm Jan 18 2017 01:46 @imcodingideas I am not sure but I think you use the element that you are appending to is what the function gets called on Ken Haduch @khaduch Jan 18 2017 01:46 @chuckcarr4 - welcome, and it's best to learn the best ways to use the chatroom early on! Stephen James @sjames1958gm Jan 18 2017 01:47 @imcodingideas$(".newoptions").appendTo
chuckcarr4
@chuckcarr4
Jan 18 2017 01:48
Yes! I'm just now learning and working through this. I figure helping others when I can will help it stick with me better.
Nataly C.
@cstpk
Jan 18 2017 01:52
Thanks guys! I was just writing it in the wrong order lol
Eugeniu Botnaru
@3ugen
Jan 18 2017 02:02
Hey guys I’m working on Return Largest Numbers in Arrays
this is my code:

function largestOfFour(arr) {
// You can do this!
var newArr = [0, 0, 0, 0];
var i = 0;
var j = 0;

while (i < arr.length) {

while (j < arr[i].length) {

if (newArr[i] < arr[i][j]){

newArr[i] = arr[i][j];
}
j++;
}
i++;
}

return newArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
what is wrong with my while loops
this is the result:
[5, 0, 0, 0]
Jan 18 2017 02:12
Hey guys, If i'm trying to add a number to the end of an array, should .push() work? the number would be in the parenthesis.
Because currently it's pushing it on the end of the variable, for instance [1,2,3,4,5] is being pushed to [1,2,3,4,5] 6
John Nunns
@johnnunns
Jan 18 2017 02:14
@revisualize It's a prep course in order just to be ready for hackreactor. It's definitely not a must that I complete it but it will give me a good leg up in the interview process
Albert L. C.
@sirus3020
Jan 18 2017 02:14
why is my arr.filter not a function?
Eugeniu Botnaru
@3ugen
Jan 18 2017 02:14
Moisés Man
@moigithub
Jan 18 2017 02:15
@rumpumpum u need to reset j on each iteration
simon01528
@simon01528
Jan 18 2017 02:16
can I compare two strings in an if statement or do they have to be number type to compare?
Jan 18 2017 02:16
@rumpumpum didn't work, just added 6 in an array of it's own
chuckcarr4
@chuckcarr4
Jan 18 2017 02:16
post the code
Daniel
@doodleslr
Jan 18 2017 02:16
you can try
yourArray.push(6);
Jan 18 2017 02:16
well it's in a function, I'll post it
Manish Giri
@Manish-Giri
Jan 18 2017 02:16
@rumpumpum the problem is with the placement of your j variable, reset it to 0 inside the i loop
Daniel
@doodleslr
Jan 18 2017 02:17
assuming its just a 6 or replace 6 with the variable
simon01528
@simon01528
Jan 18 2017 02:17
@doodleslr
can I compare two strings in an if statement or do they have to be number type to compare?
Jan 18 2017 02:17
is there a way to post code without it spamming? like what you did just there @Manish-Giri
Manish Giri
@Manish-Giri
Jan 18 2017 02:17
@rumpumpum or watch the demo here - https://jsbin.com/toguma/edit?js,console
'''
CamperBot
@camperbot
Jan 18 2017 02:17
:bulb: to format code use backticks!  more info
Manish Giri
@Manish-Giri
Jan 18 2017 02:18
Jan 18 2017 02:18
Thanks :)
Manish Giri
@Manish-Giri
Jan 18 2017 02:18
:+1:
Daniel
@doodleslr
Jan 18 2017 02:18
@simon01528 which challenge are you on? i think i'm on the same one
Jan 18 2017 02:18
function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
simon01528
@simon01528
Jan 18 2017 02:19
@doodleslr I am on mutations
Manish Giri
@Manish-Giri
Jan 18 2017 02:19
@AdamWayne-dev you need to return the result of this - arr.shift();
instead of this - return item;
Jan 18 2017 02:19
Ah, thanks!
Daniel
@doodleslr
Jan 18 2017 02:19
haha me too @simon01528 im hitting a wall with that as well
simon01528
@simon01528
Jan 18 2017 02:19
good lets figure it out
@doodleslr
chuckcarr4
@chuckcarr4
Jan 18 2017 02:19
mine didn't work with return arr.shift();
Eugeniu Botnaru
@3ugen
Jan 18 2017 02:20
@Manish-Giri Thanks
CamperBot
@camperbot
Jan 18 2017 02:20
rumpumpum sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3848 | @manish-giri |http://www.freecodecamp.com/manish-giri
Jan 18 2017 02:20
Neither did mine ahaha
Manish Giri
@Manish-Giri
Jan 18 2017 02:20
why not
mine did
chuckcarr4
@chuckcarr4
Jan 18 2017 02:20
you have to create a variable to store arr.shift() then you return the variable
Manish Giri
@Manish-Giri
Jan 18 2017 02:20
not necessarily
Jan 18 2017 02:20
maybe it's arr.unshift()?
Manish Giri
@Manish-Giri
Jan 18 2017 02:20
you can directly return arr.shift()
@AdamWayne-dev no .unshift() adds, not removes.
chuckcarr4
@chuckcarr4
Jan 18 2017 02:21
All I know is that mine did not work when I used return arr.shift()
Daniel
@doodleslr
Jan 18 2017 02:21
@simon01528
i've found out that everything needs to be lower case, and that it should iterate through the second array in a for loop and compare that value to the entire first array?
Jan 18 2017 02:21
But it says I need to return the removed number
chuckcarr4
@chuckcarr4
Jan 18 2017 02:21
I had to create a variable
Jan 18 2017 02:21
I'll try the variable, thanks
Manish Giri
@Manish-Giri
Jan 18 2017 02:21
simon01528
@simon01528
Jan 18 2017 02:22
@doodleslr i messaged you
chuckcarr4
@chuckcarr4
Jan 18 2017 02:22
He just did a minute ago
John Nunns
@johnnunns
Jan 18 2017 02:22
@Manish-Giri hey manish! new info haha supposedly the way they've reccommended it to be figured out is by using the array prototype for each method
Daniel
@doodleslr
Jan 18 2017 02:22
@simon01528 ok
manish
@kumarheemanshu
Jan 18 2017 02:22
code
LaTeX $LaTeX code$
var code = "formatted";
 (shift+enter for line break)
var code = "formatted";
John Nunns
@johnnunns
Jan 18 2017 02:22
does that sound promising?
chuckcarr4
@chuckcarr4
Jan 18 2017 02:23
I just said var remove = arr.shift(); then return remove ..... then it worked
Manish Giri
@Manish-Giri
Jan 18 2017 02:23
@johnnunns um
you mean .forEach()?
that's almost the same as using for loops!
Jan 18 2017 02:23
function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
That came out with
before: [1,2,3,4,5]
2
after: [3,4,5,6]
Manish Giri
@Manish-Giri
Jan 18 2017 02:24
@AdamWayne-dev @chuckcarr4 here's the code with arr.shift() - http://bit.ly/2juHnGs
chuckcarr4
@chuckcarr4
Jan 18 2017 02:24
You need a variable to store the data that was removed then return the variable
Manish Giri
@Manish-Giri
Jan 18 2017 02:24
@AdamWayne-dev yes this won't work because you're shifting twice!!
arr.shift();
return arr.shift();
Jan 18 2017 02:25
Manish Giri
@Manish-Giri
Jan 18 2017 02:25
remove the first arr.shift().
John Nunns
@johnnunns
Jan 18 2017 02:25
that's just where they sent me
chuckcarr4
@chuckcarr4
Jan 18 2017 02:25
or that works lol
manish
@kumarheemanshu
Jan 18 2017 02:25

hi any one can help me debug the program
in profile lookup

//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){
if(prop==contacts[i].lastName)
prop=contacts[i].lastName;
else if(prop==contacts[i].number)
prop=contacts[i].number;
else if(prop==contacts[i].likes)
prop=contacts[i].likes;
else
prop=0;
}
else
firstName=0;
}
if(firstName===0){
return "No such contact";
}
else if(prop===0){
return "No such property";
}
else
return prop;

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

John Nunns
@johnnunns
Jan 18 2017 02:25
I'm not sure if for each would encompass other information passed in
Jan 18 2017 02:26
@Manish-Giri That worked, thank you!
CamperBot
@camperbot
Jan 18 2017 02:26
adamwayne-dev sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3849 | @manish-giri |http://www.freecodecamp.com/manish-giri
Jan 18 2017 02:26
@chuckcarr4 worked a charm, cheers!
@chuckcarr4 Thank you!
CamperBot
@camperbot
Jan 18 2017 02:26
adamwayne-dev sends brownie points to @chuckcarr4 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for chuckcarr4
Manish Giri
@Manish-Giri
Jan 18 2017 02:27
@johnnunns are they specifically looking for .forEach() in your code? Other than the syntax being cleaner, I don't see how it would affect what we had yesterday.
unless they're checking for the presence of .forEach() in your code..
John Nunns
@johnnunns
Jan 18 2017 02:28
no I don't believe so. Like i said revisualize's reduce code worked. I'm wondering though is it ok to skip the for loops and learn the reduce?
Manish Giri
@Manish-Giri
Jan 18 2017 02:28
yeah certainly
John Nunns
@johnnunns
Jan 18 2017 02:28
because admittedly I'm clueless how you attained your answer, but if I had to choose one of the codes to learn it'd def be reduce
Manish Giri
@Manish-Giri
Jan 18 2017 02:28
it's concise..
well, no matter what way you choose, the for loop vs the reduce, at the end we both did the same thing
John Nunns
@johnnunns
Jan 18 2017 02:29
Let me rephrase though revisualize's code worked with the sample data but not when other data was being introduced
Manish Giri
@Manish-Giri
Jan 18 2017 02:29
setting the object's property and the value
John Nunns
@johnnunns
Jan 18 2017 02:29
Ok great. I'm gonna master reduce then!
attempt* :)
manish
@kumarheemanshu
Jan 18 2017 02:30
i new for javascript
any one can help me
Manish Giri
@Manish-Giri
Jan 18 2017 02:30
I remember it was something like this
function (acc, cur) { acc[cur][0] = data[cur][1] }, {}
John Nunns
@johnnunns
Jan 18 2017 02:30
exactly why are those the common arguments to use?
Manish Giri
@Manish-Giri
Jan 18 2017 02:30
something on those lines..
John Nunns
@johnnunns
Jan 18 2017 02:30
I know they could be anything but what do those stand for?
Manish Giri
@Manish-Giri
Jan 18 2017 02:31
it's just the way MDN uses it so
I believe it stands for accumulator and current
so that it makes sense..
vernon
@vernonkjr
Jan 18 2017 02:31
@kumarheemanshu try using the .hasOwnProperty() function of the object
Manish Giri
@Manish-Giri
Jan 18 2017 02:31
@kumarheemanshu help with?
vernon
@vernonkjr
Jan 18 2017 02:32
like so @kumarheemanshu ....

function lookUpProfile(firstName, prop) {
// Only change code below this line

for (var i = 0; i < contacts.length; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
}

}
return "No such contact";
// Only change code above this line
}

Rico042002
@rico042002
Jan 18 2017 02:32
Is it possible that codepen is unstable?
Jan 18 2017 02:32
@kumarheemanshu - you are starting off well, but there are things that you are doing that are not necessary to solve this problem. The only things that you have to take into consideration are the firstName match, which you appear to be doing properly. The second thing, once you have a match on the firstName is to find out if the contact that you have matched has the property that was requested - your attempts to get each of the properties is not correct. Note, from the test information, that the prop value is going to be one of the property names, at least that's the general information passed along (there will be some without the property that is given.) I'll just give you a suggestion - look up the Object.hasOwnProperty() method and see what it does for you - it's useful for this particular problem.
Colin McAtee
@colinmac17
Jan 18 2017 02:32
Hello, I am working with switch statements and I think I am having a hard time understanding the fundamentals.
manish
@kumarheemanshu
Jan 18 2017 02:32
thanks sir
Rico042002
@rico042002
Jan 18 2017 02:32
I have some code that works fine in plnkr but it rearrange's my parenthesis on codepen!
Joseph
@revisualize
Jan 18 2017 02:33
Colin McAtee
@colinmac17
Jan 18 2017 02:33

function sequentialSizes(val) {
// Only change code below this line
switch(val) {

case 1:
case 2:
case 3:
console.log("Low");
break;
case 4:
case 5:
case 6:
console.log("Mid");
break;
case 7:
case 8:
case 9:
console.log("High");
break;

}

I can't get why this doesn't work past case 3.
Jan 18 2017 02:34
@colinmac17 - chances are that the only thing you have to do, in each place where you are using console.log is to assign the appropriate text to the answer variable. Because you are only initializing that (or it is being initialized) and you have to set it according to the input that you received. console.log only outputs the information to the browser console, nothing else.
Manish Giri
@Manish-Giri
Jan 18 2017 02:34
@revisualize :+1:
manish
@kumarheemanshu
Jan 18 2017 02:34
@colinmac17 whats problem in this content
vega178
@vega178
Jan 18 2017 02:34
hi guys good night i have a problem in my code, i'm in the part of Testing Objects for Properties
Joseph
@revisualize
Jan 18 2017 02:35
I wrote that in about 30 mon last night. I dont know if it resolves the code.
vega178
@vega178
Jan 18 2017 02:35
this one is my code
Joseph
@revisualize
Jan 18 2017 02:35
30 min.
vega178
@vega178
Jan 18 2017 02:35

var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
if (myObj.hasOwnProperty("checkProp")){
return myObj[checkProp];
}else{
}
}

checkObj("pet");

John Nunns
@johnnunns
Jan 18 2017 02:35
@revisualize you're able to get to it without signing up for prep? c
Colin McAtee
@colinmac17
Jan 18 2017 02:35
@khaduch that is exactly what I am thinking, how to I change the variable after case 3, etc. so that it works?
Joseph
@revisualize
Jan 18 2017 02:35
I wasnt.
vega178
@vega178
Jan 18 2017 02:35
i dont understand
Jan 18 2017 02:36
@colinmac17 - see how they initially assigned it a value? You can do that in each place where you are using console.log, but do not use the var keyword again -
Joseph
@revisualize
Jan 18 2017 02:36
Quotes define strings
@vega178
"checkProp" vs checkProp
Colin McAtee
@colinmac17
Jan 18 2017 02:37

ah perfect so I used this and it worked @khaduch ! Thanks! var answer = "Low";
// Only change code below this line
switch(val) {

case 1:
case 2:
case 3:
console.log("Low");
break;
case 4:
case 5:
case 6:
break;
case 7:
case 8:
case 9:
break;

}
// Only change code above this line

CamperBot
@camperbot
Jan 18 2017 02:37
colinmac17 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
wowcoolwebsite
@wowcoolwebsite
Jan 18 2017 02:38
hey guys I´m busy with basic algoritms (javascript), all of it went fairly easily so far, sometimes I could just type out the solution from the start, however since "Falsy Bouncer " and "Seek and Destroy", I am COMPLETELY lost, even with explanations I have still hard time understanding, feels like suddenly a lot steps were skipped! Do you guys know a good website for more javascript algoritm excercices? Because I definitely need!
Joseph
@revisualize
Jan 18 2017 02:38
FreeCodeCamp
wowcoolwebsite
@wowcoolwebsite
Jan 18 2017 02:39
@revisualize well, sure I love FreeCodeCamp, but some of the exercices were to easy and now the ones I´m struggling with are too complex for me, I need to find some exercice website with more steps in between or more exercices :)
Flying_Fish
@FlyingFish195
Jan 18 2017 02:40
function titleCase(str) {
var NAMESTR=str.toLowerCase();
var array1=NAMESTR.split(' ');

for(var i=0;i<array1.length;i++)
{

array1[i].replace(array1[i].substr(0,1),array1[i].substr(0,1).toUpperCase());
}
str=array1.join(' ');
return str;
}

titleCase("I'm a little tea pot");
Please!!Where is the troble???Title Case aSentence
John Nunns
@johnnunns
Jan 18 2017 02:40
@wowcoolwebsite post the problem you're having trouble with. They definitely do make a big jump from easy to hard so with everyone's help here and you going back to previous exercises and really trying to understand them will make the difference
eeflores
@eeflores
Jan 18 2017 02:41
@FlyingFish195 each element in array1 is a string. You'll need to recreate the string and assign back to each element of array1. Strings are immutable
Jan 18 2017 02:43
@colinmac17 - you're welcome - and even though it works using console.log(answer = "Mid"); etc. It is really not what you're expected to do ordinarily, and probably should not do here. You should just to answer = "Low"; for the first group, answer = "Mid"; for the second, and answer = "High"; for the third group. (Although the first is somewhat redundant due to the initialization, but it makes for a symmetric answer, and would be good if there was no initialization or if it was something other than "Low".
eeflores
@eeflores
Jan 18 2017 02:43
@FlyingFish195 maybe use the return value from the call to the replace function and assign back to array1
wowcoolwebsite
@wowcoolwebsite
Jan 18 2017 02:43
@johnnunns Thank you! Well I think my main problem is that I still don´t completely understand the filter function in javascript, neither callback functions :) the syntax and everythng gets really complex suddenly! I´ll have to understand those better and make some more exercices on that I guess
CamperBot
@camperbot
Jan 18 2017 02:43
wowcoolwebsite sends brownie points to @johnnunns :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for johnnunns
Jan 18 2017 02:46
@wowcoolwebsite - someone posted a link to a tutorial video, and I think that it's a series, about higher-order function in JavaScript. I'll pass it along in the hope that it helps someone. YouTube video lessons on higher order functions in JavaScript
wowcoolwebsite
@wowcoolwebsite
Jan 18 2017 02:49
@khaduch Thank you will definitely check that out! This could help me a lot :)
CamperBot
@camperbot
Jan 18 2017 02:49
wowcoolwebsite sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jan 18 2017 02:57
Colin McAtee
@colinmac17
Jan 18 2017 02:59
@khaduch this makes total sense. thanks for the clarification!
CamperBot
@camperbot
Jan 18 2017 02:59
colinmac17 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Daniel
@doodleslr
Jan 18 2017 03:04
Hey @wowcoolwebsite are you able to give me a hand on mutations?
wowcoolwebsite
@wowcoolwebsite
Jan 18 2017 03:06
@doodleslr hey sure, let me check that exercise :)
Daniel
@doodleslr
Jan 18 2017 03:07
ok, sent you a pm :D
DevRice
@DevRice
Jan 18 2017 03:09
function dropElements(arr, func) {
// Drop them elements.

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

if(func(arr[0])){
break;
}
else{
arr.shift();
}
}
return arr;
}

dropElements([1, 2, 3, 4], function(n) {return n > 5;});
Does anyone know what I'm doing wrong in the "Drop it" algorithm lesson.
Durellg
@Durellg
Jan 18 2017 03:15

Hi I'm struggling to to get reverse string to pass the tests. Here is my code:

var newString = "";
function reverseString(str) {
for(var i = str.length - 1; i !== -1; i--)
{
newString += str[i];
}
str = newString;
return str;
}
reverseString("hello");

Can someone explain why this is not working please?

kevinliu6102
@kevinliu6102
Jan 18 2017 03:15
for all steps of your for loop, your if statement is checking "func(arr[0])" and also think about what happens to the length of the array when you shift an element out and how that affects what you're trying to do in the loop @DevRice
Joe Escobedo
@joeEscob1023
Jan 18 2017 03:16
why does i++ keep the value the same , but ++1 increase it by one?
i thought i++ mean to increase the value by 1 or whatever number.
yourpalsneakers
@yourpalsneakers
Jan 18 2017 03:17
Can anyone tell me why underscores are not being replaced? I'm using this RegExp: /[^A-Za-z0-9_]g/
function palindrome(str) {
// Good luck!
var intStr;
var compStr;
intStr = str.toLowerCase().replace(/[^A-Za-z0-9_]/g, '');
compStr = intStr.split('').reverse().join('');
if (intStr == compStr) {
return true;
}
return false;
}

palindrome("0_0 (: /-\ :) 0-0");
Margaret
@Margaret2
Jan 18 2017 03:20
@yourpalsneakers because ^ means not in brackets, so it will replace anything not an underscore, a letter, or a number
mrcsscco
@marcussacco
Jan 18 2017 03:22
anyone here in India? i have a crisis developing
Margaret
@Margaret2
Jan 18 2017 03:22
@TacoJoe i++ does increase the value by 1
rogchow
@rogchow
Jan 18 2017 03:23
I need help on this exercise. Just cant get it right :+)

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

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

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

yourpalsneakers
@yourpalsneakers
Jan 18 2017 03:23
@Margaret2 OH ok, thanks!
CamperBot
@camperbot
Jan 18 2017 03:23
yourpalsneakers sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1222 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Jan 18 2017 03:23
@rogchow you just need to spell celsius right :D
Greg Duncan
@GregatGit
Jan 18 2017 03:24
@rogchow you also need to remove var celsius;
Jan 18 2017 03:24
@TacoJoe - do you mean the difference between i++ and ++i ? The difference is when the increment takes place and when the value is used. You can see the description on this page: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment_() at that particular link.
Margaret
@Margaret2
Jan 18 2017 03:24
@rogchow yep, also do what @GregatGit said, you don't need to define celsius as a variable, because it already exists as a parameter of your function
Jan 18 2017 03:25
@TacoJoe - the i++ uses the value of i in the equation, and then increments it, whereas ++i increments the value and then uses it. (I've heard the terms "pre-increment" and "post-increment")
rogchow
@rogchow
Jan 18 2017 03:26
haha. Thanks Greg!
Margaret
@Margaret2
Jan 18 2017 03:27

@TacoJoe - the i++ uses the value of i in the equation, and then increments it, whereas ++i increments the value and then uses it. (I've heard the terms "pre-increment" and "post-increment")

ah, good way to put it, wasn't clear on that myself :D thx @khaduch

CamperBot
@camperbot
Jan 18 2017 03:27
margaret2 sends brownie points to @tacojoe and @khaduch :sparkles: :thumbsup: :sparkles:
Tom
@tcouillard
Jan 18 2017 03:27
For whatever reason my repeat string bonfire is returning everything but two of the answers correctly.. anyone mind taking a looksie? :+)
Margaret
@Margaret2
Jan 18 2017 03:28
lol what is with the + noses on these emoji, did i miss a new trend? :joy: :+)
Tom
@tcouillard
Jan 18 2017 03:28
str1=[];
function repeatStringNumTimes(str, num) {
for (i=0;i<num;i++){
str1[i]=str;
}
return  str1.join("");
}

repeatStringNumTimes("abc",1);
Dan
@RetartedZombie
Jan 18 2017 03:29

@Durellg I had better luck splitting the string into an array and reversing the array with arrName.reverse() then joining back to a string ( var newStr = arrName.join('') )

I'm pretty sure that's how I did it. Hope that helps.

Tom
@tcouillard
Jan 18 2017 03:29
my return posts abc
Margaret
@Margaret2
Jan 18 2017 03:29
@Strongolian ok, and which ones are failing
Tom
@tcouillard
Jan 18 2017 03:29
it is repeatStringNumTimes ("abc",1)
("abc",-2)
Rachel Riley
Jan 18 2017 03:29
Hello all!
Tom
@tcouillard
Jan 18 2017 03:29
both return correct answers but are failing
Margaret
@Margaret2
Jan 18 2017 03:30
@Strongolian try moving str1=[] inside your function, i know sometimes it doesn't like global variables
Jan 18 2017 03:30
Margaret
@Margaret2
Jan 18 2017 03:30
and make it var str1 while you're at it
Rachel Riley
Jan 18 2017 03:30
I have a general javascript question that I'm hoping someone can help me with. When examples are written like string.prototype.replace()
Timur Uzel
@timurtu
Jan 18 2017 03:30
@Strongolian why instantiate an array outside the function?
Rachel Riley
Jan 18 2017 03:31
Are they saying that the word prototype would be swapped for the variable name?
Timur Uzel
@timurtu
Jan 18 2017 03:31
missing const btw
Tom
@tcouillard
Jan 18 2017 03:31
@Margaret2 moving it makes all fail except abc,1 @timurtu I will move it in
Jan 18 2017 03:31
@Strongolian - @Margaret2 is definitely correct - the global variable is storing the results over the multiple test cases that are executed, so it will possibly get one right, then no others.
Timur Uzel
@timurtu
Jan 18 2017 03:32
@ParadiseArtist no, they’re saying that the object’s prototype contains the function. like I can call [1, 2, 3].map because the map function exists on the Array prototype
Tom
@tcouillard
Jan 18 2017 03:33
I moved my str1=[] into the function and I passed! Thank you @timurtu @khaduch and @Margaret2 :+)
CamperBot
@camperbot
Jan 18 2017 03:33
strongolian sends brownie points to @timurtu and @khaduch and @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1223 | @margaret2 |http://www.freecodecamp.com/margaret2
Jan 18 2017 03:33
@Strongolian - you're welcome. That is definitely something to watch out for in these exercises!
Tom
@tcouillard
Jan 18 2017 03:34
@khaduch I will know to fiddle with these things more when I run into similar issues again
Margaret
@Margaret2
Jan 18 2017 03:34
@ParadiseArtist yeah, the .prototype means they built it so you can call it on any value of that type
so you can call any String.prototype... function on any string
Rachel Riley
Jan 18 2017 03:35
@timurtu I want to make sure I'm understanding this because I think its one of the big things that is holding me back. So if it said Object. prototype.yeehaw () that would be saying you could call the yeehaw Modifier? or would it be a method? on any object but not neccesarily a string?
I realize that yeehaw is purely fictitious
Would it be called a syntax? I know its not really a method.
Margaret
@Margaret2
Jan 18 2017 03:38
they are called methods actually
and yeah, you could call the yeehaw method on any object { ... } but not on a string, unless there is also a String.prototype.yeehaw()
Rachel Riley
Jan 18 2017 03:39
So what about methods being used as a framework to create multiple objects though.
Margaret
@Margaret2
Jan 18 2017 03:39
for example?
Rachel Riley
Jan 18 2017 03:39
I thought a method would be something like this ...
Timur Uzel
@timurtu
Jan 18 2017 03:40
@ParadiseArtist You can do it yourself to if you need to,
for example if I declare a function on the prototype of of a DOM element, then I will have access to that function on any DOM element
<div id="foo"></div>
Node.prototype.myNewFunction = function() {
// this refers to the node calling the function
}

document.getElementById(‘foo’).myNewFunction()
chuckcarr4
@chuckcarr4
Jan 18 2017 03:42
It would be so nice if they could explain these problem more thoroughly .
Rachel Riley
Jan 18 2017 03:43
Oh wow ok I just figured it out!
Margaret
@Margaret2
Jan 18 2017 03:43
:bulb:
:D
Rachel Riley
Jan 18 2017 03:43
I was thinking of constructors and thought they were called methods
haider
@candh
Jan 18 2017 03:43
prototype means extending a object with custom methods or properties. Everything in javascript is an object (it might be a oversimplification tho)
so like if you have a super cool function on arrays. and you think hmm, i wonder why javascript doesn't have that already, you can do Array.prototype.superCoolFunction = function (){}
Rachel Riley
Jan 18 2017 03:44
Now I get it. because I can create a method to assign someone a different age with a function. It does the same thing! I can't really explain it at all but I think I get it.
Timur Uzel
@timurtu
Jan 18 2017 03:44
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
if you look at all of the different prototype functions that exist on arrays, strings, or anything really you’ll see that these functions aren’t direct descendents of the Object but they exist in the Object’s prototype chain, so when an Object property isn’t found, the prototype chain is checked next then if nothing is found then undefined error
Terence Stone
@Tmstone
Jan 18 2017 03:45
Hello World
CamperBot
@camperbot
Jan 18 2017 03:45

## welcome to FreeCodeCamp @Tmstone!

Rachel Riley
Jan 18 2017 03:46
Ok now lets see if I can figure out the Check for palindromes problem on my own or at least get a few lines of code out before I'm totally stuck. lol
Ive been working on it for a couple days now.
Randy Goldsmith
@Dueldrawer8
Jan 18 2017 03:46
function getSmallestElementAtProperty(obj, key) {
for(var gal in obj){
var smallest = obj[key][0];
if(Array.isArray(obj[key]) && obj[key].length > 0){
for(var i = 1; i < obj[key].length; i++){
if(obj[key][i] < smallest){
smallest = obj[key][i];
}
}
return smallest;
}
else{
return undefined;
}
}

}

var obj = {

};
var output = getSmallestElementAtProperty(obj, 'key');
console.log(output);
So my function is suppose to return undefined if the object is not an array, the array is empty, or there is no property at the key. It passes all test except "no property at the key" When i console.log it, it says undefined, but my test says typeError: cannot read property "0" of undefined. What does that mean?
haider
@candh
Jan 18 2017 03:49
which exercise is this @Dueldrawer8
Timur Uzel
@timurtu
Jan 18 2017 03:50
var smallest = obj[key][0]; @Dueldrawer8 obj[key] is undefined in one iteration
Randy Goldsmith
@Dueldrawer8
Jan 18 2017 03:50
@candh its not an excercise here at freecode camp..im doing a study guide
haider
@candh
Jan 18 2017 03:50
aight, coo
Timur Uzel
@timurtu
Jan 18 2017 03:50
@Dueldrawer8 well all because it’s an empty object actually give the object properties
Randy Goldsmith
@Dueldrawer8
Jan 18 2017 03:51
hm
@timurtu so maybe move the var smallest inside my first if statement?
@timurtu yes..that works! thanks..how did you figure out the problem though
CamperBot
@camperbot
Jan 18 2017 03:52
dueldrawer8 sends brownie points to @timurtu :sparkles: :thumbsup: :sparkles:
Timur Uzel
@timurtu
Jan 18 2017 03:52
@Dueldrawer8 the error message
Jan 18 2017 03:53
Hey guys, having trouble getting a function to carry on if it doesn't meet the right condition. I want the code to carry on after this " if (a > 0 || b > 0) {return;}. Should my code carry on if it doesn't meet that condition?
Randy Goldsmith
@Dueldrawer8
Jan 18 2017 03:53
@timurtu the error message i told you or did you actually test it in chrome console>?
Timur Uzel
@timurtu
Jan 18 2017 03:53
@Dueldrawer8 It was looking for a property 0 on an undefined object, obj[key][0]
Randy Goldsmith
@Dueldrawer8
Jan 18 2017 03:54
@timurtu ahh.. that makes more sense
@timurtu thanks again, made me realize my problem..
CamperBot
@camperbot
Jan 18 2017 03:54
dueldrawer8 sends brownie points to @timurtu :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave timurtu points
Dan
@RetartedZombie
Jan 18 2017 03:55
@Strongolian I just discovered String.repeat() function.
function repeatStringNumTimes(str, num) {
return str.repeat(Math.max(0,num));
}
chuckcarr4
@chuckcarr4
Jan 18 2017 03:56
I'm really getting annoyed with the fact they're asking you to do stuff in problems that was not taught in any example or problem before hand.... :/
Dan
@RetartedZombie
Jan 18 2017 03:57
@chuckcarr4 I guess they're encouraging people to do outside research and perfect those Google search skills ;)
Jan 18 2017 03:57
That's what I'm having to do haha
I was certain I had it right :(
ignore me, I had < and > the wrong way around /facepalm
Margaret
@Margaret2
Jan 18 2017 03:58
@chuckcarr4 yeah, if you're on the algorithms, the point is not to teach you how to do that specific algorithm, but to use logic and research to find the solution to your problem imo
DevRice
@DevRice
Jan 18 2017 03:58
function binaryAgent(str) {
var temp = str.split(' ');
var coded = [];
var translated = [];
for(x=0;x<temp.length;x++){
coded.push(temp[x]/10000000);
}
for(y=0;y<coded.length;y++){
translated.push(String.fromCharCode(coded[y]));
}
return translated.join(' ');
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
Anybody know what I'm doing wrong?
Joe Escobedo
@joeEscob1023
Jan 18 2017 03:58

I dont understand how this works...

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

  product = product * arr[i][j];
}

}

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

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

Timur Uzel
@timurtu
Jan 18 2017 04:01
@DevRice forgot let before the x and y in the for loops
CoryCMyers
@CoryCMyers
Jan 18 2017 04:01
Is there a site that has hints on how to work through the challenges? I keep running into walls and I would rather look at hints and try to muddle through it to possibly gain some comprehension, than just find a complete answer.
DevRice
@DevRice
Jan 18 2017 04:02
@timurtu What do you mean?
Timur Uzel
@timurtu
Jan 18 2017 04:03
for(let x = 0;;) @DevRice
to instantiate it
Margaret
@Margaret2
Jan 18 2017 04:03
@CoryCMyers the forum has both hints and answers
CoryCMyers
@CoryCMyers
Jan 18 2017 04:04
@Margaret2 I have tried to find what I am looking for there, and usually end up lost or not finding it. Am I perhaps looking in the wrong section?
Margaret
@Margaret2
Jan 18 2017 04:04
hmm i will see if i can find it real quick
DevRice
@DevRice
Jan 18 2017 04:05
@timurtu That didn't make a difference
Margaret
@Margaret2
Jan 18 2017 04:07
@CoryCMyers try looking here or searching for "challenge guide" + the name of your challenge
CoryCMyers
@CoryCMyers
Jan 18 2017 04:08
@Margaret2 Thank you
CamperBot
@camperbot
Jan 18 2017 04:08
corycmyers sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1228 | @margaret2 |http://www.freecodecamp.com/margaret2
CoryCMyers
@CoryCMyers
Jan 18 2017 04:09
@Margaret2 I keep feeling silly because I will be thinking through how to do something, then when I take a look at an answer it is a moment of Yeah! I knew that is what I needed but could not remember how to get there. Is it just a matter of repetition once I start to get an idea for how things work?
I know I keep bashing away at my tribute page because I get an idea for it to do X, and I poke it till it does.
Margaret
@Margaret2
Jan 18 2017 04:10
@CoryCMyers yeah, i think the more you practice, the more you will get used to it :smile:
DevRice
@DevRice
Jan 18 2017 04:11
function binaryAgent(str) {
var temp = str.split(' ');
var coded = [];
var translated = [];
for(x=0;x<temp.length;x++){
coded.push(temp[x]/10000000);
}
for(y=0;y<coded.length;y++){
translated.push(String.fromCharCode(coded[y]));
}
return translated.join(' ');
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
Anybody know what I'm doing wrong?
Timur Uzel
@timurtu
Jan 18 2017 04:11
@DevRice true what is the intended result? it prints out empty stings
DevRice
@DevRice
Jan 18 2017 04:11
it should return "Aren't bonfires fun!?"
Timur Uzel
@timurtu
Jan 18 2017 04:15

what’s the first loop for?

function binaryAgent(str) {
return str.split(/\s/)
.map(t => String.fromCharCode(t))
.join(' ')
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");

this prints out chinese characters

DevRice
@DevRice
Jan 18 2017 04:16
Yeah.. It's not supposed to?
Gabriela Bazan
@GabrielaLBazan
Jan 18 2017 04:16
Hi FCC I'm having trouble with the Golf Code challenge if anyone's got a minute
Phil Seidel
@psbyron3
Jan 18 2017 04:16
The map exposes each character in the array, then sets it to its charCode instead of a letter @timurtu
Jan 18 2017 04:16

var myVar = 87;

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

i dont unederstand
increment a Number with javascript
Simon Anatole Orlovsky
@sorlovsky
Jan 18 2017 04:17
Hey all. Why is smallest common multiple of (1, 5) = 60 on the smallest common multiple challenge? I would expect it to be 5
Jan 18 2017 04:17
it says myVar = myVar should be changed
Phil Seidel
@psbyron3
Jan 18 2017 04:17
@GabrielaLBazan yea I can take a look
Jan 18 2017 04:17
i thought i changed it
Phil Seidel
@psbyron3
Jan 18 2017 04:18
@sorlovsky 1 and 5 are the range
Simon Anatole Orlovsky
@sorlovsky
Jan 18 2017 04:18
oh
I see
Phil Seidel
@psbyron3
Jan 18 2017 04:18
meaning that the smallest common mulitple of 1,2,3,4, and 5 is 60
Gabriela Bazan
@GabrielaLBazan
Jan 18 2017 04:18
Thanks @psbyron3
There are two parts that don't seem to work
Phil Seidel
@psbyron3
Jan 18 2017 04:18
multiple*
CamperBot
@camperbot
Jan 18 2017 04:18
gabrielalbazan sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles:
Simon Anatole Orlovsky
@sorlovsky
Jan 18 2017 04:18
Thank you @psbyron3
CamperBot
@camperbot
Jan 18 2017 04:18
sorlovsky sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles:
Gabriela Bazan
@GabrielaLBazan
Jan 18 2017 04:18
I can't get the "Hole in one!" to work
Phil Seidel
@psbyron3
Jan 18 2017 04:18
No worries it took me a second
Gabriela Bazan
@GabrielaLBazan
Jan 18 2017 04:18
here's my code:

function golfScore(par, strokes) {
// Only change code below this line
if (par >= 0 && strokes == 1) {
return "Hole in one!";
} else if (par >= 0 && strokes <= par - 2) {
return "Eagle";
} else if (par >= 0 && strokes == par - 1) {
return "Birdie";
} else if (par >= 0 && strokes == par) {
return "Par";
} else if (par >= 0 && strokes == par + 1) {
return "Bogey";
} else if (par >= 0 && strokes == par + 2) {
return "Double Bogey";
} else if (par >= 0 && strokes >= par + 3) {
return "Go Home!";
} else {

return "Change Me";}
// Only change code above this line
}

// Change these values to test
golfScore(1, 1);

CoryCMyers
@CoryCMyers
Jan 18 2017 04:19

So I am having a bit of problem understanding here, I how this works but I do not understand the why.

for( var i = 0; i < contacts.length; i++ ){
if( firstName == contacts[i].firstName ) {
if( contacts[i].hasOwnProperty( prop ) ) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}
return "No such contact";

I think the part that is confusing me is that it is saying variable i if it is not the value listed in the search to look on to the next one eight which is what the i++ does?

Jan 18 2017 04:19
or not
CoryCMyers
@CoryCMyers
Jan 18 2017 04:19
Or am I understanding incorrectly? I can read it and understand what it is doing, but I am having trouble understanding the why.
Phil Seidel
@psbyron3
Jan 18 2017 04:22
Hmm... it seems to be working on my end @GabrielaLBazan
I know why
It wants "Hole-in-one" You have "Hole in one" without the dashes
@GabrielaLBazan
Gabriela Bazan
@GabrielaLBazan
Jan 18 2017 04:23
ahhhh
thank you!!!
second pair of eyes, I appreciate it @psbyron3
Phil Seidel
@psbyron3
Jan 18 2017 04:23
No problem its the small stuff that always goes unnoticed
John Gibson
@jgibson02
Jan 18 2017 04:24

Hi, I'm working on the Intermediate Algorithms problem "Pig Latin" and I'm having a problem with the first 2 tests, where str.match(...) returns null, even though it should be detecting the vowels in the string.

function translatePigLatin(str) {
console.log(str);
switch (str.charAt(0)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
return str + "way";
default:
console.log(str.match('/(a|e|i|o|u)/g'));
var idxFirstVwl = str.indexOf(str.match('/a|e|i|o|u/g'));
console.log(idxFirstVwl);
return str.substr(idxFirstVwl) + str.substr(0, idxFirstVwl) + "ay";
}
}

translatePigLatin("california");

translatePigLatin("california") returns "iforniacalay" and translatePigLatin("paragraphs") returns "say"

Gabriela Bazan
@GabrielaLBazan
Jan 18 2017 04:25
@psbyron3 I'm losing my testing skills... thanks again!
CamperBot
@camperbot
Jan 18 2017 04:25
gabrielalbazan sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles:
:warning: gabrielalbazan already gave psbyron3 points
Jan 18 2017 04:25
I'm getting scared now, I've blitzed through about 60 missions today and soon i'll be at the app development ones, hopefully I've retained enough information and understanding haha
Phil Seidel
@psbyron3
Jan 18 2017 04:26
@CoryCMyers Is your question what is going on in the for loop?
Brian
@BrianCodes33
Jan 18 2017 04:26
@AdamWayne-dev yea i did the same, once it gets harder its important to take your time and understand everything
Gabriela Bazan
@GabrielaLBazan
Jan 18 2017 04:26
congrats @AdamWayne-dev stoked for you! can't wait to get there... just remember how far you've come! You can do it!
Jan 18 2017 04:27
@GabrielaLBazan Thank you! I'm pretty excited to start it all. I only started this about 3 days ago and I've just passed the 200 mark
CamperBot
@camperbot
Jan 18 2017 04:27
adamwayne-dev sends brownie points to @gabrielalbazan :sparkles: :thumbsup: :sparkles:
Jan 18 2017 04:28
@BrianCodes33 Haha yeah I'm starting to understand that, but so far I feel quite confident. I knew a little C# before starting this so It's not all too unfamiliar territory
CoryCMyers
@CoryCMyers
Jan 18 2017 04:28
@psbyron3 No, I can read the loop, I just cannot get my head around the why. I am just struggling with the javascript portion, and when I look at something I get it and it makes sense, but I cannot reliably get my head around the why it works as it does, and how to be able to reliably recall what I need for challenges so I can improve.
Phil Seidel
@psbyron3
Jan 18 2017 04:30

@CoryCMyers So the loop does three things, where to start, where to stop, and how to get there. A very normal for loop starts at 0; ends at 1 less than the length of the array; and iterates by one (i++). You could also say i += 1 or i = i + 1, but these are redundant and it is more common practice to code the ++ instead.

The reason we iterate by one at a time, is that the logic inside the for loop is dumb

It goes to every single element and it asks it the same question
arr[0] are you firstName Joe? No, okay arr[1] are you first name Joe? No, okay arr[2].....
and so on and so on.
Brian
@BrianCodes33
Jan 18 2017 04:31
@AdamWayne-dev that’s good i never learned C# or C just Javascript.
CoryCMyers
@CoryCMyers
Jan 18 2017 04:32
@psbyron3 That makes sense, just feeling a bit frustrated cause the HTML and CSS stuff made sense, then this is like pounding my head against a brick wall/
Phil Seidel
@psbyron3
Jan 18 2017 04:32
The reason we do for loops this way is we often don't know the exact location of the data and we have to ask every element. Or iterate over the array/collection
Javascript takes a while, especially if it is your first programming language.. You also get the instant gratification of seeing HTML and CSS by reloading the page
But you can'y necessarily see your js code
Brian
@BrianCodes33
Jan 18 2017 04:33
pythontutor.com has a good call stack
where you can visualize execution
John Nunns
@johnnunns
Jan 18 2017 04:34

Anyone who's familiar with reduce want to take a look at this with me?

var arr = [
[
['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
],
[
['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
]
]

arr.reduce(function(a,b){a[b[0][0]]=b[0][1]; return a},{})

what this is returning is only {firstName: Mary}, where I want it to return every property listed in the array in object format
I feel like I have to be close

Phil Seidel
@psbyron3
Jan 18 2017 04:34
Right on
I love a good visualization
Jan 18 2017 04:34
@BrianCodes33 It's not too dissimilar really, same concepts and rules almost, just a little different on the syntax
CoryCMyers
@CoryCMyers
Jan 18 2017 04:34
That it is, I just started this on new years as my resolution and am trying to be sure i spend a few hours on it each day. I was able to muddle my way through tweaking a few jQuery things for my tribute page my pokinmg it and reloading but anything more than that just gets confusing.
John Nunns
@johnnunns
Jan 18 2017 04:34
I've worked with manish and revisualize but I'm trying to understand further
kez
@keztheminer
Jan 18 2017 04:34
@psbyron3 i private messaged you need a little help
Brian
@BrianCodes33
Jan 18 2017 04:34
i found the syntax more dense in C and C++.
Timur Uzel
@timurtu
Jan 18 2017 04:35
@johnnunns all as a part of one object? but some property names are the same
CoryCMyers
@CoryCMyers
Jan 18 2017 04:35
I am a very visual and somatic learner, so that may be one reason I am struggling with Javascript
John Nunns
@johnnunns
Jan 18 2017 04:35
I'll copy the problem @timurtu
Phil Seidel
@psbyron3
Jan 18 2017 04:36
@johnnunns It would make a lot more sense to store this data as an object. Is there a reason you need to store it in an array like this??
John Nunns
@johnnunns
Jan 18 2017 04:36
Write a function called "transformEmployeeData" that transforms some employee data from one format to another.

The argument will look something like this:
[
[
['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
],
[
['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
]
]

Given that input, the return value should look like this:
[
{firstName: 'Joe', lastName: 'Blow', age: 42, role: 'clerk'},
{firstName: 'Mary', lastName: 'Jenkins', age: 36, role: 'manager'}
]

Note that the input may have a different number of rows or different keys than the given sample.

For example, let's say the HR department adds a "tshirtSize" field to each employee record. Your code should flexibly accommodate that.

Starter Code :
function transformEmployeeData(array) {
}
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:36
I really need help on the nesting for loops lesson.. i have it complete, but i have no idea what the code is doing to give me that answer..
Timur Uzel
@timurtu
Jan 18 2017 04:36
ohh okay an array of objects
CoryCMyers
@CoryCMyers
Jan 18 2017 04:36
If I go to pythontutor.com which java option do I want to click?
John Nunns
@johnnunns
Jan 18 2017 04:36
@psbyron3 @timurtu the idea is to change an array to object
Phil Seidel
@psbyron3
Jan 18 2017 04:38
Okay cool
John Nunns
@johnnunns
Jan 18 2017 04:39
interesting, @timurtu . Ok so would I just write that separate to the reduce function?
and concat each property?
Jan 18 2017 04:39
@jgibson02 - did you get help with your Pig Latin code? I couldn't tell looking through the chat replies while I was experimenting
kez
@keztheminer
Jan 18 2017 04:39
@psbyron3 Thanks you're a pro :)
CamperBot
@camperbot
Jan 18 2017 04:39
kezdarkriser sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles:
John Gibson
@jgibson02
Jan 18 2017 04:39
Jan 18 2017 04:41
@jgibson02 - it's a little strange.... it seems that the regular expression that you have /a|e|i|o|u/ doesn't necessarily match the first vowel that it sees - I was trying to see if they described that in the regular expression documentation.
Ogundele Olumide
@Lumexralph
Jan 18 2017 04:41
@TacoJoe when you loop through an array, you're trying to access each element in an array which each element in that array is also an array, to reach the elements in that inner array, you also have to create another loop that will access the inner array elements at every iteration of the outer loop
Marc M
@Marc-Moeller
Jan 18 2017 04:42
Hello people, I'm just wondering if this data here in the screenshot is JSON format and how to access 'city' for example. http://prnt.sc/dx1x98
Ha Nguyen
@uxsasukexnaruto
Jan 18 2017 04:43

function rot13(str) { // LBH QVQ VG!
var sep = str.split(' '); //["SERR", "PBQR", "PNZC"]
var sepSplit = [];
var charCode = [];

for (i = 0; i < sep.length; i++) {
//sep ==> ["SERR", "PBQR", "PNZC"]
sepSplit.push(sep[i].split(''));
//sepSplit ==> [["S","E","R","R"], ["P","B","Q","R"], ["P","N","Z","C"]]

for (j = 0; j < sepSplit.length; j++) {
charCode.push(sep[i].charCodeAt([j]));
//expected: [83, 80, 66, ....]

//output: [83, 80, 66, 80, 78, 90]
//        [S,  P,  B,  P,  N,  Z ]
}

}

It doesn't return the whole thing

haivuong14
@haivuong14
Jan 18 2017 04:43
Stuck on "Escape Sequences in Strings"! Can anyone help?
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:43
@Lumexralph im still confused...like i dont know what is going on it here..
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
haivuong14
@haivuong14
Jan 18 2017 04:43
'var myStr = "FirstLine \n \SecondLine\ \r ThirdLine";
Timur Uzel
@timurtu
Jan 18 2017 04:43
@johnnunns yeah there’s a bunch of ways to tackle this honestly you’ll want to use concat to flatten the arrays then I would probably use Object.assign to compose the objects rather than using reduce twice
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:44
is j < arr[i].length saying that j is smaller than multiplyAll([[1,2],[3,4],[5,6,7]]);
Phil Seidel
@psbyron3
Jan 18 2017 04:44

@johnnunns One thing to keep in mind about this challenge is that it wants you to take tupels of an array and make them tupels of an object. A tupel is a two element piece of data (age, 26) (name, Phil) etc.

Is it telling you to use reduce here?

Jan 18 2017 04:45
@jgibson02 - they are not too specific about that - for the | operator, they describe it as: x|y -Matches either x or y. It doesn't say "whichever comes first". Not sure if that is implied or not implied. But it seems to regularly match the "i". I changed your expression to be /[aeiou]/ so that it will match one character in that group. Then I had to do something else, because of what str.match will return.
Phil Seidel
@psbyron3
Jan 18 2017 04:45
@TacoJoe Are you referring to that "j <" line in the for loop?
Ogundele Olumide
@Lumexralph
Jan 18 2017 04:45
@haivuong14 eliminate any space#
Marc M
@Marc-Moeller
Jan 18 2017 04:45
Is this data JSON format and how do I access 'city' for example. http://prnt.sc/dx1x98
Timur Uzel
@timurtu
Jan 18 2017 04:45
the ES6 Spread operator would also come in handy here idk if you’re using ES6
flatten the arrays, spread over them in new objects
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:46
@psbyron3 well both of the for loops. the problem is nothing like the example they show so im so confused on what is going on
Phil Seidel
@psbyron3
Jan 18 2017 04:46
It means that loop is going to iterate up to one less then arr[i].length.. This is still the last element because arrays start their count at 0
John Nunns
@johnnunns
Jan 18 2017 04:46
I just used reduce because the for loop seemed complicated. And keep in mind I'm pretty new to coding :) @timurtu @psbyron3
Phil Seidel
@psbyron3
Jan 18 2017 04:46
and length starts at 1
M.Sohaib
@coolcoder007
Jan 18 2017 04:46

var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

how to solve this challange
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:47
@psbyron3 heres the full code..

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

  product = product * arr[i][j];
}

}

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

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

John Nunns
@johnnunns
Jan 18 2017 04:47
real quick. can you tell me why this returns undefined :
var array = [
[
['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
],
[
['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
]
]
function transformEmployeeData(array){

array.reduce(function(a,b){a[b[0][0]]=b[0][1]; return a},{})
}

transformEmployeeData(array)
THalletProtech
@THalletProtech
Jan 18 2017 04:47
hey everyone I have a question. if you have already called the $(document).ready(); and you load(); more content to the div how can you do more jquery to the newly loaded elements. Ogundele Olumide @Lumexralph Jan 18 2017 04:47 @TacoJoe the first loop is to iterate through the outer array, the second loop, is looping through each inner array, arr[i].length is the length of the inner array at every iteration of the outer loop John Nunns @johnnunns Jan 18 2017 04:47 I just wanted it to be the function they listed to use and not sure why this isn't returning anything at this point Phil Seidel @psbyron3 Jan 18 2017 04:47 @johnnunns I think you are going one layer too deep. I don't think 0 of 0 of b exists Timur Uzel @timurtu Jan 18 2017 04:48 @johnnunns reduce is an amazing function but honestly there are better times to use it, but it also depends how you use it because you could even compose an array of two Objects with it the code might be a little weird Ogundele Olumide @Lumexralph Jan 18 2017 04:48 @coolcoder007 you have idea of how to concatenate strings, right? Phil Seidel @psbyron3 Jan 18 2017 04:48 You should console.log(b[0][0]) within your reduce function M.Sohaib @coolcoder007 Jan 18 2017 04:48 @Lumexralph yeah Ogundele Olumide @Lumexralph Jan 18 2017 04:48 @THalletProtech yes John Gibson @jgibson02 Jan 18 2017 04:49 @khaduch If it helps, I've been using this website to test the regex: http://regexr.com/ And in both the original regex and "/[aeiou]" they both correctly highlight on the vowels in the test strings, so str.match for that regex should at least return a non-null object John Nunns @johnnunns Jan 18 2017 04:49 It seemed to have worked before I put it in the function above. It returned firstName: Mary Joe Escobedo @joeEscob1023 Jan 18 2017 04:49 so the first loop is just adding 1 until it gets to the .length of arr? John Nunns @johnnunns Jan 18 2017 04:49 @timurtu which direction would you go? Ogundele Olumide @Lumexralph Jan 18 2017 04:49 @coolcoder007 your functions have parameters? right holding the strings, right? THalletProtech @THalletProtech Jan 18 2017 04:49 @Lumexralph what do you mean yes? Timur Uzel @timurtu Jan 18 2017 04:49 @TacoJoe this is a good place to use reduce Ogundele Olumide @Lumexralph Jan 18 2017 04:50 @TacoJoe no it doesn't, the first loop is picking each array Phil Seidel @psbyron3 Jan 18 2017 04:50 @TacoJoe No the reason you are using two for loops is because the array you are accessing is a 2-Dimensional array. Meaning that it is an array of arrays John Nunns @johnnunns Jan 18 2017 04:50 yeah even when i change it @psbyron3 to your recommendation it still returns undefined Phil Seidel @psbyron3 Jan 18 2017 04:50 So in order to access the inner arrays, you would need a second iterator, or a second for loop @johnnunns I haven't messed around with your code yet Gonna check it out now Ogundele Olumide @Lumexralph Jan 18 2017 04:51 @coolcoder007 myNoun etc.... concatenate them using + operator separating them with space " " and assign it to result M.Sohaib @coolcoder007 Jan 18 2017 04:51 @Lumexralph i want to know to which i have to concatenate ? do you have code THalletProtech @THalletProtech Jan 18 2017 04:51 @Lumexralph I think you have me confused with someone Joe Escobedo @joeEscob1023 Jan 18 2017 04:51 @psbyron3 so the second for loop is just going inside of the first one and printing out a number? Ogundele Olumide @Lumexralph Jan 18 2017 04:52 @THalletProtech sorry, just saw Joe Escobedo @joeEscob1023 Jan 18 2017 04:52 which when i do this. it equals one John Nunns @johnnunns Jan 18 2017 04:52 @psbyron3 thanks, you'll notice it runs, not correctly, but runs when it's just the reduce method but when I attempt to place it in a function it returns undefined CamperBot @camperbot Jan 18 2017 04:52 johnnunns sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles: :cookie: 46 | @psbyron3 |http://www.freecodecamp.com/psbyron3 Phil Seidel @psbyron3 Jan 18 2017 04:52 @johnnunns You are not returning anything from your transferEmployee function Joe Escobedo @joeEscob1023 Jan 18 2017 04:52 then i use product = product * arr[i][j]; and it give mes 5040 Phil Seidel @psbyron3 Jan 18 2017 04:52 you only return something from the inner reduce function John Nunns @johnnunns Jan 18 2017 04:53 does it not just run the reduce inside and then return? Ogundele Olumide @Lumexralph Jan 18 2017 04:53 @TacoJoe let's break it down a lil with an example Joe Escobedo @joeEscob1023 Jan 18 2017 04:53 @Lumexralph please do Phil Seidel @psbyron3 Jan 18 2017 04:53 Your reduce is a function inside of another function @johnnunns In order to return a value from it you would also need to return a value from the outer function. Ogundele Olumide @Lumexralph Jan 18 2017 04:54 @coolcoder007 the parameters THalletProtech @THalletProtech Jan 18 2017 04:54 hey everyone I have a question. if you have already called the$(document).ready(); and you load(); more content to the div how can you do more jquery to the newly loaded elements.
John Nunns
@johnnunns
Jan 18 2017 04:54
so how do I access that function and return it's value?
Phil Seidel
@psbyron3
Jan 18 2017 04:54
Functions work as a stack.. Are you familiar with Stack data structures yet? @johnnunns
John Nunns
@johnnunns
Jan 18 2017 04:54
not yet no. This is kind of an advanced problem they threw me in
Jan 18 2017 04:54

@jgibson02 - here's the thing that I'm seeing - this line of code: console.log(str.match(/[aeiou]/)); (note that I removed the quotes from around the expression) gives this output:

["a", index: 1, input: "california"]

So to actually make your code run, I made this change to the line:
var idxFirstVwl = str.indexOf(str.match(/[aeiou]/)[0][0]); and all tests pass. Note that .match() is returning an array of information, so the [0][0] is accessing the first element, which is the character that matched. I could probably use the .index and get the same result.

Ogundele Olumide
@Lumexralph
Jan 18 2017 04:54
@TacoJoe
var arr = [[1, 3, 5]];
M.Sohaib
@coolcoder007
Jan 18 2017 04:54
@Lumexralph ok let me try
Ogundele Olumide
@Lumexralph
Jan 18 2017 04:55
@TacoJoe what's arr?
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:55
[[1, 3, 5]]
@Lumexralph
Ogundele Olumide
@Lumexralph
Jan 18 2017 04:56
@coolcoder007 make sure you separate them with space " "
@TacoJoe what kind of array?
Phil Seidel
@psbyron3
Jan 18 2017 04:56
Well you called a function called transformEmployeeData. Inside that function you called a reduce function. You have returned the value out of reduce back into transformEmployeeData. But you don't do anything with that data from there. The rest of the function runs, and then hops out with nothing, thus the undefined
If you don't return a value out of a function you get undefined @johnnunns
Jan 18 2017 04:56
@jgibson02 - yes, this is actually more efficient: var idxFirstVwl = str.match(/[aeiou]/).index;
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:57
@Lumexralph mulit-dimensional array
multi*
John Gibson
@jgibson02
Jan 18 2017 04:57
@khaduch thank you! I wonder why it was logging it as null...
CamperBot
@camperbot
Jan 18 2017 04:57
jgibson02 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Jan 18 2017 04:57
@TacoJoe if you have an array var a = [1, 3, 5, 6] how will you get every element in a ?
John Nunns
@johnnunns
Jan 18 2017 04:57
makes sense @psbyron3 . I think I'm understanding but I'm not exactly sure how to return the value isnide the reduce function though
can I simply retype return a again?
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:58
@Lumexralph a = [0][0];
Phil Seidel
@psbyron3
Jan 18 2017 04:58
you already have returned the value out of reduce
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:58
wait
Phil Seidel
@psbyron3
Jan 18 2017 04:58
now return the value from transformEmployeeData
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:58
a = 0;
Ogundele Olumide
@Lumexralph
Jan 18 2017 04:58
@TacoJoe look at it closely
Joe Escobedo
@joeEscob1023
Jan 18 2017 04:58
@Lumexralph a = 0;
@Lumexralph a = [0];
THalletProtech
@THalletProtech
Jan 18 2017 04:59
i have
$("input#address").keyup(function(){ var newAddress =$("input#address").val();
$("#container").load(newUrl); }); John Nunns @johnnunns Jan 18 2017 04:59 function transformEmployeeData(array){ var result = array.reduce(function(a,b){a[b[0][0]]=b[0][1]; return a},{}) return result } transformEmployeeData(array) that worked Phil Seidel @psbyron3 Jan 18 2017 04:59 @johnnunns perfect Ogundele Olumide @Lumexralph Jan 18 2017 04:59 @TacoJoe no, you want to get access or print every element in the array how will a = [0] do that? Phil Seidel @psbyron3 Jan 18 2017 04:59 You can do that Edgar Pan @edgaryp Jan 18 2017 04:59 Hi, I try to use $.output.html("");(JS line 20) to delete previous API contents, but it seems affected the next function of new API contents. Does anybody know the reasons?
http://codepen.io/edgaryp/pen/qRapvW?editors=1011
THalletProtech
@THalletProtech
Jan 18 2017 04:59
how can i do an event to the newly loaded elements
Phil Seidel
@psbyron3
Jan 18 2017 05:00
You also can just return arr.reduce.... @johnnunns The extra results variable isn't necessary.
John Nunns
@johnnunns
Jan 18 2017 05:00
aha..
good call!
ok, so back to base one :)
I'm still currently returning firstName: Mary
and that's it
Phil Seidel
@psbyron3
Jan 18 2017 05:01
You only need to declare and use variables within functions if they need to hold certain values or will be changing as you go, such as a sum variable @johnnunns
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:01
@Lumexralph i forgot... :l
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:01
@TacoJoe you use a loop
Phil Seidel
@psbyron3
Jan 18 2017 05:01
Okay, So now your reduce function isn't doing everything you want it to @johnnunns What's this challenge called btw? I'd like to take a look at it directly
John Nunns
@johnnunns
Jan 18 2017 05:02
Array to Object
it's a prep course for a school that I plan to attend
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:03
@Lumexralph so for (var i = 1; 1 < a; i++);
John Nunns
@johnnunns
Jan 18 2017 05:03
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:03

@TacoJoe

var a = [1, 3, 5, 6];
for(var i = 0; i < a.length; i++) {
console.log( a[i] )
}

understand this loop, what will it do?

Joe Escobedo
@joeEscob1023
Jan 18 2017 05:04
print 1 2 5 6
John Nunns
@johnnunns
Jan 18 2017 05:04
@psbyron3 that's just the background info, the problem that you may not have access to states the instructions:
Module 0 Wiki: https://github.com/tim-hr/reactor-prep/wiki/Module-0

Write a function called "transformEmployeeData" that transforms some employee data from one format to another.

The argument will look something like this:
[
[
['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
],
[
['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
]
]

Given that input, the return value should look like this:
[
{firstName: 'Joe', lastName: 'Blow', age: 42, role: 'clerk'},
{firstName: 'Mary', lastName: 'Jenkins', age: 36, role: 'manager'}
]

Note that the input may have a different number of rows or different keys than the given sample.

For example, let's say the HR department adds a "tshirtSize" field to each employee record. Your code should flexibly accommodate that.

Starter Code :
function transformEmployeeData(array) {
}
Phil Seidel
@psbyron3
Jan 18 2017 05:05
Is this to get into Hack Reactor??
@johnnunns
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:05
@TacoJoe you mean 1, 3, 5, 6.... how do you arrive at that?
John Nunns
@johnnunns
Jan 18 2017 05:05
prep course for HackReactor. Open book test if you will
kez
@keztheminer
Jan 18 2017 05:06
@Lumexralph would add 15 to end of array ?
Phil Seidel
@psbyron3
Jan 18 2017 05:06
Nice! is it precourse? Have you already been accepted or is this to prepare for the interview?
M.Sohaib
@coolcoder007
Jan 18 2017 05:06

var result = "";
// Your code below this line

wordBlanks("cat", "little", "hit", "slowly");
// Your code above this line
return result;
}

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

John Nunns
@johnnunns
Jan 18 2017 05:06
yeah a free pre course which will have you ready for the interview
M.Sohaib
@coolcoder007
Jan 18 2017 05:06
help neededd
CamperBot
@camperbot
Jan 18 2017 05:06
no wiki entry for: neededd
heroiczero
@heroiczero
Jan 18 2017 05:06
@coolcoder007 gotta use result to make a string with all those variables
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:07
@Lumexralph by console.log(a[i]);
Phil Seidel
@psbyron3
Jan 18 2017 05:07
nice I did Hack Reactor this summer... @johnnunns My cohort was HRLA08
John Nunns
@johnnunns
Jan 18 2017 05:07
They stated you should be able to solve the problems if you've done the codeacad course but that's bs. This is a much higher level of coding and only question 1 :) haha
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:07
@coolcoder007 join your parameters with +
Phil Seidel
@psbyron3
Jan 18 2017 05:07
Oh yea it is... That was a tough step going from codecademy to being ready for the interview
John Nunns
@johnnunns
Jan 18 2017 05:07
awesome man! @psbyron3 I'm presuming it means you were in the LA location?
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:07
@coolcoder007 wordBlanks("cat", "little", "hit", "slowly"); what are you trying to do by doing this?
Phil Seidel
@psbyron3
Jan 18 2017 05:08
yessir
John Nunns
@johnnunns
Jan 18 2017 05:08
same! I live in Torrance and plan on attending asap
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:08
@TacoJoe exactly, you access an array like this right Arrray[index] ?
M.Sohaib
@coolcoder007
Jan 18 2017 05:08
@Lumexralph i,m so confused what i have to made
John Nunns
@johnnunns
Jan 18 2017 05:09
I can already apply as I can write the code that accepts my application, but I'd like to do everything possible to make sure I'm as ready as I can be
Phil Seidel
@psbyron3
Jan 18 2017 05:09
Nice man, well it's a great program, you will learn a shit-ton of information. @johnnunns
Edgar Pan
@edgaryp
Jan 18 2017 05:09
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:09
@Lumexralph yes. and index would be [i]
M.Sohaib
@coolcoder007
Jan 18 2017 05:09
words Blanks
John Nunns
@johnnunns
Jan 18 2017 05:09
I'm just excited to have a valuable tangible school. I'm done being a businessman :)
Phil Seidel
@psbyron3
Jan 18 2017 05:09
Yea the interview can definitely be challenging. I didn't get in on my first try
John Nunns
@johnnunns
Jan 18 2017 05:09
skill**
CoryCMyers
@CoryCMyers
Jan 18 2017 05:10
Is there an average amount of time it takes to stop overthinking the Java stuff and jsut occams it?
John Nunns
@johnnunns
Jan 18 2017 05:10
Yeah I got a bit nervous when I read the stories of people not getting in so I'm trying to over prepare
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:10
@TacoJoe when i is 0, it's a[0] which is 1 , when i is 1 it's a1 which is 3, when i is 2 it's a[2] which is 5...that's why you need a loop
John Nunns
@johnnunns
Jan 18 2017 05:10
Got a bit nervous when i realized I can't solve the first problem too hahaha
CoryCMyers
@CoryCMyers
Jan 18 2017 05:10
Because I just spent twenty minutes trying to write out an answer, when all I had to do was edit the return line on this challenge.
Phil Seidel
@psbyron3
Jan 18 2017 05:11
That's the best practice.. I think the best prep for the interview is to practice toy problems.. sites like leetcode and hackerrank are good resources for that
John Nunns
@johnnunns
Jan 18 2017 05:11
I'll save those now
M.Sohaib
@coolcoder007
Jan 18 2017 05:11
@edgaryp i think i need to review the code.
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:11
@Lumexralph so the loop will display all the numbers?
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:11
@coolcoder007 myNoun + " " + myAdjective........ assign it to result using the 4 parameters of your function
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:12
so in an inner loop, is it just displaying all the numbers again?
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:12
@TacoJoe exactly, remember every element in that array is a number? right?
Edgar Pan
@edgaryp
Jan 18 2017 05:12
@coolcoder007 the task is asking you to use function wordBlanks' parameters in the sentence and signed to the variable result.
John Nunns
@johnnunns
Jan 18 2017 05:12
a friend of mine recommended codewars but man they through some very tough problems without any help. At the same time I discovered the prep course so I've just been trying this out
Jan 18 2017 05:12
Just out of interest guys, has anyone completed the freeCodeCamp course here?
John Nunns
@johnnunns
Jan 18 2017 05:12
threw*
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:13
@TacoJoe now look at this example
var a = [ [1, 2], [3, 4]];
Phil Seidel
@psbyron3
Jan 18 2017 05:13

@johnnunns Yea it can be daunting at first.. But you'll want to stick with it.. I think the best prep for toy problems (it'll seem cyclical) but understanding JS fundamentals.

In knowing the fundamentals, you will gain more and more tools. Then you can have a better idea of how to approach a toy problem.

Ogundele Olumide
@Lumexralph
Jan 18 2017 05:14
@TacoJoe can you see the array is a bit different now?
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:14
@Lumexralph yes
Edgar Pan
@edgaryp
Jan 18 2017 05:15

anybody?

Hi, I try to use $.output.html("");(JS line 20) to delete previous API contents, but it seems affected the next function of new API contents, as it only prints out the 1st result. Does anybody know the reasons? http://codepen.io/edgaryp/pen/qRapvW?editors=1011 Phil Seidel @psbyron3 Jan 18 2017 05:15 @johnnunns eloquent javascript, you don't know JS by Kyle Simpson is a great resource. It is free on his github (@getify). It is terse, but you just need to read it over and over. Then you need to apply what you learned to toy problems. John Nunns @johnnunns Jan 18 2017 05:15 in module1 they actually review the fundamentals, which I find odd that they wouldn't do that first tbh Ogundele Olumide @Lumexralph Jan 18 2017 05:16 @TacoJoe i want to print 1, 2, 3, 4, if i use just a loop let's see what that will get.... var a = [ [1, 2], [3, 4] ]; for(var i = 0; i < a.length; i++) { console.log( a[i] ) } what will be printed out? John Nunns @johnnunns Jan 18 2017 05:17 saved it @psbyron3 Ogundele Olumide @Lumexralph Jan 18 2017 05:17 @johnnunns codewars is fun but yes, tough challenges Joe Escobedo @joeEscob1023 Jan 18 2017 05:17 @Lumexralph [1,2] [3,4] is that because of the a.length? John Nunns @johnnunns Jan 18 2017 05:17 tell me do you recommend that I drop what I'm doing currently and go that route? Or continue trying to slve this problem? @psbyron3 @Lumexralph wasn't even fun :) haha. Hopefully soon it will be though! Jamil Akhtar @frontender007 Jan 18 2017 05:18 Hello World CamperBot @camperbot Jan 18 2017 05:18 ## welcome to FreeCodeCamp @frontender007! Ogundele Olumide @Lumexralph Jan 18 2017 05:18 @TacoJoe cool, it's because we're looping through the first array @johnnunns it's a mix of both :smile: Phil Seidel @psbyron3 Jan 18 2017 05:19 @johnnunns keep working on what you're doing.. especially if it was recommended by an HR rep John Nunns @johnnunns Jan 18 2017 05:19 they've framed this as the resource that all alumni wish they had before they applied @psbyron3 Jamil Akhtar @frontender007 Jan 18 2017 05:19 anybody got a rough idea about how to generate Fibonacci Sequence? Joe Escobedo @joeEscob1023 Jan 18 2017 05:19 @Lumexralph ok..so the first array give me [1,2][3,4] what about a second one? John Nunns @johnnunns Jan 18 2017 05:19 they also offer help through the course for$795 :) . Not sure if that's the play making the first question this difficult haha @psbyron3
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:20
@frontender007 1 + 1 = 2, 2 + 1 = 3, 3 +2 = 5, 5+3 = 8...........
heroiczero
@heroiczero
Jan 18 2017 05:20
@frontender007 current number + previous Number = final Number
Phil Seidel
@psbyron3
Jan 18 2017 05:20
They may have changed the coding interviews since I took mine and now their more interested in that kind of stuff.. @johnnunns who knows.
The prep course is cool because they will apply all that money towards your tuition @johnnunns
So there's no real downside to doing it if you are committed to HackReactor
John Nunns
@johnnunns
Jan 18 2017 05:20
what! I totally missed that
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:21
@TacoJoe the first loop gave you that, not the first array
Jamil Akhtar
@frontender007
Jan 18 2017 05:21
@Lumexralph @heroiczero have that in mind but how come you get first two as 1 1 ?
John Nunns
@johnnunns
Jan 18 2017 05:21
Had no idea. Now a big possibility, only problem is that it's currently full haha @psbyron3
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:21
oops yeah thats what i meant. and does it only do that because there is a .length?
Phil Seidel
@psbyron3
Jan 18 2017 05:21
Yea, that was the policy when I was there. Get in touch with someone and double check @johnnunns but I think that still is how it works
John Nunns
@johnnunns
Jan 18 2017 05:21
Ok so in the mean time, I'm returning a result in the format I wish, but not for the full array. Where should I look to from here?
heroiczero
@heroiczero
Jan 18 2017 05:22
@frontender007 https://en.wikipedia.org/wiki/Fibonacci_number check this out
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:22
@frontender007 how else do you think I can get 2 if i don't do that? to get 3 ?
Phil Seidel
@psbyron3
Jan 18 2017 05:22
I know one of the prep course instructors
I'll get in touch
John Nunns
@johnnunns
Jan 18 2017 05:22
That is awesome man I really appreciate that
Jamil Akhtar
@frontender007
Jan 18 2017 05:23
@Lumexralph how to do you code that ?
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:23
@TacoJoe it does that because your loop is on the outer array,
heroiczero
@heroiczero
Jan 18 2017 05:24
@frontender007 try using loops
CoryCMyers
@CoryCMyers
Jan 18 2017 05:24

What am I missing here or doing wrong?


// Example
function ourRandomRange(ourMin, ourMax) {

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

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

return Math.floor(Math.random() * ( myMax - myMin + 1)) + 5;

}

// Change these values to test your function
var myRandom = randomRange(5, 15);

so I used Math.floor to tell it to round down, and Math.random to tell it I want a random number. Multiplication to raise it to the realm of a whole number. I set myMax minus myMin plus One to offset rounding down yes and then added my minimum back in after everything else to put me within the minimum range of the operation yes?

Ogundele Olumide
@Lumexralph
Jan 18 2017 05:24
@TacoJoe a.length is just for conditions of your loop
CoryCMyers
@CoryCMyers
Jan 18 2017 05:24
I am being told that randomRange needs to use both myMax and myMin and return a random number in my range.
Jamil Akhtar
@frontender007
Jan 18 2017 05:25
@heroiczero I've got headache been trying for a long time , can't get it work
Phil Seidel
@psbyron3
Jan 18 2017 05:25
@johnnunns As for the problem at hand ill give you the pseudocode for what your trying to do:
heroiczero
@heroiczero
Jan 18 2017 05:25
Michael J Kusdya
@michael-kusdya
Jan 18 2017 05:25
hello, this is my code for the "Sum All Odd Fibonacci Numbers" challenge but its not working, can anyone tell me what's wrong with this code ?
function sumFibs(num) {
var fib = [];
var sum = 0;
fib[0] = 0;
fib[1] = 1;

for(var i=2; i<=num; i++){
fib[i] = fib[i-2] + fib[i -1];
if(fib[i] % 2 !== 0){
sum += fib[i];
}
}
return sum;
}
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:26
@Lumexralph im still extremely lost..I saw how we got the first loop to get [1,2][3,4] but I am still completely lost on understanding the full thing..
Jamil Akhtar
@frontender007
Jan 18 2017 05:26
@heroiczero 
function Fibs(num) {
var fabionacci = [];
for ( var i = 1; i < num; i++ ) {
fabionacci.push(i, i+=i);
}

return fabionacci;
}

Fibs(4);
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:29
@TacoJoe do you understand how a loop works?
@TacoJoe what exactly is causing the confusion?
Rebecca Vest
@idahogurl
Jan 18 2017 05:29
Is someone available to help me with the pairwise challenge
heroiczero
@heroiczero
Jan 18 2017 05:29
@frontender007 finalNumber=currentNumber+previousNumber should be in your code somewhere right now you are just adding i and not storing it anywhere and you need to sum all odd numbers of fib
Joseph
@revisualize
Jan 18 2017 05:30
@johnnunns My code didn't work?
SBilaal
@SBilaal
Jan 18 2017 05:30
someone help. how do i split a sentence in to an array of words
John Nunns
@johnnunns
Jan 18 2017 05:30
@revisualize half of it did. I didn't see you online so I didn't get a chance to talk it through with you
I wanted to learn
CoryCMyers
@CoryCMyers
Jan 18 2017 05:30
Rebecca Vest
@idahogurl
Jan 18 2017 05:31
@SBilaal Lets say your variable is named a
Joe Escobedo
@joeEscob1023
Jan 18 2017 05:31
@Lumexralph i kind of do. when i write them out, i seem to understand them, but i think i need more practice with them. The entire nesting of the loops has just go me lost. Like the entire section really. Some of it was a breeze to go by and now im just stuck and havent retained what did earlier..
Rebecca Vest
@idahogurl
Jan 18 2017 05:31
then you would do
a.split(" ")
SBilaal
@SBilaal
Jan 18 2017 05:31
ok... @idahogurl
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:31
@SBilaal string.split(" ")
SBilaal
@SBilaal
Jan 18 2017 05:31
thanks @idahogurl
CamperBot
@camperbot
Jan 18 2017 05:31
sbilaal sends brownie points to @idahogurl :sparkles: :thumbsup: :sparkles:
Edgar Pan
@edgaryp
Jan 18 2017 05:32
@CoryCMyers use the function randomRange' parameter instead of 5 in your formula
Dan
@RetartedZombie
Jan 18 2017 05:32
@CoryCMyers This worked for me:
function randomRange(myMin, myMax) {

return Math.floor(Math.random() * (myMax - myMin + 1) + myMin);

}
SBilaal
@SBilaal
Jan 18 2017 05:32
thanks @Lumexralph
CamperBot
@camperbot
Jan 18 2017 05:32
sbilaal sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jan 18 2017 05:32
@johnnunns I did only spend about 25 min coding up my solution.
Rebecca Vest
@idahogurl
Jan 18 2017 05:32
@Lumexralph you can't name your variable string.
It is a reserved word
Jamil Akhtar
@frontender007
Jan 18 2017 05:32
@heroiczero ok gonna try again
John Nunns
@johnnunns
Jan 18 2017 05:32
@revisualize what do you mean by that?
Jamil Akhtar
@frontender007
Jan 18 2017 05:32
@heroiczero thanks
CamperBot
@camperbot
Jan 18 2017 05:32
frontender007 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:33
@TacoJoe maybe you should do that
Edgar Pan
@edgaryp
Jan 18 2017 05:33
@CoryCMyers which in this case it will be myMin
Joseph
@revisualize
Jan 18 2017 05:33
@johnnunns What I gave to you as my attempt at a solution .. I only spent 25min on it.
CoryCMyers
@CoryCMyers
Jan 18 2017 05:33
@RetartedZombie @edgaryp Oh! So it was failing because I was giving it a real number instead of the parameter the rest was basing off of?
@RetartedZombie @edgaryp Thank you!
CamperBot
@camperbot
Jan 18 2017 05:33
corycmyers sends brownie points to @retartedzombie and @edgaryp :sparkles: :thumbsup: :sparkles:
Rebecca Vest
@idahogurl
Jan 18 2017 05:33
Can someone explain what to do with this requirement
If multiple pairs are possible that have the same numeric elements but different indices, return the smallest sum of indices.
Edgar Pan
@edgaryp
Jan 18 2017 05:33
@CoryCMyers correct
John Nunns
@johnnunns
Jan 18 2017 05:34
@revisualize gotcha, yeah I actually have had your code right above the one I've been making as my own and I've used your code along with the youtube videos I've watched on using reduce
Joseph
@revisualize
Jan 18 2017 05:34
@johnnunns Cheater. :P
John Nunns
@johnnunns
Jan 18 2017 05:34
haha it's either that or have a headache all day @revisualize
Joseph
@revisualize
Jan 18 2017 05:34
@johnnunns I'm going to try your solution against the test data.
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:35
@idahogurl you mean to say String i used string and moreover it's a pseudocode...to illustrate
John Nunns
@johnnunns
Jan 18 2017 05:35
my solution definitely doesn't work
it only returns firstName: Mary. I didn't want to just copy your solution without understanding first though so I was trying to walk through it here
Rebecca Vest
@idahogurl
Jan 18 2017 05:35
True. I just didn't want to confuse the guy
John Nunns
@johnnunns
Jan 18 2017 05:35
let me repost
var array = [
[
['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
],
[
['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
]
]
function transformEmployeeData(array){

return array.reduce(function(a,b){a[b[0][0]]=b[0][1]; return a},{})

}
transformEmployeeData(array)
Ogundele Olumide
@Lumexralph
Jan 18 2017 05:36
@idahogurl i understand
John Nunns
@johnnunns
Jan 18 2017 05:36
right now, as I said, I return only {firstName: Mary} for some reason I don't know
Joseph
@revisualize
Jan 18 2017 05:36
That doesn't seem right.
John Nunns
@johnnunns
Jan 18 2017 05:37
confused on two things. A) it doesn't run through the whole array and B) why would it choose to only print the 2nd array group
Phil Seidel
@psbyron3
Jan 18 2017 05:37
// the input is a three dimensional array, meaning it is 3 levels deep (will require 3 iterations)
function transformEmployeeData(array) {
establish two objects: var joe = {}; var mary = {};
iterate over the array (can be done with for loop, reduce, etc.)
each element is its own array, containing the info we need in, you guessed it, arrays
so we need to iterate thru the mid-level array.
Now iterate thru this layer to uncover the data!!!
inside each array we have a key and a value pair, so we need to set it to an object
where arr[i][j][0] is the key and arr[i][j][1] is the value

return the object

There are ways to dynamically create objects on the fly, however I feel that is above your current level and requires understanding of a few more concepts

You also need to set a condition (if statement) with the positioning of the second iteration to assign the right properties to the right object.
so array[0] is joe and array[1] is mary.

@johnnunns
Joseph
@revisualize
Jan 18 2017 05:38
@psbyron3 You're not supposed to return the array of objects?
John Nunns
@johnnunns
Jan 18 2017 05:38
Thanks @psbyron3 let me try and understand this
CamperBot
@camperbot
Jan 18 2017 05:38
johnnunns sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles:
:warning: johnnunns already gave psbyron3 points
Phil Seidel
@psbyron3
Jan 18 2017 05:38
The input is a 3D array
CoryCMyers
@CoryCMyers
Jan 18 2017 05:38
So just to make sure I am understanding this correctly
/ / will always be the container saying everything inside of this is the regular expression I am looking for.
\ Denotes the presence of specific parameters within that regular expression or allowances
/ /gi etc is then saying I want you to allow for these variables or defines the scope of the search?
Phil Seidel
@psbyron3
Jan 18 2017 05:38
The data inside needs to be converted to an object @revisualize
I was trying to offer a fundamental solution that doesn't involve more complicated parts of JS @revisualize
Oh I see what your saying in my return statement
John Nunns
@johnnunns
Jan 18 2017 05:40
@psbyron3 now to use arr[i][j][0] we're using a for loop correct?
azariahk7
@azariahk7
Jan 18 2017 05:40
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.
Joseph
@revisualize
Jan 18 2017 05:40
@psbyron3 My solution returned this:
[ { firstName: 'Joe', lastName: 'Blow', age: 42, role: 'clerk' } , { firstName: 'Mary', lastName: 'Jenkins', age: 36, role: 'manager' } ]
azariahk7
@azariahk7
Jan 18 2017 05:40
how to do this???
Joseph
@revisualize
Jan 18 2017 05:40
@psbyron3 Is that not correct?
heroiczero
@heroiczero
Jan 18 2017 05:40
@azariahk7 review shift ,push, pop, and unshift methods in your FreecodeCamp map
Phil Seidel
@psbyron3
Jan 18 2017 05:40
No you got it right @revisualize
Joseph
@revisualize
Jan 18 2017 05:41
SEE!
:muscle:
@psbyron3 25 minutes!
azariahk7
@azariahk7
Jan 18 2017 05:41
thanks sir @heroiczero
CamperBot
@camperbot
Jan 18 2017 05:41
azariahk7 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
Rebecca Vest
@idahogurl
Jan 18 2017 05:42
when I am determining the indexes that add up to the arg. it doesn't have to be a pair right?
Joseph
@revisualize
Jan 18 2017 05:42
John Nunns
@johnnunns
Jan 18 2017 05:42
@revisualize were you able to figure out how to run it if other values were introduced though? @revisualize
yuelittle
@yuelittle
Jan 18 2017 05:42
Reverse a String how to do ?
Phil Seidel
@psbyron3
Jan 18 2017 05:42
Yes @johnnunns standard naming convention for 'for' loops is the first and second is
for (var i...
for (var j...
Joseph
@revisualize
Jan 18 2017 05:42
@johnnunns What other values?
Timur Uzel
@timurtu
Jan 18 2017 05:42
@johnnunns did you get it? I found a solution
Joseph
@revisualize
Jan 18 2017 05:42
@johnnunns And where?
Rebecca Vest
@idahogurl
Jan 18 2017 05:42
@yuelittle lets say your variable is named str
Phil Seidel
@psbyron3
Jan 18 2017 05:42
@revisualize 25 minutes for what?
Rebecca Vest
@idahogurl
Jan 18 2017 05:43
it would be str.reverse()
John Nunns
@johnnunns
Jan 18 2017 05:43

@revisualize
Note that the input may have a different number of rows or different keys than the given sample.

For example, let's say the HR department adds a "tshirtSize" field to each employee record. Your code should flexibly accommodate that.

That's where your code wasn't working I thought we established
Joseph
@revisualize
Jan 18 2017 05:43
@johnnunns You mean like this:
[ { firstName: 'Joe',
lastName: 'Blow',
age: 42,
role: 'clerk',
tshirtSize: 'L' },
{ firstName: 'Mary',
lastName: 'Jenkins',
age: 36,
role: 'manager',
tshirtSize: 'M' } ]
John Nunns
@johnnunns
Jan 18 2017 05:44
@timurtu I think they have an understanding, I'm grinding it out still
Rebecca Vest
@idahogurl
Jan 18 2017 05:44
pairwise([0, 0, 0, 0, 1, 1], 1)
John Nunns
@johnnunns
Jan 18 2017 05:44
@revisualize looks good!
Joseph
@revisualize
Jan 18 2017 05:44
Same code that I posted.
Rebecca Vest
@idahogurl
Jan 18 2017 05:44
I would get 0,4;1,4;2,4;3,4
Joseph
@revisualize
Jan 18 2017 05:45
John Nunns
@johnnunns
Jan 18 2017 05:45
ok so @psbyron3 would you recommend that I do use a for loop instead of the reduce? or do I need to place the reduce method into a for loop?
Manish Giri
@Manish-Giri
Jan 18 2017 05:45
Yes @johnnunns standard naming convention for 'for' loops is the first and second is
for (var i...
for (var j...
this is what I did yesterday, lol
Joseph
@revisualize
Jan 18 2017 05:46
function transformEmployeeData (array) {
var result = [];
for (var i = 0; i < array.length; i++) {
result.push(array[i].reduce(function(acc, cur) { acc[cur[0]] = cur[1]; return acc; }, {}));
}
return result;
}
Rebecca Vest
@idahogurl
Jan 18 2017 05:46
What do I do to determine the lowest sum
I'm getting this one wrong too
Timur Uzel
@timurtu
Jan 18 2017 05:47
I’m actually not sure how to do it without reduce
Rebecca Vest
@idahogurl
Jan 18 2017 05:47
pairwise([0, 0, 0, 0, 1, 1], 1)
John Nunns
@johnnunns
Jan 18 2017 05:47
yeah @revisualize that one worked
Joseph
@revisualize
Jan 18 2017 05:47
That was my solution from last night.
LOL!
log
CamperBot
@camperbot
Jan 18 2017 05:47
Archives for HelpJavaScript
John Nunns
@johnnunns
Jan 18 2017 05:48
If you didn't update it then it must have been the site bugging
Joseph
@revisualize
Jan 18 2017 05:48
John Nunns
@johnnunns
Jan 18 2017 05:48
Because last night the last code that I tried from you worked with sample data but not outside data
Timur Uzel
@timurtu
Jan 18 2017 05:48
function transformEmployeeData(array) {
return array.map((item, i) => item.reduce((x, y) => {
const z = {}

z[y[0]] = y[1]

return Object.assign({}, x, z)
}, {}))
}
Joseph
@revisualize
Jan 18 2017 05:49
@johnnunns I then refactored it to use the parameter https://gitter.im/FreeCodeCamp/HelpJavaScript?at=587ddc49e836bf7010535b3e
Rebecca Vest