These are chat archives for FreeCodeCamp/HelpJavaScript

29th
Nov 2016
Evan Kalvis
@evan17gr
Nov 29 2016 00:01
@HelioRochaCardoso @rugby8724 thanks for the help
CamperBot
@camperbot
Nov 29 2016 00:01
evan17gr sends brownie points to @heliorochacardoso and @rugby8724 :sparkles: :thumbsup: :sparkles:
:cookie: 213 | @heliorochacardoso |http://www.freecodecamp.com/heliorochacardoso
:cookie: 216 | @rugby8724 |http://www.freecodecamp.com/rugby8724
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 00:01
well done @evan17gr
Jeremiah Wise
@rugby8724
Nov 29 2016 00:02
@evan17gr glad to help out
nredona
@nredona
Nov 29 2016 00:05
how do i fix this code?

// Setup
function testStrict(val) {
if (val) { 7 === 7;
7 === '7';
return "Equal";
}
return "Not Equal";
}

// Change this value to test
testStrict(10);

its the comparison with the strict equality operator
Jeremiah Wise
@rugby8724
Nov 29 2016 00:08
@nredona if I remember correctly that challenge just wants you to change the 7 to a 10
nredona
@nredona
Nov 29 2016 00:16
@rugby8724 lol i know i have to change the if (val) { line
i just don't know to what
Jeremiah Wise
@rugby8724
Nov 29 2016 00:19
@nredona sorry I had to go back and look at the challenge to refresh my memory
technically we don't know what the user will enter for val correct?
nredona
@nredona
Nov 29 2016 00:20
correct
so we have to change the if statement line
Jeremiah Wise
@rugby8724
Nov 29 2016 00:21
correct
nredona
@nredona
Nov 29 2016 00:23
so i thought i would write 7 === 7;
Jeremiah Wise
@rugby8724
Nov 29 2016 00:24
in that case you are forcing 7 to be the value that is being compared in stead of the val
we want to know if val is strictly equal to 7
and the challenge wants to know if val is strictly equal to 10
@nredona lets relook at how the if statement works. Inside the () is what the if statement is trying to determine if it is true or not right
Danilo Geronimo
@danilogeronimo
Nov 29 2016 00:34
function whatIsInAName(collection, source) {


    console.log("collection keys: " + Object.keys(collection[0]));    
    console.log("source keys: " + Object.keys(source));


    console.log(Object.keys(collection[0]) == Object.keys(source));
}

whatIsInAName([{"a" : 1,"b" : 2}, {"a" : 1}, {"a" : 1,"b" : 2,"c" : 2}], {"a" : 1,"b" : 2});
why the test give me 'false'?
WhiteLeaf1103
@WhiteLeaf1103
Nov 29 2016 00:35
it says to print out computerChoice... how do I do that. I tried console.log(computerChoice); but it doesnt work.
var userChoice = prompt("Do you choose rock, paper or scissors?");

var computerChoice = math.random();
nredona
@nredona
Nov 29 2016 00:36
@rugby8724 if (val === 7) worked thanks
CamperBot
@camperbot
Nov 29 2016 00:36
nredona sends brownie points to @rugby8724 :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @rugby8724 |http://www.freecodecamp.com/rugby8724
Jeremiah Wise
@rugby8724
Nov 29 2016 00:36
@nredona nice, happy to help out
Danilo Geronimo
@danilogeronimo
Nov 29 2016 00:40
:worried:
Justin Castro
@justmcastro
Nov 29 2016 00:43
Jeremiah Wise
@rugby8724
Nov 29 2016 00:43
@danilogeronimo sorry man...I have not worked that challenge yet
@justmcastro can you show us the code you have so far
@WhiteLeaf1103 could you show us all the code
Moisés Man
@moigithub
Nov 29 2016 00:44
@WhiteLeaf1103 its Math not math.. javascript is case sensitive
Justin Castro
@justmcastro
Nov 29 2016 00:44
@rugby8724 I'm working on the code,give me a few minutes.
Stephen James
@sjames1958gm
Nov 29 2016 00:46
@danilogeronimo two arrays cannot be compared that way, the only way that would be equal is they were the same array reference.
Danilo Geronimo
@danilogeronimo
Nov 29 2016 00:47
@sjames1958gm I can only test iterating?
Stephen James
@sjames1958gm
Nov 29 2016 00:47
@danilogeronimo Correct
Danilo Geronimo
@danilogeronimo
Nov 29 2016 00:50
@sjames1958gm I'm trying to figure out how to iterate two properties at once. From the 'source' array, i like to test the 'a' and 'b' If they match the elements inside object 'collection'
Stephen James
@sjames1958gm
Nov 29 2016 00:52
@danilogeronimo You could use the array function .every
@danilogeronimo Or you can use a boolean variable set to true then loop and set to false if any property fails the test
Danilo Geronimo
@danilogeronimo
Nov 29 2016 00:53
@sjames1958gm thanks, i'll try the boolean thing
CamperBot
@camperbot
Nov 29 2016 00:53
danilogeronimo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4590 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 29 2016 00:54
@danilogeronimo :+1:
Alen Sljivar
@machy44
Nov 29 2016 01:03
Im on task "Caesars Cipher"-->Basic algorithm scripting.. I need help..why my code does not work

function rot13(str) { // LBH QVQ VG!
var num = 13;
var res=0;
var letter='';
for (var i = 0; i < str.length; i++) {
if(str.charCodeAt(i)>=65 && str.charCodeAt(i) <= 77){
res = str.charCodeAt(i)+num;
}
else if(str.charCodeAt(i)==32){
res = 0;
letter +=' ';
}
else {
res = str.charCodeAt(i)-num;
}
letter += String.fromCharCode(res);
}

return letter;
}

// Change the inputs below to test
//rot13("SERR PBQR PNZC");
rot13("HELLO HELLO");

Moisés Man
@moigithub
Nov 29 2016 01:10
u should test ur code with this //rot13("SERR PBQR PNZC");
that should return FREE CODE CAMP
Nayenne Abgail
@Nayenne
Nov 29 2016 01:13
hello.
for challenge Generate Random Fractions with JavaScript
is my code ok?

function randomFraction() {

// Only change code below this line.

return Math.random(Math.random()*0);

// Only change code above this line.
}

looks simple. is there any other way to write this code?
Omar Hernandez
@comhernandez28
Nov 29 2016 01:14
hey guys
Alen Sljivar
@machy44
Nov 29 2016 01:14
@moigithub it returns me FREE •CODE •CAMP
Omar Hernandez
@comhernandez28
Nov 29 2016 01:14
did anyone else struggle with the chunky monkey problem
mcrea2610
@mcrea2610
Nov 29 2016 01:14

My first post! Hi everyone!
I am working on the StandInLine challenge in the JavaScript section which presents the following challenge (and am completely stuck):

"In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

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."

And the code prompt:

function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

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

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

also, what is the best way to share code on here?
Thank you!

Omar Hernandez
@comhernandez28
Nov 29 2016 01:15
i just spent 50 minutes on it and i feel stupid
Johnny
@JohnnyBizzel
Nov 29 2016 01:17
@comhernandez28 Some challenges took me all day. Nothing wrong with that
'''
CamperBot
@camperbot
Nov 29 2016 01:17
:bulb: to format code use backticks! ``` more info
Johnny
@JohnnyBizzel
Nov 29 2016 01:18
@mcrea2610 For that challenges use push and shift
Moisés Man
@moigithub
Nov 29 2016 01:18
@machy44 i ugess that EXTRA char is from res=0
cuz it always reach this letter += String.fromCharCode(res);
i think u can add a continue statement
else if(str.charCodeAt(i)==32){
res = 0;
letter +=' ';
continue; ///////////<<<<
}
Alen Sljivar
@machy44
Nov 29 2016 01:19
@moigithub yes thanks
CamperBot
@camperbot
Nov 29 2016 01:19
machy44 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2263 | @moigithub |http://www.freecodecamp.com/moigithub
mcrea2610
@mcrea2610
Nov 29 2016 01:19
Thank you @JohnnyBizzel Ill give it a try and update you
CamperBot
@camperbot
Nov 29 2016 01:19
mcrea2610 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 905 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Omar Hernandez
@comhernandez28
Nov 29 2016 01:19
i just felt retarded lol i couldnt get it for 50 minutes
the other ones i blew through in 20 minutes or less each
but this one was 50 minutes
idk
just came to vent lol
Johnny
@JohnnyBizzel
Nov 29 2016 01:22
@comhernandez28 Lots of challenges to come!
@mcrea2610 I am off to bed soon. You only need a couple of lines of code.
vazqjose
@vazqjose
Nov 29 2016 01:24
Hello, im incredibly stuck...Im doing the Record Collection challenge (Front End Cert./Basic Javascript) and could use some help in what reference material can i use to solve this. I was browsing through previous challenges but none seemed to provide what i need to complete it. :(
Jeremiah Wise
@rugby8724
Nov 29 2016 01:29
@vazqjose did you write any code yet?
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 01:29
hey @vazqjose I'll give you some hints. "If" some conditions are met you'll need to "push" stuff around and "if" other conditions are met you'll need to check if some stuff "haveAProperty"
Tenzin Topjor
@aovsne
Nov 29 2016 01:35
write a program that asks rthe user for a number from 1-10 and display the sum of the numbers in the console starting from 1 to the number they chose.
can anyone help me with this problem
Nayenne Abgail
@Nayenne
Nov 29 2016 01:36
i am surprised i have got this right without help. thats why i want to check and make sure

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.
var randomWholeNumBetween0and9 = Math.floor(Math.random() * 10);

return randomWholeNumBetween0and9;

}

*Generate Random Whole Numbers with JavaScript
Allan Oloo
@OlooAllaN
Nov 29 2016 01:37

can someone walk me through this challenge.
function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments);

return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

burkose
@burkose
Nov 29 2016 01:37
Hi, I'm stuck in the JavaScript challenge for switch statements can anyone help ?

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

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

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

Allan Oloo
@OlooAllaN
Nov 29 2016 01:38
Also is it bad that I have had help on almost every challenge? I understand what the challenges are asking, but I always struggle solving them. I suck at coding
Zapp_Brannigan
@dggz93
Nov 29 2016 01:43
hey
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 01:43
@OlooAllaN you'll get there! I'm a complete beginner lol The more you try the more mistakes you'll make and the more chances you'll have of moving forward
Zapp_Brannigan
@dggz93
Nov 29 2016 01:43
in the collection exercise
i need an example
or an explanation
Hoang Sy Tan
@sytan001
Nov 29 2016 01:44
hi everybody!
I've a problem, wish anyone can help me:
<script>
function chunkArrayInGroups(arr, size) {
//Break 'arr' to n array with each array contain 'size' element

var tempArray = [];
var tempChildArray = [];
for(var i=0; i<arr.length/size; i++){ for(var j=0; j<size; j++){ tempChildArray.push(arr[i*size +j]); } tempArray.push(tempChildArray); for(j=0; j<size; j++){ tempChildArray.pop(); } } return tempArray; //document.write(tempArray); } chunkArrayInGroups(["a", "b", "c", "d"], 2); </script>
it return an array with two empty element
Justin Castro
@justmcastro
Nov 29 2016 01:47
Can someone help me with Record Collection

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

// Only change code below this line
function updateRecords(id, prop, value) {

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

else if (prop === "tracks") {
collection.hasOwnProperty("tracks");
}

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

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

return collection;
}

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

Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 01:49
@burkose you don't need to print to the console, you just need to set the variable answer to the names instead
@justmcastro you forgot the ; on the last else if statement
Zapp_Brannigan
@dggz93
Nov 29 2016 01:53
why collection[id][prop]? I was trying with collection.id[prop]
Justin Castro
@justmcastro
Nov 29 2016 01:54
@HelioRochaCardoso Thanks, my else if (prop === "tracks") { collection.hasOwnproperty("tracks); seem to be my problem now.
CamperBot
@camperbot
Nov 29 2016 01:54
justmcastro sends brownie points to @heliorochacardoso :sparkles: :thumbsup: :sparkles:
:cookie: 220 | @heliorochacardoso |http://www.freecodecamp.com/heliorochacardoso
Justin Castro
@justmcastro
Nov 29 2016 01:54
If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 01:54
You're welcome @justmcastro
What did I do wrong here?
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 01:55
are you stil having trouble with that last thing? @justmcastro
Justin Castro
@justmcastro
Nov 29 2016 01:55
@HelioRochaCardoso yes.
@khanhbao86 you need to assign proccessArg to process
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 01:56
your second else if is suppose to read tracks and not tracts. Make sure you look out for typos
Omar Hernandez
@comhernandez28
Nov 29 2016 01:56
@Hoan
Diep
@khanhbao86
Nov 29 2016 01:57
@justmcastro I did. please check my code
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 01:59
@justmcastro you need to check for the property on the prop parameter not on the word "tracks" itself. Then you need to "push" a value into ( = ) an empty array
David Amanze
@GodKingShogun
Nov 29 2016 02:00
is anyone here familiar with the golf javascript problem
perssonalities
@perssonalities
Nov 29 2016 02:00
Hello, I am stumped on the Comparison with the Greater Than Operator Comparison with the Greater Than Operator lesson. I understand how to use a comparison operator. I am not understanding what they are asking...??? Help!!! anyone. Would greatly appreciate it
Hoang Sy Tan
@sytan001
Nov 29 2016 02:01

@khanhbao86 : just: var processed = 2;

processed = processArg(7);

David Amanze
@GodKingShogun
Nov 29 2016 02:02
@perssonalities just put >= or <= inside the if statement depending on what they are asking you to do
Manish Giri
@Manish-Giri
Nov 29 2016 02:02
@perssonalities you need to modify the if statements in such a way that the return statement inside those if’s reflect that
David Amanze
@GodKingShogun
Nov 29 2016 02:03
my favorite person
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:03
@justmcastro you also need to correct where you're looking for "AProperty" which is suppose to be on the album's "prop" parameter and not on the word collection
David Amanze
@GodKingShogun
Nov 29 2016 02:03
@Manish-Giri
Manish Giri
@Manish-Giri
Nov 29 2016 02:03

ex -

  if (val) {  // Change this line
    return "Over 100";
  }

modify this if such that it executes when val is over 100, use greather than operator,
similarly for the other if

Justin Castro
@justmcastro
Nov 29 2016 02:03
@sytan001 good job! I was trying to solve it and i always forget to put the ;
Manish Giri
@Manish-Giri
Nov 29 2016 02:04
lol, haha, you’re too kind @GodKingShogun
David Amanze
@GodKingShogun
Nov 29 2016 02:04
are you familiar with the javascript golf problem @ma
@Manish-Giri
Manish Giri
@Manish-Giri
Nov 29 2016 02:04
the par, strokes thing? @GodKingShogun
David Amanze
@GodKingShogun
Nov 29 2016 02:04
yes
Manish Giri
@Manish-Giri
Nov 29 2016 02:04
yeah, kind of remember
David Amanze
@GodKingShogun
Nov 29 2016 02:04
this is what i have so far but im not succeding
function golfScore(par, strokes) {
// Only change code below this line
if (strokes==1) {
return "Hole-in-one!";
}
else if (strokes<=par-2) {
return "Eagle";
}
else if (strokes<par-1){ return "Birdie"; } else if(strokes==par) { return "Par"; } else if (strokes>par+1) {
return "Bogey";
}
else if (strokes>par+2) {
return "Double Bogey";
}
else {
return "Go Home!";
}
// Only change code above this line
}
Manish Giri
@Manish-Giri
Nov 29 2016 02:05
@GodKingShogun pm me your challenge url, or post it here if you can format it
David Amanze
@GodKingShogun
Nov 29 2016 02:05

Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"
par and strokes will always be numeric and positive.

does that help
perssonalities
@perssonalities
Nov 29 2016 02:06
Go it! Thanks!!!
Manish Giri
@Manish-Giri
Nov 29 2016 02:06
not really
see here
Justin Castro
@justmcastro
Nov 29 2016 02:06
@Manish-Giri try else if (stroke <= (par -1))
Manish Giri
@Manish-Giri
Nov 29 2016 02:06
else if (strokes<=par-2) {
return "Eagle";
}
else if (strokes<par-1)
@GodKingShogun
in one place, you’re using <= and < in the other
make sure you use the one which is required
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:07
@perssonalities you only need to use the greater operator so that the statement written under evaluates to true
David Amanze
@GodKingShogun
Nov 29 2016 02:09
i used <= because the table wants me to use that
Manish Giri
@Manish-Giri
Nov 29 2016 02:10
then post the URL
Justin Castro
@justmcastro
Nov 29 2016 02:10
@HelioRochaCardoso Still solving it but that that helps a lot.
Diep
@khanhbao86
Nov 29 2016 02:11
@sytan001 cam on ban
David Amanze
@GodKingShogun
Nov 29 2016 02:11
i hope that helps
Manish Giri
@Manish-Giri
Nov 29 2016 02:11

@GodKingShogun first thing

else if (strokes == par-1){
    return "Birdie";
  }

this should be == not <

Zapp_Brannigan
@dggz93
Nov 29 2016 02:11
@justmcastro don't use else if
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:11
@justmcastro it took me a very long time to finish that one
Justin Castro
@justmcastro
Nov 29 2016 02:12
@dggz93 what do i use? QQ
Manish Giri
@Manish-Giri
Nov 29 2016 02:12
@GodKingShogun because in the left column, strokes is equal to the value in each row, unless they specifically mention a < or >
David Amanze
@GodKingShogun
Nov 29 2016 02:13
got it
Manish Giri
@Manish-Giri
Nov 29 2016 02:13
you should modify your remaining ifs that way @GodKingShogun
Zapp_Brannigan
@dggz93
Nov 29 2016 02:13
in the state of value === ""
use if
David Amanze
@GodKingShogun
Nov 29 2016 02:14
a million arigato gozaimasu to @Manish-Giri
Manish Giri
@Manish-Giri
Nov 29 2016 02:14
lol
welcome
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:17
@justmcastro when checking if the album doesn't have a property, remember that this property is a [parameter] of the collection
Zapp_Brannigan
@dggz93
Nov 29 2016 02:17
forget it, bad advise. Keep trying, sorry
RubberFactory
@RubberFactory
Nov 29 2016 02:18
//myStr should have encoded text with the proper escape sequences and no spacing.
var myStr="FirstLine\n \SecondLine\ \rThirdline";
WhiteLeaf1103
@WhiteLeaf1103
Nov 29 2016 02:20
keep getting a syntax error
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
    computerChoice = "rock";
} else if(computerChoice <= 0.67) {
    computerChoice = "paper";
} else {
    computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

var compare =function(choice1,choice2) {
    if(choice1=== choice2){
        return "The result is a tie!";
    }
            else if(choice1==="rock") {

                if( choice2==="scissors"){
                return "rock wins";
                }

                else {
                    return "paper wins";
        }


    }
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:21
@justmcastro "If" prop is "tracks" but (and) the album(collection) doesn't have a "tracks" property (a parameter of the updateRecords function), create an empty array before adding (pushing) the new value to the album's corresponding property.
Manish Giri
@Manish-Giri
Nov 29 2016 02:22
@WhiteLeaf1103 where are you calling compare()
MoNag1
@MoNag1
Nov 29 2016 02:22
@WhiteLeaf1103 you are missing a closing curly brace
scentury23
@scentury23
Nov 29 2016 02:28
how come im getting shift is not a function error?
Khalid
@Khaleed
Nov 29 2016 02:29
var userChoice = prompt( "Do you choose rock, paper or scissors?" );
var computerChoice = Math.random();
if ( computerChoice < 0.34 ) {
    computerChoice = "rock";
} else if ( computerChoice <= 0.67 ) {
    computerChoice = "paper";
} else {
    computerChoice = "scissors";
} console.log( "Computer: " + computerChoice );

var compare =function ( choice1,choice2 ) {
    if  ( choice1 === choice2 ){
        return "The result is a tie!";
    }
    else if ( choice1==="rock" ) {
        if ( choice2==="scissors" ){
            return "rock wins";
        }
        else {
            return "paper wins";
        }
    }
}
@WhiteLeaf1103 ^^
you're missing a curly braces plus you need to space out your code
scentury23
@scentury23
Nov 29 2016 02:29
can someone help me quick
Khalid
@Khaleed
Nov 29 2016 02:29
i have spaced the code out
@scentury23 post your code please
Allan Oloo
@OlooAllaN
Nov 29 2016 02:30

so I am on the challenge "Where do I belong" function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var sorted = arr.sort(function(a, b) { return a-b;});
for (var i = 0; i < sorted.length; i++){

}
return sorted;
}

getIndexToIns([5, 3, 20, 3]);
I have sorted the array from least to greatest. Now I need guidance on the next part solving this problem. I have a for loop to go through each index. Would an if state to compare each index value to num work?

scentury23
@scentury23
Nov 29 2016 02:30

function nextInLine(arr, item) {
// Your code here
arr = arr.push(item);
var g = arr.shift();
return "g"; // 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));

supposed to get it to return the first element of the array.. thought the function was shift()?
Khalid
@Khaleed
Nov 29 2016 02:31
function nextInLine(arr, item) {
// Your code here
arr = arr.push(item);
var g = arr.shift();
return "g"; // 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));
so basically this is your code
scentury23
@scentury23
Nov 29 2016 02:31
yes
how'd you do that?
Khalid
@Khaleed
Nov 29 2016 02:31
missin and f :(
place your code between ``` and ````
using mark down
which is supported by gitter
what is your q?
MoNag1
@MoNag1
Nov 29 2016 02:33
@OlooAllaN there is no need for a loop you are quite close
Khalid
@Khaleed
Nov 29 2016 02:33
shift removes the first element in the array
MoNag1
@MoNag1
Nov 29 2016 02:33
@scentury23 your code is not working because of the arr = arr.push(item) part. When you do that, you are setting the array arr equal to the pushed item.
Allan Oloo
@OlooAllaN
Nov 29 2016 02:34
@MoNag1 should I use an if statement to check each index to num?
Khalid
@Khaleed
Nov 29 2016 02:34
to get to the first element of the array you call the array with 0 index
index*
Allan Oloo
@OlooAllaN
Nov 29 2016 02:34
Why dont i need a forloop?
scentury23
@scentury23
Nov 29 2016 02:34
@MoNag1 wait so what should i do instead to add the element to the array?
MoNag1
@MoNag1
Nov 29 2016 02:34
@OlooAllaN what you first need to do it push the number num into your array
@OlooAllaN then sort the array with the new number added
@scentury23 you have to simply push item into arr. You don't want the pushed item to be equal to arr
Khalid
@Khaleed
Nov 29 2016 02:35
to add element to the array you push
MoNag1
@MoNag1
Nov 29 2016 02:35
so remove arr= part
Khalid
@Khaleed
Nov 29 2016 02:36
what MoNag1 is saying is that you're re-assigning the arr
when you only need to push an item into it
scentury23
@scentury23
Nov 29 2016 02:36
ohh i see, thank you
MoNag1
@MoNag1
Nov 29 2016 02:36
yeah exactly ^ you shouldn't reassign
mgarrett2546
@mgarrett2546
Nov 29 2016 02:37
hello campers this is my first time asking for help on the chat line I have a question regarding the factorialize a number challenge
Khalid
@Khaleed
Nov 29 2016 02:37
post your code please
so we can see the problem
mgarrett2546
@mgarrett2546
Nov 29 2016 02:37

this is my current code var array =[];
var zero = 0;

function factorialize(num) {
if (num>0){
for(var i = num; i>zero; i--){
console.log(array.push(i));
}
var factor = array.reduce(function(num,zero){
return (num * zero);
});
return factor;
}
else {
return 1;
}
}

factorialize(0);

Khalid
@Khaleed
Nov 29 2016 02:37
var array = [];
var zero = 0;
function factorialize(num) {
if (num>0) {
for(var i = num; i > zero; i--){
console.log(array.push(i));
}
var factor = array.reduce(function(num,zero){
return (num * zero);
});
return factor;
}
else {
return 1;
}
}
factorialize(0);
Sakitha
@Sakitha
Nov 29 2016 02:38
@OlooAllaN i did that challenge using a for loop
gina
@nagi26
Nov 29 2016 02:38
how to do this problem? wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
Khalid
@Khaleed
Nov 29 2016 02:39
@mgarrett2546 what's your question please?
mgarrett2546
@mgarrett2546
Nov 29 2016 02:39
ill revise...my code is giving the proper answers but the challenge isnt accepting it as correct
Allan Oloo
@OlooAllaN
Nov 29 2016 02:39

getting an error
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var newArr = arr.push(num);
var sorted = newArr.sort(function(a, b) { return a-b;});

return sorted;
}

getIndexToIns([5, 3, 20, 3],5);

Khalid
@Khaleed
Nov 29 2016 02:40
@mgarrett2546 could you post the link to the challenge please
MoNag1
@MoNag1
Nov 29 2016 02:41
@OlooAllaN ok thats good, you now have a new array that includes the number num and is sorted in ascending order
Justin Castro
@justmcastro
Nov 29 2016 02:41
@HelioRochaCardoso this is what i have?
else if (prop === "tracks") {
collection[id].tracks = [];
collection[id].tracks.push(value);
}
Allan Oloo
@OlooAllaN
Nov 29 2016 02:42
@MoNag1 but i am getting a type error saying sort is not a funciton
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:42
@nagi26 what you need to do is to output the words using the parameters given in hte function below and add a space " " in between each word
Khalid
@Khaleed
Nov 29 2016 02:43
@mgarrett2546 do you know how reduce works?
mgarrett2546
@mgarrett2546
Nov 29 2016 02:43
not exactly
Khalid
@Khaleed
Nov 29 2016 02:45
reduce is going to transform values in an array into just one total value
MoNag1
@MoNag1
Nov 29 2016 02:45
@OlooAllaN rather than create a new variable called newArr, you can simply push num into arr and call .sort() on arr instead of newArr
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:46
@justmcastro that's very good, but not quite. Remember that here tracks is represented by the parameter given at the beginning of the function. So you are actually adding a value to this parameter and not to the word tracks
Khalid
@Khaleed
Nov 29 2016 02:46
in your example code, it is going to take the values in your array and come up with a final value by multiplying each number
in other words, you are calculating factorial
anyway, your problem is that you named your array array
which is a reserved word in JavaScript :)
MoNag1
@MoNag1
Nov 29 2016 02:46
@OlooAllaN because right now, your variable newArr is equal to the pushed number only. It is an array with only 1 value. You are getting an error because when your function requires 2 values (a,b)
mgarrett2546
@mgarrett2546
Nov 29 2016 02:47
is it really that simple
Khalid
@Khaleed
Nov 29 2016 02:47
change your variable name
to arr
mgarrett2546
@mgarrett2546
Nov 29 2016 02:47
:D thank you
Khalid
@Khaleed
Nov 29 2016 02:47
or myArray
let me know if it worked!
vazqjose
@vazqjose
Nov 29 2016 02:47
Here is my code so far for the Record Collection challenge.
/*
  If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.
  */
  if (prop !== 'tracks' && value !== null)
    {
      collection[id][prop] = value;
     }

  /*
  If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.
  */
  if (prop == 'tracks' && collection[id].hasOwnProperty(prop) === false)
      {
        collection[id].tracks = value;
      }

  /*
  If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.
  */
  if (collection[id][prop] == 'tracks' && value !== null)
    {
      collection[id].tracks.push(value);
    }

  /*
  If value is empty (""), delete the given prop property from the album.
  */
  if (value === "")
    {
      delete collection[id][prop];
    }
Khalid
@Khaleed
Nov 29 2016 02:48
@vazqjose could you please re-copy that
i think your code is mixed with comments
@mgarrett2546 does the test pass?
Justin Castro
@justmcastro
Nov 29 2016 02:49
@HelioRochaCardoso would i use prop instead of "tracks"?
vazqjose
@vazqjose
Nov 29 2016 02:49
@Khaleed I know, i included the comments as a guide for each block
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:50
and in the if condition you also need to check for "the album doesn't have a "tracks" property" meaning the album (collection) hasProperty tracks (prop) of false
@justmcastro yup
__mifflin__
@cdrainxv
Nov 29 2016 02:50

@mgarrett2546: Move this:

var array =[];
var zero = 0;

inside the function.
And change this:
console.log(array.push(i)); to:
array.push(i);

Zapp_Brannigan
@dggz93
Nov 29 2016 02:50
solved it!
thanks @vazqjose
CamperBot
@camperbot
Nov 29 2016 02:50
dggz93 sends brownie points to @vazqjose :sparkles: :thumbsup: :sparkles:
:cookie: 225 | @vazqjose |http://www.freecodecamp.com/vazqjose
vazqjose
@vazqjose
Nov 29 2016 02:51
@dggz93 really? Thats great i could help you out! Im still stuck though :(
Justin Castro
@justmcastro
Nov 29 2016 02:51
@HelioRochaCardoso

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

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

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

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

this is what i have now.
Khalid
@Khaleed
Nov 29 2016 02:51

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


if (prop == 'tracks' && collection[id].hasOwnProperty(prop) === false) {
    collection[id].tracks = value;
}


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

if (value === "") {
    delete collection[id][prop];
}
Justin Castro
@justmcastro
Nov 29 2016 02:52
how do you do that?
@Khaleed
MoNag1
@MoNag1
Nov 29 2016 02:52
'''
CamperBot
@camperbot
Nov 29 2016 02:52
:bulb: to format code use backticks! ``` more info
MoNag1
@MoNag1
Nov 29 2016 02:52
@justmcastro ^
thoresen-k
@thoresen-k
Nov 29 2016 02:52
I need help with the "Global Scopes and Functions" task. Can anyone help?
Zapp_Brannigan
@dggz93
Nov 29 2016 02:52
@vazqjose you need to create an empty array
in the second if state
Khalid
@Khaleed
Nov 29 2016 02:53
@justmcastro place your code inside three back ticks
@mgarrett2546 I made a huge mistake :)
it wasn't the reserved word -> the reserved JavaScript for array is Array
with a capital A
MoNag1
@MoNag1
Nov 29 2016 02:54
@thoresen-k sure what do you have so far?
Khalid
@Khaleed
Nov 29 2016 02:54
function factorialize(num) {
    var arr = [];
    var zero = 0;   
    if (num>0) {
        for(var i = num; i > zero; i--){
            arr.push(i);
        }
        var factor = arr.reduce(function(num,zero){
            return (num * zero);
        });
        return factor;
    }
    else {
        return 1;
    }
}

factorialize(0);
@mgarrett2546
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:55
@justmcastro on the second condition you need to create an empty array before pushing value. And you are suppose to push value to [prop] not tracks
thoresen-k
@thoresen-k
Nov 29 2016 02:55
@MoNag1

// Declare your variable here
var myGlobal = 10;

function fun1() {
// Assign 5 to oopsGlobal Here

}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Instructions
Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

MoNag1
@MoNag1
Nov 29 2016 02:56
@thoresen-k ok you declared myGlobal correctly, but you haven't assigned oopsGlobal a value
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:56
the empty array should go on the prop of the collection[id]
@justmcastro
MoNag1
@MoNag1
Nov 29 2016 02:57
@thoresen-k you need to do exactly what you did with myGlobal for oopsGlobal, except don't use the var keyword
vazqjose
@vazqjose
Nov 29 2016 02:57
wow I cant create an empty array >:/
thoresen-k
@thoresen-k
Nov 29 2016 02:58
@MoNag1 that doesn't work, I just tried it
vazqjose
@vazqjose
Nov 29 2016 02:58
var propArr = new Array(); ----> doesnt work
MoNag1
@MoNag1
Nov 29 2016 02:58
@thoresen-k how are you assigning oopsGlobal?
Zapp_Brannigan
@dggz93
Nov 29 2016 02:58
var array = [];
Doug
@doug20000
Nov 29 2016 02:58
Anyone able to help a brother out with the Factorialize a Number challenge? I've got code that does what the instructions ask, though it's not passing. (I might have coded in a weird way...)
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 02:59
@justmcastro oh I was referring to the code that was actually posted by Khaleed up there, I though it was your code, sorry
thoresen-k
@thoresen-k
Nov 29 2016 02:59
i'm not, i don't know how to assign it without the var keyword
MoNag1
@MoNag1
Nov 29 2016 02:59
oopsGlobal = 5;
@thoresen-k ^ it's just omitting the var keyword
thoresen-k
@thoresen-k
Nov 29 2016 03:00
that's exactly what i did, didn't work :(
@MoNag1
mgarrett2546
@mgarrett2546
Nov 29 2016 03:00
@Khaleed @cdrainxv moving the var array inside and changing the name of the variable worked thank you for your help
CamperBot
@camperbot
Nov 29 2016 03:00
mgarrett2546 sends brownie points to @khaleed and @cdrainxv :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for khaleed
:star2: 1150 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Manish Giri
@Manish-Giri
Nov 29 2016 03:00
@thoresen-k can you post your challenge URL here
MoNag1
@MoNag1
Nov 29 2016 03:00
@thoresen-k that's odd it passes for me, are you doing it on line 8?
@doug20000 send your code
Doug
@doug20000
Nov 29 2016 03:01

@MoNag1 var newArr = [];
var factorVal = 1;

function factorialize(num) {
if (num === 0) {
factorVal = 1;
return factorVal;
}

else {
for (i = 1; i <= num; i++) {
newArr.push(i);
}
var factorVal = newArr.reduce(function(a, b) {
return (a * b);
});

return factorVal;
}
}

factorialize(10);

@MoNag1
MoNag1
@MoNag1
Nov 29 2016 03:03
@doug20000 you are defining the variable factorVal twice
Manish Giri
@Manish-Giri
Nov 29 2016 03:03
@thoresen-k it's oopsGlobal
@thoresen-k you have oppsGlobal
typo
MoNag1
@MoNag1
Nov 29 2016 03:04
@doug20000 remove the var keyword on line 13 i believe
thoresen-k
@thoresen-k
Nov 29 2016 03:04
oh, oops LOL. thanks you! @Manish-Giri
CamperBot
@camperbot
Nov 29 2016 03:04
thoresen-k sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 2567 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Nov 29 2016 03:04
@thoresen-k welcome
MoNag1
@MoNag1
Nov 29 2016 03:04
@doug20000 but it works regardless btw
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:05
@justmcastro If prop is "tracks" but (and) the album (collection) doesn't have a "tracks" property (property is false), 1 - create an empty array = (collection[id][prop]) before 2 - adding (pushing) the new value to the album's corresponding property
Doug
@doug20000
Nov 29 2016 03:05
@MoNag1 that has removed the warning signs on my markup page, but the code still does not pass when i submit :S
MoNag1
@MoNag1
Nov 29 2016 03:05
@doug20000 oh yea and you need to defined factorVal and newArr locally and not globally
so move them inside the function
vazqjose
@vazqjose
Nov 29 2016 03:06
@dggz93 still stuck in this
mgarrett2546
@mgarrett2546
Nov 29 2016 03:07
@khalid thank you for all your help I think i got your name wrong the first time :D
CamperBot
@camperbot
Nov 29 2016 03:07
mgarrett2546 sends brownie points to @khalid :sparkles: :thumbsup: :sparkles:
:cookie: 77 | @khalid |http://www.freecodecamp.com/khalid
Doug
@doug20000
Nov 29 2016 03:07
@MoNag1 it worked! I don't get why it made a difference though as the console was still spitting out the right number when the variables were still global..
MoNag1
@MoNag1
Nov 29 2016 03:08
@doug20000 I'm an unsure as to why that would happen too
Doug
@doug20000
Nov 29 2016 03:09
@MoNag1 fair enough, thank you for your assistance :D
CamperBot
@camperbot
Nov 29 2016 03:09
doug20000 sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
:cookie: 378 | @monag1 |http://www.freecodecamp.com/monag1
Vejil
@Icehao
Nov 29 2016 03:09
how to remove all punctuation and space from a string?
MoNag1
@MoNag1
Nov 29 2016 03:09
:thumbsup:
@Icehao you can use .replace()
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:10
@justmcastro how is it going?
Vejil
@Icehao
Nov 29 2016 03:11
@MoNag1 what i should write in the () ?
Justin Castro
@justmcastro
Nov 29 2016 03:11
@HelioRochaCardoso just got your message at 19:05. Working on it.
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:12
cool, you're nearly there, just need to work the details
Zapp_Brannigan
@dggz93
Nov 29 2016 03:12
@vazqjose tracks not exist in this case, so you need to create the empty array in the collection[id] for simulate tracks, once you have the array, you give the value
MoNag1
@MoNag1
Nov 29 2016 03:12
.replace(/\W/g,""); should remove all non word characters @Icehao
Zapp_Brannigan
@dggz93
Nov 29 2016 03:12
i probably don't explain myself because of my rookie english
and my rookie javascript
vazqjose
@vazqjose
Nov 29 2016 03:13
@dggz93 if (collection[id][prop] == 'tracks' && value !== null) { var myArr = [value]; collection[id].tracks = myArr; }
MoNag1
@MoNag1
Nov 29 2016 03:14
@Icehao but I believe /\W/g doesn't remove underscores, so you'd have to take care of those as well
Vejil
@Icehao
Nov 29 2016 03:14
@MoNag1 in this way can i keep all numbers?
MoNag1
@MoNag1
Nov 29 2016 03:15
@Icehao no numbers will be removed too, but are you doing this for the palindromes challenge?
Zapp_Brannigan
@dggz93
Nov 29 2016 03:15
if(prop == 'tracks' && collection[id].hasOwnProperty(prop) === false)
you have done before
Wallace
@waudena
Nov 29 2016 03:16

I am in the "Using Objects for Lookups" section, does anyone know why this code the last line doesn't work in the "result=lookup.val; notation, but it works if i have it in result = lookup.val notation? // Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup= {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot":"Frank"
};
result = lookup.val;

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

// Change this value to test
phoneticLookup("charlie");

Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:17
@vazqjose you need to check if prop is 'tracks' (not collection[id][prop]). Then you just need to create an array with nothing inside and assign it to the album (collection) second parameter (prop)
Sam Fisk
@Neofish22
Nov 29 2016 03:17
@waudena The . notation only works with preset strings (hardcoded), so you should use the [] notation instead: result = lookup[val];
Anthony
@jawaka72
Nov 29 2016 03:17
function mutation(arr) {
  var arr1 = arr[0].toLowerCase();
  var arr2 = arr[1].toLowerCase();

  if(arr.indexOf(arr2) == arr.indexOf(arr1)){
    return true;
  } else {

  return false;
}
}
mutation(["hello", "hey"]);
Any tips on where to go from here?
Vejil
@Icehao
Nov 29 2016 03:17
@MoNag1 yes, i'm working on it now
Wallace
@waudena
Nov 29 2016 03:17
@Neofish22 thanks!
CamperBot
@camperbot
Nov 29 2016 03:17
waudena sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @neofish22 |http://www.freecodecamp.com/neofish22
Justin Castro
@justmcastro
Nov 29 2016 03:17

@HelioRochaCardoso ``` else if (prop === "tacks" && collection[id][prop] === false) {
collection[id][prop] = [ ];
collection[id][prop].push(value);

}

Zapp_Brannigan
@dggz93
Nov 29 2016 03:17
trust @HelioRochaCardoso
MoNag1
@MoNag1
Nov 29 2016 03:18
@Icehao then removing numbers too shouldn't be an issue
Justin Castro
@justmcastro
Nov 29 2016 03:19

```else if (prop === "tacks" && collection[id][prop] === false) {
collection[id][prop] = [ ];
collection[id][prop].push(value);

} ```

Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:20
@justmcastro that's even better than before, just a little detail... you need to check if the second parameter of collection (prop) exists (hasOwn)property
@justmcastro instead of collection[id][prop]. Like this you are referring to the value, referring to prop only requires the same but without [prop]
vazqjose
@vazqjose
Nov 29 2016 03:23
i am down to one error....
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:24
@vazqjose keep it going. The feeling of excitement you get after you complete it is worth it haha
Adam
@Adkstein
Nov 29 2016 03:24
I am having a stupidly difficult time at trying to figure this one out. can anyone send help :)?

Assignment with a Returned Value
If you'll recall from our discussion of Storing Values with the Assignment Operator, everything to the right of the equal sign is resolved before the value is assigned. This means we can take the return value of a function and assign it to a variable.

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

ourSum = sum(5, 12);

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

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

MoNag1
@MoNag1
Nov 29 2016 03:25
@Icehao .replace(/\W|_/g,"") your regex should look like that in the end
vazqjose
@vazqjose
Nov 29 2016 03:25
@HelioRochaCardoso It worked!!
victormanoliu97
@victormanoliu97
Nov 29 2016 03:25
hello guys can someone pls help me with map ?

var Add3 = oldArray.map(function(number)
{
return number + 3;
});

var newArray = oldArray;

i dont't understand why it's not working
Somia ♡
@somiajagadish
Nov 29 2016 03:26
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:26
@vazqjose nice one. I took over a week to compete that. The best thing to do now is go back and try to understand your code so that you can explain it to whoever needs help. That will help you improve, it is helping me
Vejil
@Icehao
Nov 29 2016 03:26
@MoNag1
Somia ♡
@somiajagadish
Nov 29 2016 03:26
What should my statement be?
Vejil
@Icehao
Nov 29 2016 03:26

@MoNag1 function palindrome(str) {
var newStr=str.replace(/\W|_/g,"");
newStr.toLowerCase();
var arr=newStr.split("");
var newArr=arr.reverse();
var newStrOne=newArr.join("");
if(str==newStrOne){return true;
}
else return false;

}
palindrome("eye");

vazqjose
@vazqjose
Nov 29 2016 03:26
@HelioRochaCardoso I created an array with the value parameter, then i added it to the tracks property. No empty array needed, just in two lines :)
victormanoliu97
@victormanoliu97
Nov 29 2016 03:27
what variable you have to switch ? @somiajagadish
Vejil
@Icehao
Nov 29 2016 03:27
@MoNag1 i have no idear why this don't work
victormanoliu97
@victormanoliu97
Nov 29 2016 03:27

var Add3 = oldArray.map(function(number)
{
return number + 3;
});

var newArray = oldArray;

why is this not working guys ?
Sam Fisk
@Neofish22
Nov 29 2016 03:28
@victormanoliu97 You're returning the result from map into Add3 then doing nothing with it.
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:28
oh really? I thought you would need an empty array. Well done @vazqjose
victormanoliu97
@victormanoliu97
Nov 29 2016 03:28
console.log(newArray); and it's still not working @Neofish22
vazqjose
@vazqjose
Nov 29 2016 03:28
@HelioRochaCardoso Yeah man remember you can declare a predermined array, so i figured i already have the value i have to insert .
MoNag1
@MoNag1
Nov 29 2016 03:29
@Icehao because you need to remove the chracters from str too and not only newStrOne
Sam Fisk
@Neofish22
Nov 29 2016 03:29
@victormanoliu97 oldArray remains unchanged when you do the assignment to newArray. You want to remove the oldArray.map() from the var Add3 = funciton... assignment, and merge it with the newArray one like this: var newArray = oldArray.map(Add3);
Somia ♡
@somiajagadish
Nov 29 2016 03:30
@victormanoliu97 I have to write a switch statement that sets answer so what would me statement be?
i know it should look like this:
switch(answer){
switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
default:
defaultStatement;
}
victormanoliu97
@victormanoliu97
Nov 29 2016 03:31
@Neofish22 [object Array] is not a function
Sam Fisk
@Neofish22
Nov 29 2016 03:31
Sec I'll write out what I mean so it's clearer.
silver537
@silver537
Nov 29 2016 03:31
@somiajagadish na. switch(answer) does nothing really.
victormanoliu97
@victormanoliu97
Nov 29 2016 03:31
@somiajagadish so you do the same thing with your cases
Sam Fisk
@Neofish22
Nov 29 2016 03:31
@victormanoliu97 var Add3 = function(number) { return number + 3; }; var newArray = oldArray.map(Add3);
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:32
@Adkstein you only need to assign (=) the function processArg with the parameter 7 to the variable processed. Remember this goes from right to left. You assign what's on the right to what's on the left
victormanoliu97
@victormanoliu97
Nov 29 2016 03:32
@Neofish22 and when i do that it tells me : TypeError: [object Array] is not a function
MoNag1
@MoNag1
Nov 29 2016 03:32
@Icehao instead of if(str===newStrOne) you should have if(str.replace(/\W|_/g,"").toLowerCase()==newStrOne.toLowerCase())
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:33
@vazqjose oh I don't remember that lol would you mind sending me your code through private message please so I can have a look?
vazqjose
@vazqjose
Nov 29 2016 03:34
@HelioRochaCardoso How can i do it?
Justin Castro
@justmcastro
Nov 29 2016 03:34
I got it! @vazqjose @vazqjose
vazqjose
@vazqjose
Nov 29 2016 03:34
@justmcastro cool!
Justin Castro
@justmcastro
Nov 29 2016 03:34
Thank you! :+1:
Sam Fisk
@Neofish22
Nov 29 2016 03:35
@victormanoliu97 Could you tell me the challenge you're on so I can try it myself in context, please?
Nm found it
Justin Castro
@justmcastro
Nov 29 2016 03:35
@HelioRochaCardoso Got it Thank you!
CamperBot
@camperbot
Nov 29 2016 03:35
justmcastro sends brownie points to @heliorochacardoso :sparkles: :thumbsup: :sparkles:
:cookie: 221 | @heliorochacardoso |http://www.freecodecamp.com/heliorochacardoso
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:36
out your mouse cursor over my image and some options should appear (Chat Privately)
@vazqjose
Sam Fisk
@Neofish22
Nov 29 2016 03:36
@victormanoliu97 I pasted in my modified version of your code into the challenge and it worked. Could you copy-paste yours?
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:36
@justmcastro Well done!!
vazqjose
@vazqjose
Nov 29 2016 03:37
@HelioRochaCardoso I see the pop up window but nothing for sending msg appears, can you pm me from your end?
victormanoliu97
@victormanoliu97
Nov 29 2016 03:37

@Neofish22 var Add3 = oldArray.map(function(val)
{

return val + 3;

});

var newArray = oldArray.map(Add3);

silver537
@silver537
Nov 29 2016 03:37
@vazqjose it's called chat privately
Vejil
@Icehao
Nov 29 2016 03:38
@MoNag1 yes ,it worked ,thanks a lot!
Sam Fisk
@Neofish22
Nov 29 2016 03:38
@victormanoliu97 You need to remove "oldArray.map(" from the first line, and the corresponding ) on the 4th line. :)
vazqjose
@vazqjose
Nov 29 2016 03:38
@silver537 I dont see it lol
silver537
@silver537
Nov 29 2016 03:39
your browser is whack mate
vazqjose
@vazqjose
Nov 29 2016 03:39
@silver537 firefox?
Sam Fisk
@Neofish22
Nov 29 2016 03:39
Alternatively you could do this: var newArray = oldArray.map(function(val){ return val+3; });
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:39
@vazqjose i have just pm you did you receive?
silver537
@silver537
Nov 29 2016 03:40
or let newArray = oldArray.map(val=>val+3)
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:40
I'm running chrome
@vazqjose it might be your browser or something
Briyona
@Briyona
Nov 29 2016 03:41
okay I've been at this counting cards problem for an hour and I can't seem to get the var count to change and to add up the count based on the sequence of cards. Can someone guide me in the right direction, I don't want the answer, but I can seem to figure this out.
Adam
@Adkstein
Nov 29 2016 03:41
@HelioRochaCardoso this is what I put in based on the instructions and examples and it won't work DX var processed = 2;
function processArg(7) {
return (processed);
}
var processed = 2;
function processArg(7) {
return (processed);
}
Somia ♡
@somiajagadish
Nov 29 2016 03:42

A common anti-pattern is to use an if/else statement to do a comparison and then return true/false:

function isEqual(a,b) {
  if (a === b) {
    return true;
  } else {
    return false;
  }
}

Since === returns true or false, we can return the result of the comparison:

function isEqual(a,b) {
  return a === b;
}

Instructions

Fix the function isLess to remove the if/else statements.

Help?

function isLess(a, b) {
// Fix this code
if (a < b) {
return true;
} else {
return false;
}
}

// Change these values to test
isLess(10, 15);

Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:42
@Adkstein you put your code where it says // Only change code below this line
actually under that line @Adkstein
Somia ♡
@somiajagadish
Nov 29 2016 03:44
Anyone?
^^^
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:44
@Adkstein calling a statement is literally writing down the statement and put whatever parameters inside the ()
Sam Fisk
@Neofish22
Nov 29 2016 03:44
@somiajagadish In the examples from the help, can you see how it reduced the if ... else ... to a single statement? You need to do similar but with a different comparison
Somia ♡
@somiajagadish
Nov 29 2016 03:45
@Neofish22 I dont understand
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:45
@Adkstein then you just assign (=) that to processed
Adam
@Adkstein
Nov 29 2016 03:45
@HelioRochaCardoso understood. I think what is tripping me up is the 7 and the 2. I am supposed to "Call the processArg function with an argument of 7 and assign its return value to the variable processed." but var processed is supposed to have a value of 2 in the end
tech-tron
@tech-tron
Nov 29 2016 03:46
having trouble with the fuction nextInLine'
silver537
@silver537
Nov 29 2016 03:46
@somiajagadish a===b returns a boolean. so instead of hard coding that return value i.e if(...) { return true } else { return false }
you can just return that expression => return a===b
Sam Fisk
@Neofish22
Nov 29 2016 03:47
^ What I was about to say. :)
Helio Cardoso
@HelioRochaCardoso
Nov 29 2016 03:47
@Adkstein processed is suppose to have a parameter of 7 like it says on the first instructions
silver537
@silver537
Nov 29 2016 03:48

so they give you the if else format:

if(a<b){
  return true
} else {
  return false
}

but they want you to reduce that hardcoding into a simple return statement.
reducing 5 lines of code into 1 line of code

Zapp_Brannigan
@dggz93
Nov 29 2016 03:50
i'm stuck again
silver537
@silver537
Nov 29 2016 03:50
@Briyona can't guide you anymore than what the challenges have taught you. use a switch statement to process the cards. then use an if/else to process Bet/Hold
if you need real help, you need to provide your code.
Zapp_Brannigan
@dggz93
Nov 29 2016 03:50
in the contacts exercise, do i need a for loop?
silver537
@silver537
Nov 29 2016 03:50
yes
you have to search through your list of contacts.
Zapp_Brannigan
@dggz93
Nov 29 2016 03:50
but it doesn't loop
silver537
@silver537
Nov 29 2016 03:51
oh well.
no code no help :P
Zapp_Brannigan
@dggz93
Nov 29 2016 03:51
for(var i = 0; i <= contacts.length; i++) doesn't loop
silver537
@silver537
Nov 29 2016 03:51
there we go :D
that does loop
William Huang
@WilliamHuang1995
Nov 29 2016 03:52
array.sort(function(a,b){return b-a;});
Zapp_Brannigan
@dggz93
Nov 29 2016 03:52

for(var i = 0; i <= contacts.length; i++)
{
return contacts[i];

}

if i do this
Dusliat
@Alchemistioc
Nov 29 2016 03:52

What up y'all. I'm stuck. What do? `
// Setup
var phoneticLookup={

// Only change code below this line
'alpha':"Denver",
'bravo':"Boston",
'charlie':"Chicago",
'delta':"Denver",
'echo':"Easy",
'foxtrot':"Frank",

};

phoneticLookup("charlie");
`

Zapp_Brannigan
@dggz93
Nov 29 2016 03:52
only return the first object
silver537
@silver537
Nov 29 2016 03:52
@dggz93 the return statement terminates the loop. take that out
William Huang
@WilliamHuang1995
Nov 29 2016 03:53
array.sort(function(a,b){return b-a;});
why does this reverse the order of the array?
Zapp_Brannigan
@dggz93
Nov 29 2016 03:53
oh, ok, thanks
silver537
@silver537
Nov 29 2016 03:54
@WilliamHuang1995 it depends on the evalutation. if it's a negative, siwtch the elements, if its positive, keep it the same
@Alchemistioc what do you have to do?
William Huang
@WilliamHuang1995
Nov 29 2016 03:54
but shouldn't b-a return the difference between b and a?
coming from a java background this just makes me very confused
silver537
@silver537
Nov 29 2016 03:55
@WilliamHuang1995 no the sort function does the evaluation. yes your function inside the sort returns the difference of the two. but then the sort takes that value and determines what to do with the initial two value
Ezeboy
@Ezeboy
Nov 29 2016 03:56
myStr should have encoded text with the proper escape sequences and no spacing.
silver537
@silver537
Nov 29 2016 03:56
@WilliamHuang1995 JS is also a functional language. so you'll be seeing a lot of that type of higher order functions
Ezeboy
@Ezeboy
Nov 29 2016 03:56
myStr should have encoded text with the proper escape sequences and no spacing.
var myStr = "\nFirstLine\\SecondLine\\rThirdLine.";
Dusliat
@Alchemistioc
Nov 29 2016 03:57
@silver537 I:Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Realized I missed a step.
Ezeboy
@Ezeboy
Nov 29 2016 03:57
what is wrong to my code?
Sam Fisk
@Neofish22
Nov 29 2016 03:58
@WilliamHuang1995 Generally speaking, in trivial cases, you would expect to use < or > in such sorting functions, which gives more comprehensible results. As @silver537 says, sort() evaluates the return from your function and if it is 'falsey' it rearranges it.
Ezeboy
@Ezeboy
Nov 29 2016 03:58
@Ezeboy
myStr should have encoded text with the proper escape sequences and no spacing.
var myStr = "\nFirstLine\\SecondLine\\rThirdLine.";
William Huang
@WilliamHuang1995
Nov 29 2016 03:59

@silver537 @Neofish22 so let's say and

array = [1,12,21,2];
array.sort(function(a,b){return b-a;});

what would a and b be replaced as?

Sam Fisk
@Neofish22
Nov 29 2016 04:00
@Ezeboy Your string contains those characters but they are not 'escaped' as the challenge requires.
silver537
@silver537
Nov 29 2016 04:00
@WilliamHuang1995 the first two elements of your array
William Huang
@WilliamHuang1995
Nov 29 2016 04:00
so 12-1 = 11
array.sort(11)?
Sam Fisk
@Neofish22
Nov 29 2016 04:01
@WilliamHuang1995 You would change it to { return a < b; } probably (maybe > instead).
silver537
@silver537
Nov 29 2016 04:01
a= 1
b= 12
b-a => 12 - 1 = 11
positive, so it stays the same
William Huang
@WilliamHuang1995
Nov 29 2016 04:01
but the result i get is
[21,12,2,1]
silver537
@silver537
Nov 29 2016 04:02
@WilliamHuang1995 oh yea. lol my bad
Sam Fisk
@Neofish22
Nov 29 2016 04:02
Negative is stay the same then :P
silver537
@silver537
Nov 29 2016 04:02
^
lol
sorry. like he said, it's better to use > or <
but i already understand a-b vs b-a
a-b is the ascending order
and
b-a is the descending order
Ezeboy
@Ezeboy
Nov 29 2016 04:03
what is those thing that not escaped? @Neofish22
Sam Fisk
@Neofish22
Nov 29 2016 04:03
\n and \ and \r
\\
Ezeboy
@Ezeboy
Nov 29 2016 04:04
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
tech-tron
@tech-tron
Nov 29 2016 04:04
"Do not hardcode any of the tests inside the function." what'oes this mean?
silver537
@silver537
Nov 29 2016 04:04
@WilliamHuang1995 you shouold read the docs. they explain it way better
silver537
@silver537
Nov 29 2016 04:04
yes
@tech-tron don't code it out yourswelf. let the computer do it
Ezeboy
@Ezeboy
Nov 29 2016 04:05
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \. @Neofish22
Zapp_Brannigan
@dggz93
Nov 29 2016 04:06
how i do the contacts loop without returns?
tech-tron
@tech-tron
Nov 29 2016 04:06
@silver537
Sam Fisk
@Neofish22
Nov 29 2016 04:06
@Ezeboy When you have just \n (etc) in a string, it evaluates to what \n means (a newline character). The task wants you to have the string containing "\" and "n" in sequence, which then would later turn into a \n. The way you do this is to 'escape' the \ with another \. E.g. \\n in your string
tech-tron
@tech-tron
Nov 29 2016 04:07
thx, @silver537
CamperBot
@camperbot
Nov 29 2016 04:07
tech-tron sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 792 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Nov 29 2016 04:07
@Ezeboy follow the table they provide.
Sam Fisk
@Neofish22
Nov 29 2016 04:07
(Had to edit that a couple times because this chat client also does escaping through \ :P)
silver537
@silver537
Nov 29 2016 04:08
@Neofish22 use inline snippets
Ezeboy
@Ezeboy
Nov 29 2016 04:08

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

can you tell me the right code for that. .tnx . .myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
silver537
@silver537
Nov 29 2016 04:09
@Ezeboy ok so what you do is go to the table
search for newline
and replace the text newline for the actual code. do the same for
backslash replace text with the code.
so on and so forth
Sam Fisk
@Neofish22
Nov 29 2016 04:11
@Ezeboy You sent earlier: var myStr = "\nFirstLine\\SecondLine\\rThirdLine."; You're only missing one backslash here.
silver537
@silver537
Nov 29 2016 04:11
na. got the newline in the wrong place
Sam Fisk
@Neofish22
Nov 29 2016 04:11
And that but it doesn't look like it tests for that... It does :p
silver537
@silver537
Nov 29 2016 04:12
cant wait for the new FCC update
:P
Sam Fisk
@Neofish22
Nov 29 2016 04:13
Actually have my own question about the wording/tests for an advanced challenge...
silver537
@silver537
Nov 29 2016 04:13
which one?
dude have you noticed, none of these people thanked us for helping them?
psh.
Sam Fisk
@Neofish22
Nov 29 2016 04:14
:P I had. Oh well
Some did earlier
silver537
@silver537
Nov 29 2016 04:14
im late on that ha
Dusliat
@Alchemistioc
Nov 29 2016 04:14

I'm back! I changed it so much, but the instructions only go so far. Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable. I got this so far:```function phoneticLookup(val) {
var result = "";

// Only change code below this line
var Lookup(val)={
'alpha':"Denver",
'bravo':"Boston",
'charlie':"Chicago",
'delta':"Denver",
'echo':"Easy",
'foxtrot':"Frank",
};
//change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");```

silver537
@silver537
Nov 29 2016 04:15
woah woah
you took out the function
oh wait, there it is
hahah
@Alchemistioc format your code like this:
``` <- 3 backticks intheir OWN line
code
``` <- close with backticks in their OWN line
Adam
@Adkstein
Nov 29 2016 04:17
@HelioRochaCardoso oh my goodness.... i just figured it out. I was over thinking what I had to do and totally ignored the setup as part of what I was suppose to consider... lol. thanks for your help :)
CamperBot
@camperbot
Nov 29 2016 04:17
adkstein sends brownie points to @heliorochacardoso :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @heliorochacardoso |http://www.freecodecamp.com/heliorochacardoso
Sam Fisk
@Neofish22
Nov 29 2016 04:17
@Alchemistioc Also if you press the up key you can edit your messages, which will help with making the adjustment silver just suggested.
Dusliat
@Alchemistioc
Nov 29 2016 04:17
Thanks @silver537
CamperBot
@camperbot
Nov 29 2016 04:17
alchemistioc sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 793 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Nov 29 2016 04:18
this: var Lookup(val) is bad syntax
remember, parenthesis indicate functions
Lookup is an object, not a function
im pretty sure they showed you how to grab object properties with variable in the previous challenge.
kinda like arrays
brackets?d
dring a bell?
wtf..
cant spell for shit man
Sam Fisk
@Neofish22
Nov 29 2016 04:24

I'm confused with the wording of No repeats please. I thought I understood the general premise until looking at the final test. permAlone('aaabb'). It has only 1 possible combination that doesn't have repeats ("ababa") out of 12, so presumably I've totally misunderstood what it means by 'repeat' (the answer is 12).

The description does seem to be partially contradicting itself: 2nd sentence says "assume that all characters in the string are unique"; if you did that then there would be no concept of repeating. I considered that it might actually mean permutations when it says it and they are unique, so you could have repeats, but it would only depend on length of string, and one of the examples ("zzzzzz"etc) would not be 0.

silver537
@silver537
Nov 29 2016 04:27
unique as in aab where it has two answers, aba and aba in the sense that both of those are unique and not the same. because when you look at it in numbers of appearance.
a1a2b1 => a1b1a2 and a2b1a1
Sam Fisk
@Neofish22
Nov 29 2016 04:28
Oh yeah so in my example ababa it's a1b1a2b2a3 with the numbers switching 12 times...
silver537
@silver537
Nov 29 2016 04:29
well no necessarily, since that only happens once.
Doug
@doug20000
Nov 29 2016 04:29

So I'm having trouble: I have a variable that equals an array. I've set a new var, (var2), to equal the contents of var1.reverse()

This I though would give me two variables, one with an array one way and the other with the array reversed. However for some reason after I set var2 value, var1 will also show as reversed

silver537
@silver537
Nov 29 2016 04:29
oh wait... yes
Sam Fisk
@Neofish22
Nov 29 2016 04:30
XD phew :p
silver537
@silver537
Nov 29 2016 04:30
lol
Sam Fisk
@Neofish22
Nov 29 2016 04:30
Did you solve it programmatically or with maths? :P
Clifton Hutchins
@cliftonh02
Nov 29 2016 04:30
can someone help me with "Make Instances of Objects with a Constructor Function"
silver537
@silver537
Nov 29 2016 04:30
maths
Kevin Anderson
@LemonStain
Nov 29 2016 04:30
Hello Friends. I am having some trouble with "Using Objects for Lookups". I appear to have the object set up but I think I am not creating it with the right name.
Sam Fisk
@Neofish22
Nov 29 2016 04:31
Cool, will do that then. When trying to find explanation of the description I found people saying don't bother if you're not capable of doing the maths, though I wouldn't ever want to try something so expansive as this programmatically. :P
Thanks @silver537 :)
CamperBot
@camperbot
Nov 29 2016 04:31
neofish22 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 794 | @silver537 |http://www.freecodecamp.com/silver537
Clifton Hutchins
@cliftonh02
Nov 29 2016 04:31

var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 5;
};

// Only change code below this line.

var myCar = new Car();
myCar.nickName = "craig";

silver537
@silver537
Nov 29 2016 04:32
@Neofish22 lol i just looked at the challenge. you confused me dude
>.<
David S.
@reydavid
Nov 29 2016 04:32
Hello. On "Increment a Number with JavaScript" and can't get the variable to match up.
Clifton Hutchins
@cliftonh02
Nov 29 2016 04:32
says i need to give myCar a nickname property but doesnt work
Sam Fisk
@Neofish22
Nov 29 2016 04:33
@doug20000 reverse() works "in-place" meaning it modifies the existing array. You'll have to copy it if you want both. I think clone() is what you want to call first.
Doug
@doug20000
Nov 29 2016 04:33
@Neofish22 ah ha! I see, thanks mate!
CamperBot
@camperbot
Nov 29 2016 04:33
doug20000 sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 288 | @neofish22 |http://www.freecodecamp.com/neofish22
Justin Castro
@justmcastro
Nov 29 2016 04:34

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.length; j++) {
         console.log(arr[i][j]);
         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]]);
need help with this one, end up getting 7.
multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
Sam Fisk
@Neofish22
Nov 29 2016 04:35
@cliftonh02 I'll try and find the challenge but it might be that the property it expects is "nickname" not "nickName" :)
Dusliat
@Alchemistioc
Nov 29 2016 04:35
@silver537 almost there. Looked at the previous challenges as reference.I got this:phoneticLookup.val=Lookup["charlie"];
tech-tron
@tech-tron
Nov 29 2016 04:35
I come from a c++ background so the only return I know is return 0, why does java return elements? whats the point? why not just call the element before the return?
silver537
@silver537
Nov 29 2016 04:36
@cliftonh02 yea its the nickname property. no camelcasing!!!
@Alchemistioc noooooooooooo
phoneticLookup is the name of the function
try
answer = Lookup[val]
David S.
@reydavid
Nov 29 2016 04:38

myVar needs to increment to 88. var myVar = 87;

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

silver537
@silver537
Nov 29 2016 04:38
@Reydavid no code, no help :P
damn it
you beat me to it :P
David S.
@reydavid
Nov 29 2016 04:38
Can't figure out how to return to new line in this chat.
silver537
@silver537
Nov 29 2016 04:39
@justmcastro you're supposed to be multiplying the product variable.
everything is right, it's just one symbol you are forgetting
@Reydavid shift+enter
David S.
@reydavid
Nov 29 2016 04:39
@silver537 Cool.
Dusliat
@Alchemistioc
Nov 29 2016 04:40
@silver537 it works. Just like the line I pasted on here. The only problem is, to pass the challenge it needs to recognize phoneticLookup("")
Sam Fisk
@Neofish22
Nov 29 2016 04:40
@tech-tron Generally speaking if you had any function you'd return something meaningful. I'm guessing by return 0 you mean the return value in main(). Breaking functionality up into functions is generally sensible way to keep things tidier and resuable and not otherwise confusing.
Not sure if that'll answer your question, could you elaborate?
silver537
@silver537
Nov 29 2016 04:40
@Reydavid the ++ operator is shorthand for var = var + 1
so instead of typing all of that just fo var++
no need to assign anything
Sam Fisk
@Neofish22
Nov 29 2016 04:41
@Alchemistioc You need to handle that case specifically. When you look up something in the dictionary object and it isn't there it will return undefined, so you should check for that and return what it wants instead.
tech-tron
@tech-tron
Nov 29 2016 04:42
@Neofish22
Clifton Hutchins
@cliftonh02
Nov 29 2016 04:45
@Neofish22 @silver537 cool ill try it out thanks
CamperBot
@camperbot
Nov 29 2016 04:45
cliftonh02 sends brownie points to @neofish22 and @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @neofish22 |http://www.freecodecamp.com/neofish22
:cookie: 795 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Nov 29 2016 04:45
@tech-tron if you're talking about this language as in JavaScript. then unfortunately your association is wrong.
JavaScript and Java are two separate languages and have nothing to do with each other.
David S.
@reydavid
Nov 29 2016 04:45

@silver537

myVar=87;
myVar=myVar++; //my attempt

result: myVar=87, still. I've tried "myVar=++myVar;" but still doesn't satisfy the check.

silver537
@silver537
Nov 29 2016 04:46
if we broke up your attempt:
myVar=myVar++
it will look like this
myVar=myVar=myVar+1
now that doesn't look right
David S.
@reydavid
Nov 29 2016 04:47
Ah, so maybe myVar++; ?
Sam Fisk
@Neofish22
Nov 29 2016 04:47
Yep
silver537
@silver537
Nov 29 2016 04:47
and thats all she wrote!
Clifton Hutchins
@cliftonh02
Nov 29 2016 04:47
@Neofish22 @silver537 worked guys thanks a bunch!!
CamperBot
@camperbot
Nov 29 2016 04:47
cliftonh02 sends brownie points to @neofish22 and @silver537 :sparkles: :thumbsup: :sparkles:
:warning: cliftonh02 already gave neofish22 points
:warning: cliftonh02 already gave silver537 points
Sam Fisk
@Neofish22
Nov 29 2016 04:47
You're welcome @cliftonh02 :)
David S.
@reydavid
Nov 29 2016 04:47
@silver537 Yup, Thanks!
CamperBot
@camperbot
Nov 29 2016 04:47
reydavid sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 796 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Nov 29 2016 04:48
@Reydavid no problem
tech-tron
@tech-tron
Nov 29 2016 04:48
@Neofish22
i just don't get what return means in java. in c++ it was just something i used to end the main function and in my last mission it had me return arr.shift();
i got stuck forever because it just doesn't make since to me to do that. is there a special reason to use return
silver537
@silver537
Nov 29 2016 04:49
sigh
Manish Giri
@Manish-Giri
Nov 29 2016 04:50
@tech-tron return means the same everywhere
Sam Fisk
@Neofish22
Nov 29 2016 04:50
return in C++ is actually very similar to javascript (not java ;) ), but as you say you're only used to it ending main. Functions 'return' a value, so lets say function someComplexMaths(a,b,c) { var res = ...; return res; } the return statement allows us to get a value from the inside of a function. By subdividing everything into functions it keeps things more neat.

So you could then have something like console.log('Result of complex maths on '+a+', '+b+', '+c+' is: '+someComplexMaths(a,b,c));

Importantly, it's used everywhere; there are cases where you wont use it but it simply terminates /any/ function, rather than just the main one

Kevin Anderson
@LemonStain
Nov 29 2016 04:53
How do I paste code? Is this like slack?
silver537
@silver537
Nov 29 2016 04:53
no its markdown
idk what slack is
Sam Fisk
@Neofish22
Nov 29 2016 04:54
Slack is a chat thing
silver537
@silver537
Nov 29 2016 04:54
oh.
Sam Fisk
@Neofish22
Nov 29 2016 04:54
@LemonStain You can see info for that from a little "M" button in the bottom right.
Kevin Anderson
@LemonStain
Nov 29 2016 04:54
see it now - thanks
Dusliat
@Alchemistioc
Nov 29 2016 04:57
I got it! Thanks Sam Fisk and @silver537!!
CamperBot
@camperbot
Nov 29 2016 04:57
alchemistioc sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:warning: alchemistioc already gave silver537 points
Doug
@doug20000
Nov 29 2016 04:59
I'm on the Check for Palindromes exercise and my code is failing. Can't figure out why. Anyone point me in the right direction?

function palindrome(str) {
  // Good luck!

  var lowerCase = str.toLowerCase(); //Make string lowercase
  var myArr = lowerCase.split(""); //Make string an array

  var formatArr = myArr.filter(function(val) { //Filters out spaces
  return val !== " "; 
  }); 

  var reversedArr = formatArr.slice().reverse(); //Reverses the array

  if (reversedArr === formatArr) { //Compares the arrays but always returns false
    return true;
  }
  else {
    return false;
  } 
}

palindrome("raceCar");
silver537
@silver537
Nov 29 2016 04:59
@Neofish22 have you gotten into any frameworks yet?
bad slice
no need for filter
and no need for that if/else
tech-tron
@tech-tron
Nov 29 2016 05:01
@Neofish22 thanks, you've been super helpful
CamperBot
@camperbot
Nov 29 2016 05:01
tech-tron sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @neofish22 |http://www.freecodecamp.com/neofish22
Sam Fisk
@Neofish22
Nov 29 2016 05:01
You're welcome :)
silver537
@silver537
Nov 29 2016 05:02
ah i cant multitask
im trying to play pool and code at the same time.
>.<
Abhisek Pattnaik
@abhisekp
Nov 29 2016 05:03
@LemonStain
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
@silver537 is that you?
silver537
@silver537
Nov 29 2016 05:03
yes sir
caught you off guard? ;)
Sam Fisk
@Neofish22
Nov 29 2016 05:03
@silver537 Not with FCC but I'm already familiar with Backbone and Angular. Only really doing the course for fun, the certification, a couple bits n pieces I've not done, the charity bits at end for verifiable experience and folio stuffs.
silver537
@silver537
Nov 29 2016 05:04
ah.
im still on the weather challenge :P
been on that one for like 3 months now hehe
mainly cause ive been procrastinating learning a framework
Sam Fisk
@Neofish22
Nov 29 2016 05:05
:P Tbf if you're doing something vaguely productive it's not really procrastination
Which are you learning?
Abhisek Pattnaik
@abhisekp
Nov 29 2016 05:06

Are you feeling awkward with Bootstrap?

Give all your worries to Bulma - a modern CSS framework.
feel the change, feel the new experience ;)

// cc @0x0936

Alejandro Tejada
@wannabecoding
Nov 29 2016 05:07
Can I get some guidance here? Record collection has been kicking my ass for a few days now...
function updateRecords(id, prop, value) {
  if (prop !== "tracks" && value !== false) {
    collection[id][prop] = value;
  }
  else if (prop === "tracks" && collection[id].hasOwnProperty(prop) === false) {
    collection[id][prop] = [];
    collection[id][prop].push(value);
  } else if (prop === "tracks" && value !== false) {
    collection[id][prop].push(value);
  } else if (collection[id][prop].hasOwnProperty(value) === false) {
    delete collection[id][prop];
  }

  return collection;
}
Ming Albert Yue
@mingyuea
Nov 29 2016 05:08
hello, in need of help, any assistance would be welcome!
Justin Castro
@justmcastro
Nov 29 2016 05:08
@wannabecoding re read the last else if
Sam Fisk
@Neofish22
Nov 29 2016 05:09
@mingyuea Go ahead :)
Ming Albert Yue
@mingyuea
Nov 29 2016 05:09

function truncateString(str, num) {
var newString;
if(num >= 3){
newString=str.substring(0, num-3);
}
else{
newString=str.substring(0, num);
}

            str=newString+"...";
            return str;
        }

truncateString("A-tisket a-tasket A green and yellow basket", 11);

Alejandro Tejada
@wannabecoding
Nov 29 2016 05:09
is it my condition?
tech-tron
@tech-tron
Nov 29 2016 05:09
i like how javascript has a lot in common with c++ is this because they are both object oriented programs
Ming Albert Yue
@mingyuea
Nov 29 2016 05:09
ah that didnt come out how i intended it. but its for the truncate a string challenge
Sam Fisk
@Neofish22
Nov 29 2016 05:09
Just reading it over now :)
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:10
@justmcastro is it my condition?
puchinepip
@puchinepip
Nov 29 2016 05:10
I need help
please I'm stuck in this activity
silver537
@silver537
Nov 29 2016 05:11
no code no help
Ming Albert Yue
@mingyuea
Nov 29 2016 05:12
i think i might've misunderstood the question. I thought all strings that are returned are supposed to end with a ...
Justin Castro
@justmcastro
Nov 29 2016 05:12
@wannabecoding If value is empty (""), delete the given prop property from the album.
Sam Fisk
@Neofish22
Nov 29 2016 05:12
@mingyuea You need to add a case where the string is shorter or equal to the limit, and not add the ...
Indeed :)
agusprieto
@agusprieto
Nov 29 2016 05:12
hi guys
vaishnavi prasad
@vaishnaviprasad
Nov 29 2016 05:12
Hi guys ,
agusprieto
@agusprieto
Nov 29 2016 05:12
this is driving me crazy haha
vaishnavi prasad
@vaishnaviprasad
Nov 29 2016 05:12
can some one help me with this
agusprieto
@agusprieto
Nov 29 2016 05:12

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

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

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);
where is my mistake?
Ming Albert Yue
@mingyuea
Nov 29 2016 05:13

function truncateString(str, num) {
var newString;
if(num >= 3){
newString=str.substring(0, num-3);
}
else{
newString=str.substring(0, num);
}

            str=newString+"...";
            return str;
        }

truncateString("A-tisket a-tasket A green and yellow basket", 11);

Sam Fisk
@Neofish22
Nov 29 2016 05:13
@agusprieto You've misspelt length on the second for
agusprieto
@agusprieto
Nov 29 2016 05:14
@Neofish22 :O
@Neofish22 thanks a lot !
CamperBot
@camperbot
Nov 29 2016 05:14
agusprieto sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @neofish22 |http://www.freecodecamp.com/neofish22
Sam Fisk
@Neofish22
Nov 29 2016 05:14
You're welcome :)
Ming Albert Yue
@mingyuea
Nov 29 2016 05:14
@Neofish22 sorry, a little new to gitter, im not sure how to exactly format it so it all looks like code, but i did indeed include an if statement when num>=3 and an else statement otherwhise
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:15
@justmcastro I get that. So that means an empty value doesn't equal a false boolean then
@justmcastro which is how I have it now
Sam Fisk
@Neofish22
Nov 29 2016 05:16
You have to put 3 backticks on their own line, then the code, then 3 more backticks on their own line. ```
silver537
@silver537
Nov 29 2016 05:16
@Neofish22 oh shit i forgot to answer you. xD im learning the Vue framework
Sam Fisk
@Neofish22
Nov 29 2016 05:16
:P I've not heard of it. Any good?
silver537
@silver537
Nov 29 2016 05:16
yea supposedly it's like angular and react but lighter and better
lol
Sam Fisk
@Neofish22
Nov 29 2016 05:16
Nice :)
Justin Castro
@justmcastro
Nov 29 2016 05:16
@wannabecoding if the value is empty ("")
mcrea2610
@mcrea2610
Nov 29 2016 05:17
'''
CamperBot
@camperbot
Nov 29 2016 05:17
:bulb: to format code use backticks! ``` more info
silver537
@silver537
Nov 29 2016 05:17
actually no. it COMBINES both. into something lighter and better
Sam Fisk
@Neofish22
Nov 29 2016 05:17

@mingyuea If you go back to the code you had before:

function truncateString(str, num) {
  var newString;
  if(num >= 3){
    newString=str.substring(0, num-3);
  } else{
    newString=str.substring(0, num);
  }
  str=newString+"...";
  return str;
}

You ought to add an if (...) { ... } else before all the others, which returns str without modification when it is shorter or equal to the limit

silver537
@silver537
Nov 29 2016 05:18
i found it easier to learn. i couldn't understand angular for crap. -
Sam Fisk
@Neofish22
Nov 29 2016 05:18
Strange, I'll look it up.
I quite liked angular but services felt weird to me
a-pett
@a-pett
Nov 29 2016 05:18
I'm totally stuck on Accessing Nested Objects anyone have any pointers
Robert Richey
@0x0936
Nov 29 2016 05:18
@abhisekp :clap: thanks
CamperBot
@camperbot
Nov 29 2016 05:18
0x0936 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3229 | @abhisekp |http://www.freecodecamp.com/abhisekp
Justin Castro
@justmcastro
Nov 29 2016 05:19
@wannabecoding try rewriting the last one one word by word. maybe that will help.
Sam Fisk
@Neofish22
Nov 29 2016 05:19
I think I see the issue on that now. :P
a-pett
@a-pett
Nov 29 2016 05:21
Never mind got it :D
Sam Fisk
@Neofish22
Nov 29 2016 05:21
:)
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:21
@justmcastro this helped me out with the others... if value is empty, delete the prop, that's what it requests
@justmcastro originally i tried
```
Manish Giri
@Manish-Giri
Nov 29 2016 05:21
@Neofish22 did you do ng2 as well?
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:22
@justmcastro
if (value === "") {
Sam Fisk
@Neofish22
Nov 29 2016 05:22
Naw but friend of mine has been raving about it. Will learn it eventually but it's changed enough in the time he's been using it to be inconvenient. :P Yourself?
Justin Castro
@justmcastro
Nov 29 2016 05:23
@wannabecoding almost missing a word before if and
vaishnavi prasad
@vaishnaviprasad
Nov 29 2016 05:23

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

  result= myNoun+myAdjective+myVerb+myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function

wordBlanks("cat", "little", "hit", "slowly");
Hi
Justin Castro
@justmcastro
Nov 29 2016 05:23
you just need to finish the last part @wannabecoding
vaishnavi prasad
@vaishnaviprasad
Nov 29 2016 05:23
Its from the word blasnks
*blanks
exercise
masterkoda
@masterkoda
Nov 29 2016 05:24

hi can anybody explain how previousVal/currentVal takes values from the array??are they predefined??var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

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

Alejandro Tejada
@wannabecoding
Nov 29 2016 05:24
else if, is that what you mean? I meant to write that originally, don't follow you when you say last part, tbh @justmcastro
Sam Fisk
@Neofish22
Nov 29 2016 05:24
@vaishnaviprasad You're doing more than you need to in your code snippet; you're overwriting each of the parameters with those strings, where you actually don't need to change them at all.
@justmcastro Looks to me like it shouldnt be hasOwnProperty(value)
Aarya Bhorra
@aarya1302
Nov 29 2016 05:25
@masterkoda this will be helpful
Justin Castro
@justmcastro
Nov 29 2016 05:26
wrong person xD
Sam Fisk
@Neofish22
Nov 29 2016 05:26
@vaishnaviprasad That is to say, the result= ... line is all that you needed to add.
Naw I messaged you specifically because I didn't want to confuse in case I'm wrong
vaishnavi prasad
@vaishnaviprasad
Nov 29 2016 05:26
@Neofish22 I would like to better understand the exercide
Can i pm u @Neofish22
Justin Castro
@justmcastro
Nov 29 2016 05:27
@wannabecoding what do you have now?
Sam Fisk
@Neofish22
Nov 29 2016 05:27
Sure.
Aarya Bhorra
@aarya1302
Nov 29 2016 05:28
hey guys I'm trying to learn bitwise operators and codeacademy is the only interactive course that I can get but I don't understand this exercise: https://www.codecademy.com/en/courses/introduction-to-bitwise-operators/1/1#
puchinepip
@puchinepip
Nov 29 2016 05:28
console.log();
Aarya Bhorra
@aarya1302
Nov 29 2016 05:28
I don't know what to do please help
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:28
@justmcastro
else if (value === "" && collection[id].hasOwnProperty[prop]) {
    delete collection[id][prop];
honestly just throwing things at it at this point
Justin Castro
@justmcastro
Nov 29 2016 05:28
@wannabecoding If value is empty (""), delete the given [prop] property from the album.
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:29
@justmcastro I follow that
Justin Castro
@justmcastro
Nov 29 2016 05:29
@wannabecoding you don't need && collection[id].hasOwnProperty[prop]
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:31
it was the order of my conditions...
want to pull my hair out after all this
@justmcastro thanks
CamperBot
@camperbot
Nov 29 2016 05:31
wannabecoding sends brownie points to @justmcastro :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @justmcastro |http://www.freecodecamp.com/justmcastro
vaishnavi prasad
@vaishnaviprasad
Nov 29 2016 05:32
@Neofish22 thanks
CamperBot
@camperbot
Nov 29 2016 05:32
vaishnaviprasad sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @neofish22 |http://www.freecodecamp.com/neofish22
vaishnavi prasad
@vaishnaviprasad
Nov 29 2016 05:32
I got it
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:32
FYI - this passed the test
function updateRecords(id, prop, value) {
  if (value === "") {
    delete collection[id][prop];
  }
  else if (prop !== "tracks" && value !== false) {
    collection[id][prop] = value;
  }
  else if (prop === "tracks" && collection[id].hasOwnProperty(prop) === false) {
    collection[id][prop] = [];
    collection[id][prop].push(value);
  } else if (prop === "tracks" && value !== false) {
    collection[id][prop].push(value);
  } 

  return collection;
}
Sam Fisk
@Neofish22
Nov 29 2016 05:32
Ah cool :)
sainijassi
@sainijassi
Nov 29 2016 05:32
hlo any one help me
i want to know the >=
Comparison with the Greater Than Or Equal To Operator
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:33
FCC saves my submissions, right?
Justin Castro
@justmcastro
Nov 29 2016 05:33
@wannabecoding no problem :+1:
sainijassi
@sainijassi
Nov 29 2016 05:33
they say to do testGreaterOrEqual(0) should return "9 or Under"
testGreaterOrEqual(9) should return "9 or Under"
testGreaterOrEqual(10) should return "10 or Over"
testGreaterOrEqual(11) should return "10 or Over"
testGreaterOrEqual(19) should return "10 or Over"
testGreaterOrEqual(100) should return "20 or Over"
testGreaterOrEqual(21) should return "20 or Over"
You should use the >= operator at least twice

function testGreaterOrEqual(val) {
if (val) { // Change this line
return "20 or Over";
}

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

return "9 or Under";
}

// Change this value to test
testGreaterOrEqual(10);

in this code
now how i get this
help me
CamperBot
@camperbot
Nov 29 2016 05:34

:point_right: readme [wiki]

Depecrated Wiki!

This repo serves as an archive for the wiki and a place to report issues for our current wiki located in our forum!

Our open source community's Wiki focuses on answering your questions about learning to code and getting a coding job. We also cover in detail our:

  • Curriculum
  • Other Programming Languages
  • Local Group Communities
  • Nonprofit Projects and much more

:pencil: read more about readme on the FCC Wiki

Sam Fisk
@Neofish22
Nov 29 2016 05:34
@wannabecoding it saves them in LocalStorage in your browser, so will stay on your computer but isn't accessible elsewhere. You can in theory copy the URL when it's full of mess
sainijassi
@sainijassi
Nov 29 2016 05:34
any one
help me
CamperBot
@camperbot
Nov 29 2016 05:34

:point_right: readme [wiki]

Depecrated Wiki!

This repo serves as an archive for the wiki and a place to report issues for our current wiki located in our forum!

Our open source community's Wiki focuses on answering your questions about learning to code and getting a coding job. We also cover in detail our:

  • Curriculum
  • Other Programming Languages
  • Local Group Communities
  • Nonprofit Projects and much more

:pencil: read more about readme on the FCC Wiki

a-pett
@a-pett
Nov 29 2016 05:34
@sainijassi if (val>=20)
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:34
@Neofish22 ok, I just want to be able to refer to them again in the future, some of these recent ones are really taking atoll on me
sainijassi
@sainijassi
Nov 29 2016 05:35
yes i do @a-pett now for next
a-pett
@a-pett
Nov 29 2016 05:36
same thing for the next if (val >=10)
sainijassi
@sainijassi
Nov 29 2016 05:36
yes it work's
thank u @a-pett
CamperBot
@camperbot
Nov 29 2016 05:36
sainijassi sends brownie points to @a-pett :sparkles: :thumbsup: :sparkles:
:cookie: 210 | @a-pett |http://www.freecodecamp.com/a-pett
Sam Fisk
@Neofish22
Nov 29 2016 05:36
They'll stay on your PC indefinitely if you don't wipe it or remove your browser or clearing your cookies/etc. With the latter one it's quite volatile, so it might be a good idea to save them somewhere.
a-pett
@a-pett
Nov 29 2016 05:36
no problem :D happy to help
sainijassi
@sainijassi
Nov 29 2016 05:36
thanks a lot
Callum King
@callum-king
Nov 29 2016 05:37
@sainijassi I would recommend going over the conditional statement lessons again if you are unable to grasp them, otherwise you'll become really stuck in a few lessons time.
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:38
@Neofish22 hmmm, going to have to start saving them I use different computers depending where I'm at and don't necessarily have this type of control over all of the,
them*
Aarya Bhorra
@aarya1302
Nov 29 2016 05:38
hey guys I'm trying to learn bitwise operators and codeacademy is the only interactive course that I can get but I don't understand this exercise: https://www.codecademy.com/en/courses/introduction-to-bitwise-operators/1/1#
Sam Fisk
@Neofish22
Nov 29 2016 05:42
@wannabecoding Fair few ways you could preserve it, each with their advantages/disadvantages. Git/Dropbox/USB stick/synced-webbrowser bookmarks, etc
@aarya1302 Just having a look. I've written what I think is the solution but it doesn't say I'm doing it right :P
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:45
@Neofish22 will be my first repo that I contribute to :)
Sam Fisk
@Neofish22
Nov 29 2016 05:46
@wannabecoding :D Really pays to get used to using git, tis great :D
Ok @aarya1302 Ive got it. Do you have any existing code for this?
Alejandro Tejada
@wannabecoding
Nov 29 2016 05:47
@Neofish22 I'd imagine you recommend the actual command line over the Github client with the GUI
Sam Fisk
@Neofish22
Nov 29 2016 05:48
For saving these, it's probably actually better to use the web client for github; more direct and can access anywhere. But, yep definitely. :P I'm using gitlab.com too; little bit more favourable for free private repos.
masterkoda
@masterkoda
Nov 29 2016 05:48
thank you so much @aarya1302
CamperBot
@camperbot
Nov 29 2016 05:48
masterkoda sends brownie points to @aarya1302 :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @aarya1302 |http://www.freecodecamp.com/aarya1302
Teejay Parker
@TeejayParker
Nov 29 2016 05:49
I attribute this to it being late.. but I'm having difficulty on the "Concatenating Strings with the Plus Equals Operator" module.. for some reason.. this isn't working:
var myStr = "This is the first sentence. " += "This is the second sentence.";
Aarya Bhorra
@aarya1302
Nov 29 2016 05:50
@masterkoda you're welcome
@Neofish22 No I don't have any existing code I did not understand what it was asking
Sam Fisk
@Neofish22
Nov 29 2016 05:51
@TeejayParker += tries to modify a variable, but you're doing it to a string. It is technically valid syntax with other values (e.g. integers) but you probably never want to do it. You should have the +=... part on a new line with myStr preceding it, somewhat like the [I think] earlier exercise on adding numbers.
@aarya1302 It wants you to mask the last 3 binary digits of the input number so they are the only ones that remain in the resulting number (using binary and), and then display the result in binary.
Teejay Parker
@TeejayParker
Nov 29 2016 05:53
@Neofish22 Just odd since that is what it is telling me to do: "Instructions
Build myStr over several lines by concatenating these two strings:
"This is the first sentence. " and "This is the second sentence." using the += operator."
unless I'm just reading it wrong, which is entirely possible :P
Sam Fisk
@Neofish22
Nov 29 2016 05:53
"over several lines" :P
Teejay Parker
@TeejayParker
Nov 29 2016 05:53
ahh.. lol
whoops!
Sam Fisk
@Neofish22
Nov 29 2016 05:53
It should also be several statements, not one spread over several
Teejay Parker
@TeejayParker
Nov 29 2016 05:54
I think its time for these tired eyes to rest a bit. Thank you @Neofish22 :)
CamperBot
@camperbot
Nov 29 2016 05:54
teejayparker sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @neofish22 |http://www.freecodecamp.com/neofish22
Sam Fisk
@Neofish22
Nov 29 2016 05:54
You're welcome :)
@aarya1302 Did my explanation above make sense? (I'm also not sure you got notified about the message; I tagged wrong person at first)
Saiduk
@Saiduk
Nov 29 2016 05:57
Hey all. So, been hacking away at this for a while and got close, but no dice. The problem I see is with the second "for" loop. I know my code is probably way more complicated than it needs to be, but this is the best I got. Any help?
function titleCase(str) {
  var splitString = str.toLowerCase().split(" ");
  var titled = [];
  for (var i = 0; i < splitString.length; i++) {
    var upper = "";
    if (splitString[i][0] !== splitString[i][0].toUpperCase()) {
      upper = splitString[i][0].toUpperCase();
      if (upper === splitString[0][0].toUpperCase()) {
        titled.push(upper);
      } else {
      titled.push(" " + upper);
      }
    }
    for (var j = 0; j < splitString[i].length; j++) {
      if (splitString[i][j] !== splitString[i][0]) {
        titled.push(splitString[i][j]);

      }
    }
  }
  var unSplit = titled.join("");
  for (var k = 0; k < unSplit.length; k++) {

  }
  return unSplit;
}

titleCase("I'm a little tea pot");
//returns I'm A Litte Tea Pot
a-pett
@a-pett
Nov 29 2016 05:57
ok so I'm getting an error but I have no clue where to go from here
James
@jbonds08
Nov 29 2016 05:57

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


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



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
I need some help trying to figure this out. I am on the challenge of lookup.
a-pett
@a-pett
Nov 29 2016 05:57
blob
Aarya Bhorra
@aarya1302
Nov 29 2016 05:58
@Neofish22 I am sorry I don't think I got your explanation
Teejay Parker
@TeejayParker
Nov 29 2016 05:58
I swear I'm going to bed once I finish this module... but dang... I'm getting the correct output from the console, but it's still coming up with a red X on "build myStr with the += operator":
var myFirstSentence = "This is the first sentence. ";
var mySecondSentence = "This is the second sentence.";
var myStr = myFirstSentence += mySecondSentence;
a-pett
@a-pett
Nov 29 2016 05:58
anyone got any ideas of what is going wrong?
Sam Fisk
@Neofish22
Nov 29 2016 05:59
@TeejayParker End third statement before the +=. Start a 4th statment on next line beginning myStr += ... then you're done :) Don't usually want to be so direct but probably easier.
Teejay Parker
@TeejayParker
Nov 29 2016 06:00
Hmm.. I'll give that a go. :)
a-pett
@a-pett
Nov 29 2016 06:00
blob
I can't seem to get what is going wrong here
eusid
@eusid
Nov 29 2016 06:00
could someone explain to me why this is not shifting off the last two values for test #4 of drop it ?

function dropElements(arr, func) {
    for (var i = 0; i < arr.length; i++){
      if (func(arr[0]) === true) {
        break;
      } else {
        arr.shift();
      }
    }

  console.log(arr);
  return arr;
}
Sam Fisk
@Neofish22
Nov 29 2016 06:01
@aarya1302 Don't really want to give you the total solution. :p You need to create a 'mask' which when used with binary and (&) will allow the last 3 'bits' through. You create the mask very much like the first line (parseInt).
silver537
@silver537
Nov 29 2016 06:02
mask?
Aarya Bhorra
@aarya1302
Nov 29 2016 06:02
ok thanks @Neofish22
CamperBot
@camperbot
Nov 29 2016 06:02
aarya1302 sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 294 | @neofish22 |http://www.freecodecamp.com/neofish22
Aarya Bhorra
@aarya1302
Nov 29 2016 06:02
I'll try it
Sam Fisk
@Neofish22
Nov 29 2016 06:03
@Saiduk I highly recommend using functional methods split and join. From your existing code you don't need 3/4 of the end of the function :P You have split by word at the start, and only need to capitalise the first letter and then rejoin.
Teejay Parker
@TeejayParker
Nov 29 2016 06:04
OMG... @Neofish22 I'm such a derp. Thank you for your help. I was able to figure it out (totally missed the example they give you). Time for bed & do more code tomorrow! lol
CamperBot
@camperbot
Nov 29 2016 06:04
teejayparker sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:warning: teejayparker already gave neofish22 points
Sam Fisk
@Neofish22
Nov 29 2016 06:05
@jbonds It looks like your code is right except the 2 latter ifs need to go inside the loop, with the condition that is already in the loop coming last.
@TeejayParker You're welcome :)
Saiduk
@Saiduk
Nov 29 2016 06:07
@Neofish22 Yes, but I'm not sure exactly you to capitalize the first letter. I've tried looking for regular expressions to solve it, but I find all that a bit confusing. This complex monstrosity is the best I can think of :( Maybe I'm overlooking something really simple (I tend to over analyze things lol)
a-pett
@a-pett
Nov 29 2016 06:07
how do I take a snapshot of just the codebox?
Sam Fisk
@Neofish22
Nov 29 2016 06:07
Copy paste, and use 3 ` s on their own line before and after the code snippet. I'm looking at yours atm
@saiduk You can use split() with '' to split by character, and then toUpperCase :)
a-pett
@a-pett
Nov 29 2016 06:08
Awesome thanks.
Sam Fisk
@Neofish22
Nov 29 2016 06:09
It looks like you just need to make sure that when push()ing value on the last if statement, that the property already exists.
a-pett
@a-pett
Nov 29 2016 06:10
ok thanks
i'd give ya brownie points but i dont know how
Sam Fisk
@Neofish22
Nov 29 2016 06:10
So inside the else { ... } bit, you'd include another if statement
Tag me and say thanks :)
Adi2Point0
@Adi2Point0
Nov 29 2016 06:10
#Greed!
Aarya Bhorra
@aarya1302
Nov 29 2016 06:11
@Neofish22 Thank you again I understand now
CamperBot
@camperbot
Nov 29 2016 06:11
:warning: aarya1302 already gave neofish22 points
aarya1302 sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
Sam Fisk
@Neofish22
Nov 29 2016 06:11
You're welcome :)
Adi2Point0
@Adi2Point0
Nov 29 2016 06:11
I'm a sky full of stars!
a-pett
@a-pett
Nov 29 2016 06:11
@Neofish22 thank you!
CamperBot
@camperbot
Nov 29 2016 06:11
a-pett sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @neofish22 |http://www.freecodecamp.com/neofish22
Sam Fisk
@Neofish22
Nov 29 2016 06:13
@eusid Your code reads correctly for me, I'll quickly try
silver537
@silver537
Nov 29 2016 06:13
the thong th-thong-thong song.
xD
graalcloud
@graalcloud
Nov 29 2016 06:16
I got stuck on "Record Collection" on the javascript lessons
Sam Fisk
@Neofish22
Nov 29 2016 06:16
@eusid The way you've used the for loop whilst shortening the array would work if i never increased. By the time it gets to the 3 (3rd element) i is 2, but the length is also 2, so the for loop fails.
James
@jbonds08
Nov 29 2016 06:16
@Neofish22 thanks a lot
CamperBot
@camperbot
Nov 29 2016 06:16
jbonds08 sends brownie points to @neofish22 :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @neofish22 |http://www.freecodecamp.com/neofish22
graalcloud
@graalcloud
Nov 29 2016 06:16
havent progressed in days because of it
Sam Fisk
@Neofish22
Nov 29 2016 06:16
You're welcome. :)
@graalcloud I'll help in a minute if @silver537 hasn't by then. Need some code or you to describe the issue (or both)
Saiduk
@Saiduk
Nov 29 2016 06:17
@Neofish22 I assume that includes some sort of loop. But how do I avoid upper-casing all the other letters? Sorry if I sound stupid, I'm just not quite getting it
graalcloud
@graalcloud
Nov 29 2016 06:18
this lesson is just confusing. once i read the instructions it made me feel like i forgot everything i learned before this x.x
Sam Fisk
@Neofish22
Nov 29 2016 06:18
Ok so you've split by word, if you split by letter, you can edit the first letter with [0] (rather than iterating over all of them), then rejoin twice.
scketch88
@scketch88
Nov 29 2016 06:18
hey guys. im having a little trouble with "Assignmentwith a returned value". I'm not sure how to assign processArg to processed

var processed = 2;

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

Sam Fisk
@Neofish22
Nov 29 2016 06:23
@scketch88 Mine says // Only change code below this line so it seems to be asking you to change the parameter that the example calls, to give you the desired value
silver537
@silver537
Nov 29 2016 06:25
tbh i hate help with record collection.
Sam Fisk
@Neofish22
Nov 29 2016 06:25
Probably the one I dislike the most :p
silver537
@silver537
Nov 29 2016 06:25
it's exhausting
scketch88
@scketch88
Nov 29 2016 06:26
i have the desired value of 2. It then asks in the second part of the problem to assign "processArg" to "processed"
im lost on this part
silver537
@silver537
Nov 29 2016 06:27
whats different than assiging anything to anything?
the key word is assign
how do you assign?
=
Micah Lewis
@EastML
Nov 29 2016 06:28
Anybody have any tips on finding the least common multiple between several numbers challenge? I'm super lost
silver537
@silver537
Nov 29 2016 06:28
lcmSol.gif
Sam Fisk
@Neofish22
Nov 29 2016 06:29
You've done it in the wrong place. Rather than var processed = 2;, you're supposed to use the output of processed = processArg(..some number..);. To work out that number you should reverse the processArg function
Is it possible to solve the LCM one with maths? The requirement of several numbers threw me off
(My programmatic solution was v good though)
Guessing you'd generalise that eq like this: lcm(list) = mult(list)/gcd(list), but not sure
silver537
@silver537
Nov 29 2016 06:31
it was tricky
na it would be a recursive thing i think...
Sam Fisk
@Neofish22
Nov 29 2016 06:31
gcd is a similar problem for multiple numbers though XD
silver537
@silver537
Nov 29 2016 06:32
i forgot how i did it.
lemme check
Sam Fisk
@Neofish22
Nov 29 2016 06:32
Mines a while, a for loop, and very little storage :D
Micah Lewis
@EastML
Nov 29 2016 06:32
Yeah I think the way the problem is set up, shircuts using math don't work so well.
Did you use the while loop as a way to start counting multiples without having to worry about where to stop?
Sam Fisk
@Neofish22
Nov 29 2016 06:33
Well essentially the way to do it is to check each of the numbers given to see if they all divide cleanly into the number you're checking as the smallest common, and increment that number sensibly. Loads of different ways to implement that.
silver537
@silver537
Nov 29 2016 06:33
gcd was divding a number by the second number until you hit 0
Markus Kiili
@Masd925
Nov 29 2016 06:34
@Neofish22 There is a very simple recursive gcd solution to the challenge.
Sam Fisk
@Neofish22
Nov 29 2016 06:34
Cool