4th
May 2016
Travis
@dukenukethem
May 04 2016 00:00
Im not sure now that you mention it
I need to multiply that by the sub arrays of arr
Hassaan Hafeez
@HassHz
May 04 2016 00:00
j contains the value of the sub arrays
Daniel Godigna
@DGAcode
May 04 2016 00:00
Stuck here please some guidance " Stand in Line " JS
Hassaan Hafeez
@HassHz
May 04 2016 00:00
i contains the value of the array
@33hawk to remove any element that isn't the last element you use yourArray.switch();
to add an element to an array you do yourArray.push()
the previous challenges should've covered that
Travis
@dukenukethem
May 04 2016 00:01
I guess I'm a bit to dense right now to get what I want haha
OH
GOD
IM STUPID

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Hassaan Hafeez
@HassHz
May 04 2016 00:02
yes, but you don't have to do product = product =... just a simple product =
Travis
@dukenukethem
May 04 2016 00:03
What do you mean?
Angelo Ryndon
@AIRyndon
May 04 2016 00:03

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

for(var i = 0; i < arr.length; i++)
{
for(var j = 0;j < arr[i].length;j++){
product *= 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]]);

Travis
@dukenukethem
May 04 2016 00:03
ohhhhh
Okay I see what you mean after angelo posted
Angelo Ryndon
@AIRyndon
May 04 2016 00:03
@dukenukethem finished it in a few minutes :)
Daniel Godigna
@DGAcode
May 04 2016 00:03
@HassHz indeed I know that, but still... let me give it a try
Hassaan Hafeez
@HassHz
May 04 2016 00:03
Can you post what you have so far @33hawk?
Travis
@dukenukethem
May 04 2016 00:03
nesting for loops can SMD
Angelo Ryndon
@AIRyndon
May 04 2016 00:04
@Travis gj bro..btw how do we post like you do? My posts are all text..yours looks pretty hahaha
Travis
@dukenukethem
May 04 2016 00:04
you do js then
Diego Mayer
@Chrono79
May 04 2016 00:04
@AIRyndon
help format
CamperBot
@camperbot
May 04 2016 00:04

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

Travis
@dukenukethem
May 04 2016 00:04
then his shift + enter
Or that ^
Daniel Godigna
@DGAcode
May 04 2016 00:04
@HassHz give me a minute I will
Angelo Ryndon
@AIRyndon
May 04 2016 00:05
@dukenukethem Thanks :smile:
CamperBot
@camperbot
May 04 2016 00:05
airyndon sends brownie points to @dukenukethem :sparkles: :thumbsup: :sparkles:
Travis
@dukenukethem
May 04 2016 00:05
thank @Chrono79 @AIRyndon :p
CamperBot
@camperbot
May 04 2016 00:05
dukenukethem sends brownie points to @chrono79 and @airyndon :sparkles: :thumbsup: :sparkles:
Travis
@dukenukethem
May 04 2016 00:05
whoops.
I think I'm going to call it a night, the last 8 hours of challenges has been brain frying hehe. Have a good night everyone!
Diego Mayer
@Chrono79
May 04 2016 00:08
'nite
Moisés Man
@moigithub
May 04 2016 00:17
Daniel Godigna
@DGAcode
May 04 2016 00:19
how do I paste the region I did capture?
Tharun James
@xplorejames
May 04 2016 00:19

function translatePigLatin(str) {

var arr= str.split("");
var result;

var joi=["way"];
var jo=["ay"];

if(arr[0]=='a'||arr[0]=='e'||arr[0]=='i'||arr[0]=='o'||arr[0]=='u')
{
arr.push("way");
result=arr.join('');

}

else
{
var removed=arr.shift();

arr.push(removed);
arr.push("ay");

result=arr.join('');

}

return result;

}

translatePigLatin("glove")
Daniel Godigna
@DGAcode
May 04 2016 00:19
I'm slow today no luck and horrible code @HassHz
Tharun James
@xplorejames
May 04 2016 00:19
why im stuck reff Pig Latin
Hassaan Hafeez
@HassHz
May 04 2016 00:20
code format
help format
CamperBot
@camperbot
May 04 2016 00:20

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

Daniel Godigna
@DGAcode
May 04 2016 00:22
This message was deleted
Moisés Man
@moigithub
May 04 2016 00:23
@xplorejames IF start with CONsonant u should move ALL the consonants at start..untill u find a vowel to the end
so.... glove ------> ove gl ay
Daniel Godigna
@DGAcode
May 04 2016 00:23
This message was deleted

function nextInLine(arr, item) {
testArr.switch[1];
function nextInLine ( arr , item ) {
testArr.push[1];
return item;
}
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));

finally
Now i see I didn't understand the instructions then
Hassaan Hafeez
@HassHz
May 04 2016 00:25
There is no need for two function nextInLine's.. was that a typing error?
also, you are not pushing or switching correctly
both use ( ) brackets
Daniel Godigna
@DGAcode
May 04 2016 00:27
I thought the same
Hassaan Hafeez
@HassHz
May 04 2016 00:28
not [ ]
also you have to add the item passed to the function into the array, not add a 1.
Aryan
@aryandua
May 04 2016 00:30
var myStr = "I am a \"double quoted\" string inside \"double quotes\" "; // Change this line
i am supposed to make myStr assigned to- I am a "double quoted" string inside "double quotes"
What is wrong?!
Daniel Godigna
@DGAcode
May 04 2016 00:31
@aryandua try something like this " ' ' ' ' "
CamperBot
@camperbot
May 04 2016 00:31
:bulb: to format code use backticks!  more info
Aryan
@aryandua
May 04 2016 00:32
what?
Hassaan Hafeez
@HassHz
May 04 2016 00:33
what output are you getting @aryandua?
Aryan
@aryandua
May 04 2016 00:34
MyStr = I am a "double quoted" string inside "double quotes"
sysyphas
@sysyphas
May 04 2016 00:34
i'm working on the first algorithm, celsius/farenheit. It's a little tougher than I thought. First, do I make variables for celsius and farenheit and put it in the 'function' section of the code? second, would those variables be <!----
celsius = 30
Alexis
@alexisgcn
May 04 2016 00:34
help Repeat a string repeat a string
CamperBot
@camperbot
May 04 2016 00:34
no wiki entry for: repeat a string repeat a string
cdandro
@cdandro
May 04 2016 00:35
sysyphas
@sysyphas
May 04 2016 00:35
farenheit = (celsius * 9/5) + 32
Aryan
@aryandua
May 04 2016 00:35
very close @sysyphas
just... var farenheit = (celsius * 9/5) + 32;
You are missing the ; and var
sysyphas
@sysyphas
May 04 2016 00:35
and var celsius = 30
Aryan
@aryandua
May 04 2016 00:36
no
Hassaan Hafeez
@HassHz
May 04 2016 00:36
sysyphas
@sysyphas
May 04 2016 00:36
hmmm... why not var celsius = 30? i thought that is the temp we are trying to convert
Aryan
@aryandua
May 04 2016 00:37
@sysyphas when the function is called, it sends the vlaue 30
value
so you can call the function with any value
like...
FunctionName(30)
and
cdandro
@cdandro
May 04 2016 00:38
@aryandua Did you confirm that the initial value is celsius to begin with?
sysyphas
@sysyphas
May 04 2016 00:38
ok, ill be back, got to go back to work
A H
@allenhsieh
May 04 2016 00:39
Check for Palindromes
help Check for Palindromes
CamperBot
@camperbot
May 04 2016 00:39

# Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

• If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

Kelvin
@loweehahn
May 04 2016 00:39
Could anyone explain how this works?
$.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {$("body").append(a[0].content + "<p>&mdash; " + a[0].title + "</p>")
});
Aryan
@aryandua
May 04 2016 00:39
WHOA!
What is that?
Hassaan Hafeez
@HassHz
May 04 2016 00:39
@aryandua you simply have an extra space at the end of your string
Aryan
@aryandua
May 04 2016 00:39
oh
Hassaan Hafeez
@HassHz
May 04 2016 00:40
yeah it's pretty stupid lol
Aryan
@aryandua
May 04 2016 00:40
yeah
ientropic
@ientropic
May 04 2016 00:40
Hi everyone, I'm having trouble with "Testing Objects for Properties"
var myObj = {
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {

if (myObj.hasOwnProperty[checkProp]){
return result;
}else{
}

}
Aryan
@aryandua
May 04 2016 00:40
Freecodecamp too is just a website coded by a person
How is JS different from C except for syntax?
cdandro
@cdandro
May 04 2016 00:41
@ientropic you didn't set result to anything
ientropic
@ientropic
May 04 2016 00:41
@cdandro ah
cdandro
@cdandro
May 04 2016 00:41
@aryandua JS vs C is like asking car vs airplane
Aryan
@aryandua
May 04 2016 00:41
Where the car is...
cdandro
@cdandro
May 04 2016 00:41
@aryandua They will both get you places but have different purposes
Aryan
@aryandua
May 04 2016 00:42
I understand C much better than any other language
so I was hoping you could use either one
:)
ientropic
@ientropic
May 04 2016 00:42
@cdandro so my result should be something like
result = myObj[checkProp];
Chase Webb
@jerrybaggin
May 04 2016 00:42
function chunkArrayInGroups(arr, size) {
// Break it up.

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
This is the Chunky Monkey challenge, I believe i'm getting close. my current output is the first two index's a & b. but im not sure how to go about returning the second part into the same arrray?
Hassaan Hafeez
@HassHz
May 04 2016 00:43
cdandro
@cdandro
May 04 2016 00:43
@ientropic If you wanted to return the value for that key yes, you could just do a return myObj[checkProp] unless you need to do something else with the item first
Daniel Godigna
@DGAcode
May 04 2016 00:43

function nextInLine(arr, item) {
item = testArr.shift();
return item;  // Change this line

}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@HassHz ok I'm on the right way
ientropic
@ientropic
May 04 2016 00:44
thanks @HassHz
CamperBot
@camperbot
May 04 2016 00:44
ientropic sends brownie points to @hasshz :sparkles: :thumbsup: :sparkles:
ientropic
@ientropic
May 04 2016 00:44
@cdandro thanks, i'll keep looking at it
CamperBot
@camperbot
May 04 2016 00:44
ientropic sends brownie points to @cdandro :sparkles: :thumbsup: :sparkles:
Daniel Godigna
@DGAcode
May 04 2016 00:45
what should I do now make another function inside? @HassHz
ientropic
@ientropic
May 04 2016 00:45
i can get Not Found to show up just fine, but can't get the actual properties to return
Josue Godoy Lechuga
@josue1080
May 04 2016 00:45
help Return Largest Numbers in Arrays
CamperBot
@camperbot
May 04 2016 00:45

## :point_right: algorithm return largest numbers in arrays [wiki]

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

# :checkered_flag: Problem Explanation:

You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

cdandro
@cdandro
May 04 2016 00:45
@ientropic do the result like you showed, then just return it
CalebAllard
@CalebAllard
May 04 2016 00:46
I am stuck on the Seek and Destroy javascript part.
ientropic
@ientropic
May 04 2016 00:46

@cdandro when i run

  if (myObj.hasOwnProperty[checkProp]){
result = myObj[checkProp];
return result;

cdandro
@cdandro
May 04 2016 00:46
@jerrybaggin you need to use a loop to do complete the challenge
Hassaan Hafeez
@HassHz
May 04 2016 00:46
@33Hawk you got the removing correct, not you need to push the "item" into the array
.hasOwnProperty should have circle brackets I'm pretty sure @ientropic
Daniel Godigna
@DGAcode
May 04 2016 00:47
@HassHz item = testArr.push();
Josue Godoy Lechuga
@josue1080
May 04 2016 00:47
help Confirm the Ending
CamperBot
@camperbot
May 04 2016 00:47

# Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the confirmEnding('Bastian', 'n'); case.

Suren VB
@surenz298
May 04 2016 00:47
@CalebAllard - What is that you are struck bro
?
Hassaan Hafeez
@HassHz
May 04 2016 00:47
@HashHz no.
when you want to push, say 5 onto an array, you would do
yourArray.push(5)
Zaw Ye Htut
@yeyezaw
May 04 2016 00:48
Someone hint about factorialize number ?
CalebAllard
@CalebAllard
May 04 2016 00:48
how do I post my code so I can show you
cdandro
@cdandro
May 04 2016 00:48
@HassHz @ientropic HassHZ is correct, the hasOwnProperty(checkProp)
Hassaan Hafeez
@HassHz
May 04 2016 00:48
@CalebAllard help code format
i thought that would make the bot pop
Daniel Godigna
@DGAcode
May 04 2016 00:49
@HassHz thank you very much! I think I need more practice to remember all this that I know
cdandro
@cdandro
May 04 2016 00:49
@CalebAllard put the character to the left of the 1 before and after your code
CamperBot
@camperbot
May 04 2016 00:49
33hawk sends brownie points to @hasshz :sparkles: :thumbsup: :sparkles:
Josue Godoy Lechuga
@josue1080
May 04 2016 00:49
help Repeat a string repeat a string
CamperBot
@camperbot
May 04 2016 00:49

# Explanation:

The program is very simple, we have to take a variable and return that variable being repeated certain amount of times. No need to add space or anything, just keep repeating it into one single string.

ientropic
@ientropic
May 04 2016 00:49
@cdandro on the if statement or the result?
CalebAllard
@CalebAllard
May 04 2016 00:49

'
function destroyer(arr) {
var array = arguments[0];

var obj = { first:arguments[1],second:arguments[2]};

var result = array.filter(function(value){

if (value == this.first || value == this.second){
return true;
}

},obj);

return result;
}

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

cdandro
@cdandro
May 04 2016 00:50
@ientropic on the if
CalebAllard
@CalebAllard
May 04 2016 00:50
agh lol did not work
Hassaan Hafeez
@HassHz
May 04 2016 00:50
Also @33hawk you should not do "item = testArr.shift()" since item contains the number passed to the function. Instead make another variable
ientropic
@ientropic
May 04 2016 00:50
@cdandro @HassHz thanks a bunch!
CamperBot
@camperbot
May 04 2016 00:50
ientropic sends brownie points to @cdandro and @hasshz :sparkles: :thumbsup: :sparkles:
:warning: ientropic already gave cdandro points
:warning: ientropic already gave hasshz points
cdandro
@cdandro
May 04 2016 00:50
@CalebAllard not a quote the character to the left of the 1

Josue Godoy Lechuga
@josue1080
May 04 2016 00:51
help Truncate a string
CamperBot
@camperbot
May 04 2016 00:51

# Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

ientropic
@ientropic
May 04 2016 00:51
not sure why i wanted toput square brackets there
cdandro
@cdandro
May 04 2016 00:51
 <--notice the slant
' <--quote doesnt have the slant
CalebAllard
@CalebAllard
May 04 2016 00:51

function destroyer(arr) {
var array = arguments[0];

var obj = { first:arguments1,second:arguments2};

var result = array.filter(function(value){

if (value == this.first || value == this.second){
return true;
}

},obj);

return result;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);function destroyer(arr) {
var array = arguments[0];

var obj = { first:arguments1,second:arguments2};

var result = array.filter(function(value){

if (value == this.first || value == this.second){
return true;
}

},obj);

return result;
}

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


cdandro
@cdandro
May 04 2016 00:51
@ientropic honest mistake, [] are to get an item from something while () are to call a function
ientropic
@ientropic
May 04 2016 00:52
I'll keep that in mind for the future
Daniel Godigna
@DGAcode
May 04 2016 00:52
@HassHz thanks again
CamperBot
@camperbot
May 04 2016 00:52
33hawk sends brownie points to @hasshz :sparkles: :thumbsup: :sparkles:
:warning: 33hawk already gave hasshz points
cdandro
@cdandro
May 04 2016 00:52
@CalebAllard try 3 of them, if not just take a picture ;)
Josue Godoy Lechuga
@josue1080
May 04 2016 00:52
help Chunky Monkey
CamperBot
@camperbot
May 04 2016 00:52

# Explanation

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

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

CalebAllard
@CalebAllard
May 04 2016 00:53
function destroyer(arr) {
var array = arguments[0];

var obj = { first:arguments[1],second:arguments[2]};

var result = array.filter(function(value){

if (value == this.first || value == this.second){
return true;
}

},obj);

return result;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
cdandro
@cdandro
May 04 2016 00:53
@CalebAllard there it is!
CalebAllard
@CalebAllard
May 04 2016 00:53
there we go, all it does is return a array of [2,3,2,3]
not sure where im going wrong, and thanks @cdandro
CamperBot
@camperbot
May 04 2016 00:53
caleballard sends brownie points to @cdandro :sparkles: :thumbsup: :sparkles:
Josue Godoy Lechuga
@josue1080
May 04 2016 00:54
help Slasher Flick
CamperBot
@camperbot
May 04 2016 00:54

# Problem Explanation:

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

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

Stephen James
@sjames1958gm
May 04 2016 00:54
@CalebAllard You are filtering backwards
cdandro
@cdandro
May 04 2016 00:55
@CalebAllard your telling it to search the array and only return this.first or this.second
function RemoveItemsEqualToThis(val){
return val != this;
}
function destroyer(arr) {
for (var i=1;i<arguments.length;i++){
arr= arr.filter(RemoveItemsEqualToThis,arguments[i]);
}
return arr;
}
Stephen James
@sjames1958gm
May 04 2016 00:55
@CalebAllard if it matches you are supposed to destroy it
Josue Godoy Lechuga
@josue1080
May 04 2016 00:58
help Mutations
CamperBot
@camperbot
May 04 2016 00:58

# Problem Explanation:

• Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
Josue Godoy Lechuga
@josue1080
May 04 2016 01:00
help Falsy Bouncer
CamperBot
@camperbot
May 04 2016 01:00

# Problem Explanation:

Remove all falsy values from an array.

Josue Godoy Lechuga
@josue1080
May 04 2016 01:01
help Seek and Destroy
CamperBot
@camperbot
May 04 2016 01:01

# Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

Aparna
@Aparna-S
May 04 2016 01:02
help Using Objects for Lookups
CamperBot
@camperbot
May 04 2016 01:02

# Challenge: Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"
Josue Godoy Lechuga
@josue1080
May 04 2016 01:03
help Where do I belong
CamperBot
@camperbot
May 04 2016 01:03

# Explanation:

This can be a tricky problem to understand. You need to find where in the array a number should be inserted by order, and return the index where it should go.

Josue Godoy Lechuga
@josue1080
May 04 2016 01:05
help Caesars Cipher
CamperBot
@camperbot
May 04 2016 01:05

## :point_right: algorithm caesars cipher [wiki]

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

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take a string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Hassaan Hafeez
@HassHz
May 04 2016 01:12
How should I go about changing the first letter of every word in a string to upper case?
Anurag Lahon
@anuraglahon16
May 04 2016 01:14
how to check a palindrome?
eeflores
@eeflores
May 04 2016 01:14
@HassHz you'll need to reconstruct the string, so convert the first char using toUpperCase() and then I recommend googling "mdn array slice"
then assign to a new string or the existing one
@anuraglahon16 firstly you'll need to remove all non alphanumeric chars from the string. After that, a simple method is to reverse the string, assign to a new one, and compare the two
Anurag Lahon
@anuraglahon16
May 04 2016 01:16
@eeflores how to remove these non alphanumeric?
eeflores
@eeflores
May 04 2016 01:17
@anuraglahon16 google "mdn string replace". This will require understanding regular expressions
Anurag Lahon
@anuraglahon16
May 04 2016 01:17
ok @eeflores thnx
CamperBot
@camperbot
May 04 2016 01:17
anuraglahon16 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
sysyphas
@sysyphas
May 04 2016 01:18
@aryandua I tried putting ........ var celsius = 30;
Daniel Godigna
@DGAcode
May 04 2016 01:19
@sysyphas hey can you paste the code again
Aparna
@Aparna-S
May 04 2016 01:20
help Testing Objects for Properties
CamperBot
@camperbot
May 04 2016 01:20

# Challenge: Testing Objects for Properties

Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty([propname]) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.

## Example

var myObj = {
top: "hat",
bottom: "pants"
};
myObj.hasOwnProperty("top");    // true
myObj.hasOwnProperty("middle");
sysyphas
@sysyphas
May 04 2016 01:20
@33hawk
Daniel Godigna
@DGAcode
May 04 2016 01:21
@HassHz no luck pal
Aparna
@Aparna-S
May 04 2016 01:21

i modified the code as -
// Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {

if(myObj.hasOwnProperty(checkProp)) {
return;
}
}

// Test your code by modifying these values

can anyone help
?
Hassaan Hafeez
@HassHz
May 04 2016 01:22
eeflores
@eeflores
May 04 2016 01:22
you'll have to add more to the return statement in the if
@Aparna-S :point_up:
Daniel Godigna
@DGAcode
May 04 2016 01:23

function nextInLine(arr, item) {
item1 = testArr.shift();
item2 = testArr.push(5);
item3 = testArr.unshift();
item4 = testArr.push(10);
return item, item1, item2,item3; // Change this line

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

Hassaan Hafeez
@HassHz
May 04 2016 01:23
It's fine I can read it
sysyphas
@sysyphas
May 04 2016 01:24
I entered the .....var fahrenheit = (celsius * 1.8) + 32;
Daniel Godigna
@DGAcode
May 04 2016 01:25
how is it called?
Aparna
@Aparna-S
May 04 2016 01:25

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

function checkObj(checkProp) {

if(myObj.hasOwnProperty(checkProp)) {
result = myObj[checkProp];
return result;
}
}

// Test your code by modifying these values
checkObj("pet");

@eeflores ok i did that, i still get the not found part a red cross
Hassaan Hafeez
@HassHz
May 04 2016 01:25
First of all, every time you create a new variable you need to use "var", so
var item1, var item2....
Secondly, why are you pushing 5, 10? You need to be pushing "item" (function nextInLine(arr, item)) the item in the function parameters contains what you want to push onto the array
Lastly, I don't think there is an Unshift()
You also don't need to return anything other than the first item (which you remove by doing shift())
rkDeason
@rkDeason
May 04 2016 01:26
@sysyphas look at spelling in lines 5 & 8 fahrenheit
Hassaan Hafeez
@HassHz
May 04 2016 01:26
@33hawk
Aparna
@Aparna-S
May 04 2016 01:26
@eeflores got it! it was captial issue, thanks! :)
CamperBot
@camperbot
May 04 2016 01:26
aparna-s sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
sysyphas
@sysyphas
May 04 2016 01:26
@33hawk I'm not sure I understand 'called'.....is that the lind of code i enter after the bottom part with 'convertToF(30)'?
Daniel Godigna
@DGAcode
May 04 2016 01:27
@HassHz unshift push to the beggining
@sysyphas I mean the name of the exercise
Hassaan Hafeez
@HassHz
May 04 2016 01:27
@33hawk If I recall, you need to add the item to the end of the array, no? Can you send me the URL link of the question you are on?
sysyphas
@sysyphas
May 04 2016 01:28
@rkDeason please forgive me, I feel really dumb now.....
that fixed it, just wrong spelling.... terrible
Daniel Godigna
@DGAcode
May 04 2016 01:28
This message was deleted
Anurag Lahon
@anuraglahon16
May 04 2016 01:28

function isPalindrome(str)
{
str = str.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
return str === str.split('').reverse().join('');
}

if (palin === str){
return true;
} else {
return false;
}

}

console.log(palindrome("eye"));
whaz wrong here?

rkDeason
@rkDeason
May 04 2016 01:28
np ! LOL
bitgrower
@bitgrower
May 04 2016 01:31
@sysyphas -- do NOT worry about mis-spellings, etc ... this won't be the last time a spelling or punctuation error has kept your code from doing what you want ... programming is nothing if not humbling ...
Hassaan Hafeez
@HassHz
May 04 2016 01:31
@33hawk
Ok, so the first thing the question wants is to: add the number (item) to the end of the array
This can be accomplished by simply typing: arr.push(item);
Second thing: remove the first number in the array (arr.shift()) and return it:
var firstNumber = arr.shift();
return firstNumber;
Daniel Godigna
@DGAcode
May 04 2016 01:32
sysyphas
@sysyphas
May 04 2016 01:32
@bitgrower thanks.... appreciate the feedback.... on to the next section!
CamperBot
@camperbot
May 04 2016 01:32
sysyphas sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1029 | @bitgrower |http://www.freecodecamp.com/bitgrower
robertky
@robertky
May 04 2016 01:32
I am lost on adding onto a JSON object.
rkDeason
@rkDeason
May 04 2016 01:32
also staring at code for hours on end will have that effect too LOL
bitgrower
@bitgrower
May 04 2016 01:33
@rkDeason - yep -- it's important to know when it's time to take a break ...
Hassaan Hafeez
@HassHz
May 04 2016 01:33
@33hawk look at the function parameters (arr, item)
item has the number you want to add onto the array arr
so
arr.push(item) will add the number to the end of the array
robertky
@robertky
May 04 2016 01:33

This is the 237 challenge. I am trying to do, for example,

if(value!=="" && prop!=="tracks")
{
collectionCopy.id.prop=value;
}

But it says "TypeError: collectionCopy.id is undefined".
evide
@evid
May 04 2016 01:33
having trouble, not working, could someone help me out?
bitgrower
@bitgrower
May 04 2016 01:33
@robertky -- a JSON object is like any other JS object ... so -- review the previous challenges on working with objects ...
robertky
@robertky
May 04 2016 01:33
How am I suppose to do this.
evide
@evid
May 04 2016 01:33

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

switch(val) {
case 1:
case 2:
case 3:
default:
break;
case 4:
case 5:
case 6:
default:
break;
case 7:
case 8:
case 9:
default:
// Only change code above this line
}
// Change this value to test
sequentialSizes(6);

Hassaan Hafeez
@HassHz
May 04 2016 01:34
@robertky When using variables for properties, you have to use bracket notation
bitgrower
@bitgrower
May 04 2016 01:34
@robertky -- you gotta put some effort into it ...if someone hands you an answer on a silver platter -- run the other way -- because you won't learn that way ...
robertky
@robertky
May 04 2016 01:35
@bitgrower , I study CS part time.
I am not some idiot, the stuff wasn't explained.
It said come to chat if I need help.
I have coded in assembly, gotten through data structures, discrete math, etc..
Please dont treat me like an idiot when I come into a "help" chat asking for help.
bitgrower
@bitgrower
May 04 2016 01:35
okay -- and, maybe I missed it, but I didn't see where you'd shown what you've tried ... I apologize if you posted it and I missed it ...
robertky
@robertky
May 04 2016 01:36
Here, I will show you.

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

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

return collection;
}

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

Evidentally I need to use bracket notation.
For variables, is that correct?
bitgrower
@bitgrower
May 04 2016 01:36
yes, if you are using variables, you have to use bracket notation ...
robertky
@robertky
May 04 2016 01:36
Welp, I figured out one.
No dot between brackets.
Stephen James
@sjames1958gm
May 04 2016 01:37
help format
CamperBot
@camperbot
May 04 2016 01:37

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

robertky
@robertky
May 04 2016 01:37
I can probably figure out the rest, let me see.
bitgrower
@bitgrower
May 04 2016 01:37
good! :)
Christina
@cgraham74
May 04 2016 01:37
@robertky You can format your code for easier reading by 3 of these  and then hit enter. Paste your code and then hit control shift :)
Hassaan Hafeez
@HassHz
May 04 2016 01:37
@evid you don't need more than 1 default in a switch-case... default is used if the value doesn't match any case
Christina
@cgraham74
May 04 2016 01:37

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

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

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
control enter, not shift, sorry :)
evide
@evid
May 04 2016 01:37
i also posted my work, still cannot figure out what I am doing wrong
robertky
@robertky
May 04 2016 01:38
However told me to use bracket notation, that was the fix.
rkDeason
@rkDeason
May 04 2016 01:38
@anuraglahon16 you have "return str" I don't think you need return at that point
robertky
@robertky
May 04 2016 01:38
Thanks, I didn't feel that was well explained in the lessons.
instead of treating me like an idiot.
Moisés Man
@moigithub
May 04 2016 01:38
@evid return should be outside the switch block
robertky
@robertky
May 04 2016 01:38
appriciate it.
however=whoever.
Anurag Lahon
@anuraglahon16
May 04 2016 01:39
@rkDeason wt shud i do now
Hassaan Hafeez
@HassHz
May 04 2016 01:39
@robertky NP, there was a challenge called "Accessing objects through variables", but no worries I made the same mistake too I didn't think it made a difference
@evid you only need 1 default statement in a switch-case
it is used when the value doesn't match any of the cases listed
Moisés Man
@moigithub
May 04 2016 01:42
also a very first exercise tells u to Read Search Ask n Post (in that order)
no one know every1 elses background...
so the "default" we use to point is to RSAP
@robertky
rkDeason
@rkDeason
May 04 2016 01:42
robertky
@robertky
May 04 2016 01:44
@HassHz , quick question though.

On this part:

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

Anurag Lahon
@anuraglahon16
May 04 2016 01:45
@rkDeason i vl tryin doing dat
robertky
@robertky
May 04 2016 01:45
It isn't pushing "value" or anything.
Anurag Lahon
@anuraglahon16
May 04 2016 01:45
thnx
robertky
@robertky
May 04 2016 01:45
I know to do [value], but.
Justin Woodward
@jwoo92
May 04 2016 01:45
i just started basic alg scripting and am stuck on 'reverse a string' would anyone like to assist me through the challenge? here is what i have so far..

function reverseString(str) {
var string = str;
var array = [];
var newStr = ' ';
array = string.split(" ");
array.reverse();
newStr = array.join(" ");

return newStr;
}

reverseString("hello");
robertky
@robertky
May 04 2016 01:45
I was just testing, nothing is getting pushed on, Am I missing something?
Moisés Man
@moigithub
May 04 2016 01:45
@anuraglahon16 return exits the function immediatelly... so on the above code (the part in black) is never executed.... :point_up: May 3, 2016 8:28 PM
rkDeason
@rkDeason
May 04 2016 01:45
u welcome @anuraglahon16 Good luck! :)
Stephen James
@sjames1958gm
May 04 2016 01:46
@robertky You are attemping to push a string not value
robertky
@robertky
May 04 2016 01:46
@sjames1958gm , I know that.
I'm just testing it.
Its not pushing ANYTHING.
even the string.
Anurag Lahon
@anuraglahon16
May 04 2016 01:46
@moigithub yea its nt executed y?
Moisés Man
@moigithub
May 04 2016 01:46
@robertky should be "tracks" with s at end
Stephen James
@sjames1958gm
May 04 2016 01:47
@moigithub :+1:
robertky
@robertky
May 04 2016 01:47
@moigithub , thanks, lol.
CamperBot
@camperbot
May 04 2016 01:47
robertky sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1061 | @moigithub |http://www.freecodecamp.com/moigithub
robertky
@robertky
May 04 2016 01:48
@moigithub , but it still doesnt work :/.
Moisés Man
@moigithub
May 04 2016 01:48
@anuraglahon16 yep.. cuz return
a=1
return   <--- this make ur funciton exit
a = 2   <-- this line is never executed
Anurag Lahon
@anuraglahon16
May 04 2016 01:48

@moigithub
function isPalindrome(str)
{
str = str.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
var palin === str.split('').reverse().join('');
}

if (palin === str){
return true;
} else {
return false;
}

}

palindrome("eye");

Stephen James
@sjames1958gm
May 04 2016 01:48
@robertky Maybe because you have & and not &&
@robertky Or maybe you are testing that too?
robertky
@robertky
May 04 2016 01:49
no, stupid typo on my part.
Moisés Man
@moigithub
May 04 2016 01:49
@anuraglahon16 check how many open { u have
and how many closing } u have...
u have a extra } before if
rkDeason
@rkDeason
May 04 2016 01:49
@anuraglahon16 just use one = you are making an assignment not a comparison with var palin at that point
Steve
@smr312
May 04 2016 01:50
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Stephen James
@sjames1958gm
May 04 2016 01:50
@anuraglahon16
help format
CamperBot
@camperbot
May 04 2016 01:50

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

Steve
@smr312
May 04 2016 01:50
how would I change the string from double quotes to single quotes?
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Moisés Man
@moigithub
May 04 2016 01:51
@robertky u should also.. work with collection variable... (collectionCopy its for the test )
Anurag Lahon
@anuraglahon16
May 04 2016 01:51
@rkDeason yeah one = @moigithub okk
Daniel Godigna
@DGAcode
May 04 2016 01:51
function nextInLine(arr, item) {
arr = testArr.shift();
arr = testArr.push(5);
arr = testArr.unshift();
arr = testArr.push(10);
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));
Stephen James
@sjames1958gm
May 04 2016 01:51
@33hawk You should only be using arr and item in the function
bitgrower
@bitgrower
May 04 2016 01:52
@33hawk -- just a head's up -- without doing anything particularly fancy, you can complete the standinline challenge in 3 lines ...
Steve
@smr312
May 04 2016 01:53
Yes @sjames1958gm
thankyou
bitgrower
@bitgrower
May 04 2016 01:53
you're on the right track, in terms of using the various array functions ... but you may want to review the 4 previous challenges which cover pop push shift & unshift ...
Stephen James
@sjames1958gm
May 04 2016 01:53
@smr312 Then, um, that's how :)
Daniel Godigna
@DGAcode
May 04 2016 01:53
@bitgrower ok i will thanks
CamperBot
@camperbot
May 04 2016 01:53
33hawk sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1030 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 04 2016 01:54
yw !
Hassaan Hafeez
@HassHz
May 04 2016 01:55
@bitgrower I'm not sure pop push shift and unshift are his problem, he knows how to use them, his problem is understanding how to use "arr" and "item", I've tried to explain as best as I could, but maybe i"m not making sense
bitgrower
@bitgrower
May 04 2016 01:57
you could be right, @HassHz -- however, just reviewing may give him insight into other issues -- the thing about referring people to past challenges is that it's something they've completed ... so they can feel good about that -- in the challenges they are in a "known" state which hopefully they can build on -- especially when they have a smidgen of confidence from having completed the challenges... :)
This message was deleted
Islam Ibakaev
@dagman
May 04 2016 01:59
done with second react project finally http://codepen.io/dagman/full/JXepoa/
bitgrower
@bitgrower
May 04 2016 02:01
hey hey, congrats @dagman ...
Islam Ibakaev
@dagman
May 04 2016 02:02
@bitgrower thx :smile:
CamperBot
@camperbot
May 04 2016 02:02
dagman sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1031 | @bitgrower |http://www.freecodecamp.com/bitgrower
Islam Ibakaev
@dagman
May 04 2016 02:05
@bitgrower i am about 500 points. why i am not it leaderboard???
Anurag Lahon
@anuraglahon16
May 04 2016 02:06
@dagman how u see d points?
Islam Ibakaev
@dagman
May 04 2016 02:07
@anuraglahon16 what d means?
Anurag Lahon
@anuraglahon16
May 04 2016 02:08
Islam Ibakaev
@dagman
May 04 2016 02:08
This message was deleted
@anuraglahon16 click on all time points
Anurag Lahon
@anuraglahon16
May 04 2016 02:09
@dagman where it is available
@dagman yeah d palindrome works fine....bt it is nt accoring to d challenge
Islam Ibakaev
@dagman
May 04 2016 02:10
@anuraglahon16 do u see all time points ceil?
@anuraglahon16 click on it
Anurag Lahon
@anuraglahon16
May 04 2016 02:10
@dagman no....
Islam Ibakaev
@dagman
May 04 2016 02:10
@anuraglahon16 are u kidding?
Anurag Lahon
@anuraglahon16
May 04 2016 02:11
@dagman where it is available....i jst complete challenges
Islam Ibakaev
@dagman
May 04 2016 02:12
Anurag Lahon
@anuraglahon16
May 04 2016 02:12
yeah @dagman
Islam Ibakaev
@dagman
May 04 2016 02:12
@anuraglahon16 and find All time points
Anurag Lahon
@anuraglahon16
May 04 2016 02:13
@dagman yeah i see dz bt where did u get dz
Islam Ibakaev
@dagman
May 04 2016 02:13
@anuraglahon16 then click on it
@anuraglahon16 you mean information?
Anurag Lahon
@anuraglahon16
May 04 2016 02:14
@dagman yeah
Islam Ibakaev
@dagman
May 04 2016 02:14
@anuraglahon16 i was provided by challenge
Anurag Lahon
@anuraglahon16
May 04 2016 02:15

@dagman ohh......bdw my palindrome problem does not work according to d challenge ....if i miss anythng? function isPalindrome(str)
{
str = str.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
var palin = str.split('').reverse().join('');

if (palin === str){
return true;
} else {
return false;
}

}

isPalindrome("eye");

Islam Ibakaev
@dagman
May 04 2016 02:16
@anuraglahon16 returns true
@anuraglahon16 works perfectly
Anurag Lahon
@anuraglahon16
May 04 2016 02:18
@dagman yeah it returns true.....is i remove all d punctuation??
@dagman yeah it does bt it is nt according to d challenge
Islam Ibakaev
@dagman
May 04 2016 02:19
@anuraglahon16 what is d?
Stephen James
@sjames1958gm
May 04 2016 02:19
@anuraglahon16 What does it fail on?
Anurag Lahon
@anuraglahon16
May 04 2016 02:20

you'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.

We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.

Islam Ibakaev
@dagman
May 04 2016 02:21
@anuraglahon16 works
@anuraglahon16 perfeclty
@anuraglahon16 believe
@anuraglahon16 me
Stephen James
@sjames1958gm
May 04 2016 02:21
@anuraglahon16 Wrong function name
Anurag Lahon
@anuraglahon16
May 04 2016 02:22

yeah i correct it
function isPalindrome(str)
{
str = str.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
var palin = str.split('').reverse().join('');

if (palin === str){
return true;
} else {
return false;
}

}

isPalindrome("eye");

Stephen James
@sjames1958gm
May 04 2016 02:22
@anuraglahon16 According to the challenge it is supposed to be palindrome -
@anuraglahon16 please learn to format code
help format
CamperBot
@camperbot
May 04 2016 02:23

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

gkanchar
@gkanchar
May 04 2016 02:23
how to post screen shots
here
Hassaan Hafeez
@HassHz
May 04 2016 02:23
Is there anyway to skip a challenge?
Anurag Lahon
@anuraglahon16
May 04 2016 02:23
@camperbot help format?
@HassHz yeah u can go to the map n skip it
gkanchar
@gkanchar
May 04 2016 02:24
@anuraglahon16 hey how to post screen shots here?
Stephen James
@sjames1958gm
May 04 2016 02:24
@HassHz Yes if you click map at the top it will show you list and you can select
Islam Ibakaev
@dagman
May 04 2016 02:24
@anuraglahon16 you can shorten your solution to this
function isPalindrome(str) {
str = str.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
return str.split('').reverse().join('') === str;
}
isPalindrome("eye");
@sjames1958gm looks like new avatar :smile:
Anurag Lahon
@anuraglahon16
May 04 2016 02:26
@gkanchar u can copy n paste here
Daniel Godigna
@DGAcode
May 04 2016 02:26
@HassHz just choose it on the map
Stephen James
@sjames1958gm
May 04 2016 02:27
@dagman Yep
gkanchar
@gkanchar
May 04 2016 02:27
This message was deleted
Islam Ibakaev
@dagman
May 04 2016 02:27
@sjames1958gm what about react project? have u done them?
Anurag Lahon
@anuraglahon16
May 04 2016 02:28
@gkanchar u just copy and paste the code
gkanchar
@gkanchar
May 04 2016 02:29
Use the $("button") selector. Use the$(".btn") selector.
Use the $("#target1") selector. Only add one class with each of your three selectors. Your #target1 element should have the classes animated‚ shake and btn-primary. how to do thz?? i am in 119 challenege!! anthonyjl92 @anthonyjl92 May 04 2016 02:30 hey guys! I was wondering if there is a regex that can change </script> to <\/script> For example: <html><script> content </script></html> outputs <html><script> content <\/script></html> gkanchar @gkanchar May 04 2016 02:30 @anuraglahon16 @gkanchar Use the$("button") selector.
Use the $(".btn") selector. Use the$("#target1") selector.
Your #target1 element should have the classes animated‚ shake and btn-primary.
how to do thz??
Anurag Lahon
@anuraglahon16
May 04 2016 02:31
@gkanchar which challenge?
gkanchar
@gkanchar
May 04 2016 02:32
Target the same element with multiple jQuery Selectors
119 challenge
Anurag Lahon
@anuraglahon16
May 04 2016 02:32

@dagman function isPalindrome(str)
{
str=str.replace(/[^A-za-z0-9,'').toLower();
return str.split('').reverse().join('')===str;

}
isPalindrome("eye");

@gkanchar its easy read d hint
Coy Sanders
@coymeetsworld
May 04 2016 02:35
Norvin Burrus
@ndburrus
May 04 2016 02:35
@anuraglahon16 are you missing an underscore? :)
Coy Sanders
@coymeetsworld
May 04 2016 02:35
like for example $("button").addClass(someClass); Anurag Lahon @anuraglahon16 May 04 2016 02:36 @ndburrus where John Welch @ieldanth May 04 2016 02:36 that's the one where you have to demonstrate that you know how to select by type, class and id. Norvin Burrus @ndburrus May 04 2016 02:37 @anuraglahon16 in the palindrome challenge... did it work? John Welch @ieldanth May 04 2016 02:37 it goes in your$(document).ready function
Anurag Lahon
@anuraglahon16
May 04 2016 02:40
@ndburrus no
Stephen James
@sjames1958gm
May 04 2016 02:41
@anuraglahon16 Did you change the function name to palindrome -
Norvin Burrus
@ndburrus
May 04 2016 02:41
@anuraglahon16 try placing an underscore after the "9"
@anuraglahon16 yes, see what @sjames1958gm said.... you need that too... see the format of the listed requirements.... example: "palindrome("eye") should return a boolean."
Srinivasan
@kksrini89
May 04 2016 02:43
Guys.. help me on challenge "Where do I belong" . I did the same like below
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var initialArray = arguments[0];
var toBeInsertedItem = arguments[1];
initialArray = initialArray.sort(function(a,b){
return a - b;
});
var previousItem;
for(var i = 0;i < initialArray.length; i++){

if(initialArray[i] < toBeInsertedItem){
previousItem = initialArray[i];
}
else{
initialArray = initialArray.splice(i-1,0,toBeInsertedItem);
}
}

return initialArray;

}
Anurag Lahon
@anuraglahon16
May 04 2016 02:44
@ndburrus ok
Norvin Burrus
@ndburrus
May 04 2016 02:45
@anuraglahon16 alright, how's it going?
Anurag Lahon
@anuraglahon16
May 04 2016 02:45
@ndburrus i m tryin

function isPalindrome(str)
{
str=str.replace(/[^A-za-z0-9_,'').toLower();
return str.split('').reverse().join('')===str;

}
isPalindrome("eye");

Stephen James
@sjames1958gm
May 04 2016 02:47
@anuraglahon16 Still doesn't pass?
Srinivasan
@kksrini89
May 04 2016 02:47
Need help guys..
Norvin Burrus
@ndburrus
May 04 2016 02:48
@anuraglahon16 your function name should be palindrome(str)... also, toLowerWhat??
Anurag Lahon
@anuraglahon16
May 04 2016 02:48
ok
John Welch
@ieldanth
May 04 2016 02:48
@kksrini89 what is the output of that function?
Srinivasan
@kksrini89
May 04 2016 02:48
returns empty array
Anurag Lahon
@anuraglahon16
May 04 2016 02:49
isPalindrome does not work..... i hv written another code previously bt it gives output true ,bt didn't pass d challenge @ndburrus
Stephen James
@sjames1958gm
May 04 2016 02:49
@anuraglahon16 isPalindrome is wrong
Norvin Burrus
@ndburrus
May 04 2016 02:49
Stephen James
@sjames1958gm
May 04 2016 02:50
palindrome("eye") should return a boolean.
John Welch
@ieldanth
May 04 2016 02:50
have you tried initialArray=arr; ?
Anurag Lahon
@anuraglahon16
May 04 2016 02:50
@sjames1958gm @ndburrus ok i vl try
Norvin Burrus
@ndburrus
May 04 2016 02:50
@anuraglahon16 do you understand that the function name should change?
Srinivasan
@kksrini89
May 04 2016 02:50
John Welch
@ieldanth
May 04 2016 02:51
@kksrini89 looking at it...
Anurag Lahon
@anuraglahon16
May 04 2016 02:51
@ndburrus yeah it should be palindrome
Norvin Burrus
@ndburrus
May 04 2016 02:51
@anuraglahon16 ok, great, now look at the toLower part... do you see what needs attention? i.e. toLower WHAT?
Anurag Lahon
@anuraglahon16
May 04 2016 02:52
.toLowerCase(); it should be like that?
Stephen James
@sjames1958gm
May 04 2016 02:52
@kksrini89 The return value should be an index not an array -
Norvin Burrus
@ndburrus
May 04 2016 02:52
@anuraglahon16 right.... now type that in.... see if it passes the test. post code if it doesn't pass....
Anurag Lahon
@anuraglahon16
May 04 2016 02:52
@ndburrus ok
Srinivasan
@kksrini89
May 04 2016 02:54
@sjames1958gm I tried it yaar
but nothing worked.
@sjames1958gm @ieldanth Did I do something wrong on logic???
John Welch
@ieldanth
May 04 2016 02:55
have your code keep track of the item location rather than what to insert.
Stephen James
@sjames1958gm
May 04 2016 02:56
@kksrini89 Yes, you are supposed to return the index of the place to insert. Find the first array element that is >= to num and return its index
Norvin Burrus
@ndburrus
May 04 2016 02:56
@anuraglahon16 did it work?
John Welch
@ieldanth
May 04 2016 02:56

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

if(initialArray[i] < toBeInsertedItem){
itemLoc += 1;
}
else{
initialArray = initialArray.splice(i-1,0,toBeInsertedItem);
}

}

return itemLoc;

CamperBot
@camperbot
May 04 2016 02:56
:bulb: to format code use backticks!  more info
Stephen James
@sjames1958gm
May 04 2016 02:57
@ieldanth You don't neee itemLoc you already have 'i'
Ava Guerrero
@iamacatperson
May 04 2016 02:58
guys quick question, how to put a code sample here ?
Stephen James
@sjames1958gm
May 04 2016 02:58
help format
CamperBot
@camperbot
May 04 2016 02:58

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

John Welch
@ieldanth
May 04 2016 02:58
thanks
still working on getting formatting down
Norvin Burrus
@ndburrus
May 04 2016 02:58
@iamacatperson help paste code
Anurag Lahon
@anuraglahon16
May 04 2016 02:58
@ndburrus function Palindrome(str)
{
str=str.replace(/[^A-Za-z0-9]/g,'').toLowerCase();
var palin= str.split('').reverse().join('');
if(palin==str)
{
return true;
}else{
return false;
}
}
Palindrome("eye");
Stephen James
@sjames1958gm
May 04 2016 02:59
@anuraglahon16 Please learn to paste code correctly
Norvin Burrus
@ndburrus
May 04 2016 02:59
@anuraglahon16 did it pass?
Stephen James
@sjames1958gm
May 04 2016 02:59
@anuraglahon16 palindrome with lower case p -
Ava Guerrero
@iamacatperson
May 04 2016 02:59
 var j = 0;
sample code!
Anurag Lahon
@anuraglahon16
May 04 2016 02:59
give terue bt does not pass the test @ndburrus
Ava Guerrero
@iamacatperson
May 04 2016 02:59
ok got it!
John Welch
@ieldanth
May 04 2016 02:59
if I'm reading it right, 'i' will eventually return the length of the array
KimJongUno
@KimJongUno
May 04 2016 02:59
Any idea of why my getWeather function isn't working?
Norvin Burrus
@ndburrus
May 04 2016 02:59
@sjames1958gm good catch...
Stephen James
@sjames1958gm
May 04 2016 03:00
@ieldanth Not if you return immediately on finding the item
Srinivasan
@kksrini89
May 04 2016 03:00
@sjames1958gm wow. I did yaar. it worked.
Ava Guerrero
@iamacatperson
May 04 2016 03:00
guys i need your advise for the Profile Lookup... is this the proper way to do it or is there a more efficient way?
var arrayCounter = 0;

for(j = 0; j < contacts.length; j++) {
if(contacts[j].firstName != firstName) {
arrayCounter++;
// console.log(arrayCounter);
if(arrayCounter === contacts.length) {
return "No such contact";
}
} else {
for(i = 0; i < contacts.length; i++) {
if((contacts[i].firstName == firstName) && (contacts[i].hasOwnProperty(prop))) {
return contacts[i][prop];
} else if (contacts[i].hasOwnProperty(prop) === false) {
return "No such property";
}
}
}
}
Srinivasan
@kksrini89
May 04 2016 03:00
@sjames1958gm @ieldanth thank you so much guys
CamperBot
@camperbot
May 04 2016 03:00
kksrini89 sends brownie points to @sjames1958gm and @ieldanth :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
May 04 2016 03:01
@iamacatperson Just have your second loop and if it ends without returning any thing then return no such contact.
@iamacatperson
  for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName) {
if (contacts[i][prop]) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}

return "No such contact";
This message was deleted
Ava Guerrero
@iamacatperson
May 04 2016 03:03
thanks @sjames1958gm ! that looks much simpler...
CamperBot
@camperbot
May 04 2016 03:03
iamacatperson sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Ava Guerrero
@iamacatperson
May 04 2016 03:04
i get it now..
Norvin Burrus
@ndburrus
May 04 2016 03:05
@anuraglahon16
function palindrome(str) {
return str.replace(/[\W_]/g, '').toLowerCase() ===
str.replace(/[\W_]/g, '').toLowerCase().split('').reverse().join('');
}
palindrome("not a palindrome");
John Welch
@ieldanth
May 04 2016 03:07
we just had a challenge like that in C++ using stacks and queues XD
Ava Guerrero
@iamacatperson
May 04 2016 03:07
is there any tip.. like when to use 'nested ifs' VS an '&&' when doing if-then-else.. mine worked but very verbose.. the nested if was more efficient..
Anurag Lahon
@anuraglahon16
May 04 2016 03:08
@ndburrus is it d code
venkatesh prabhu
@venkateshprabhu2
May 04 2016 03:08
Hello all
John Welch
@ieldanth
May 04 2016 03:08
use nested ifs if you have an else that only applies to one condition
venkatesh prabhu
@venkateshprabhu2
May 04 2016 03:08
I need help with the challenge 'Make Object Properties Private'
I am unable to understand it
Robert Richey
@0x0936
May 04 2016 03:10
@iamacatperson I try to avoid using && or || in branching conditionals and instead prefer to nest them - more readable, easier to maintain
Ava Guerrero
@iamacatperson
May 04 2016 03:11
thanks @ieldanth & @0x0936 ... @0x0936, then use && or || for which instances mostly?
CamperBot
@camperbot
May 04 2016 03:11
:star2: 1297 | @0x0936 |http://www.freecodecamp.com/0x0936
iamacatperson sends brownie points to @ieldanth and @0x0936 :sparkles: :thumbsup: :sparkles:
John Welch
@ieldanth
May 04 2016 03:12
use || for conditionals where you want to check if any of the conditions are true, but break them out if they are getting too long to read
Anurag Lahon
@anuraglahon16
May 04 2016 03:12
@ndburrus it does not work at all
Robert Richey
@0x0936
May 04 2016 03:12
@iamacatperson I will still use them on occasion if it's just a single if or not terribly verbose
Angelo Ryndon
@AIRyndon
May 04 2016 03:12
function lookUpProfile(name, prop){
// Only change code below this line
var result;
for(var i = 0; i < contacts.length;i++)
{
if(contacts[i].firstName === name && contacts[i].hasOwnProperty(prop))
{
result = contacts[i][prop];
break;
}
else if(!contacts[i].hasOwnProperty(prop))
{
result = "No such property";
}
else if(contacts[i].firstName !== name)
{
result = "No such contact";
}
}
return result;
// Only change code above this line
John Welch
@ieldanth
May 04 2016 03:12
also, where the same code applies if any are true
Matt Green
@mattxgreen
May 04 2016 03:12
Angelo Ryndon
@AIRyndon
May 04 2016 03:13
is there a way to write that more elegantly?
what I posted on top :smile:
its for the profile lookup challenge
John Welch
@ieldanth
May 04 2016 03:13
simply return the value rather than breaking
Robert Richey
@0x0936
May 04 2016 03:14
@mattxgreen nested
if (something) {
if (this) { }
else if (that) {}
else {}
}
Matt Green
@mattxgreen
May 04 2016 03:14
Coy Sanders
@coymeetsworld
May 04 2016 03:14
@AIRyndon theres still an issue with your code re "No such contact"
Matt Green
@mattxgreen
May 04 2016 03:14
@AIRyndon
function lookUp(firstName, prop){
// Only change code below this line
var match = false;
for(var person in contacts){
if (contacts[person].firstName === firstName){
match = person;
break;
}
}
if(!match) return 'No such contact';
return (!contacts[match][prop]) ? 'No such property' : contacts[match][prop];
// Only change code above this line
}
John Welch
@ieldanth
May 04 2016 03:15
This message was deleted
Matt Green
@mattxgreen
May 04 2016 03:16
@0x0936
if (temp < 70){
if (temp < 30){
} else {
}
} else {
if (temp > 85){
} else {
}
}
Angelo Ryndon
@AIRyndon
May 04 2016 03:16
@coymeetsworld what is wrong with it? it worked on the challenge :smile:
Coy Sanders
@coymeetsworld
May 04 2016 03:16
oh nvm you're not returning the value, youre making it a variable
yeah i guess that could work, but something similar to what @mattxgreen showed is a little better
if you find a user with the firstName in your contacts, you don't really want to keep looping through it, just return the value you have
whether its the property if they have it, or "No such property" if they don't
Angelo Ryndon
@AIRyndon
May 04 2016 03:17
@mattxgreen nice...that's why I like asking...that looks nice @coymeetsworld ...yes, you guys are awesome!
Coy Sanders
@coymeetsworld
May 04 2016 03:18
no point in going through the rest of the array right? minor detail as your code does work, this is just a little more efficient
Anurag Lahon
@anuraglahon16
May 04 2016 03:18
@ndburrus it works now
Angelo Ryndon
@AIRyndon
May 04 2016 03:18
@coymeetsworld @mattxgreen Thanks guys! I'm somewhat OCD to elegant and efficient :smile:
CamperBot
@camperbot
May 04 2016 03:18
airyndon sends brownie points to @coymeetsworld and @mattxgreen :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 04 2016 03:19
its ok, just something to think about @AIRyndon
Matt Green
@mattxgreen
May 04 2016 03:19
@AIRyndon np.
Ronique Ricketts
@RoniqueRicketts
May 04 2016 03:20
What did I miss. I stil dont get it.

// Setup
function phoneticLookup(val) {
var result = "";

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

result=lookup["charlie"];
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");
Shanoy Sinclair
@shanoysinc
May 04 2016 03:20
how to check if something is not blank in javascript
Matt Green
@mattxgreen
May 04 2016 03:21
@RoniqueRicketts you are always returning 'chicago'
John Welch
@ieldanth
May 04 2016 03:21
btw, try switch...case if it gets too messy.
Angelo Ryndon
@AIRyndon
May 04 2016 03:21
@RoniqueRicketts type val there..not chicago
@RoniqueRicketts charlie I mean
Ronique Ricketts
@RoniqueRicketts
May 04 2016 03:22
@mattxgreen so i tried val there and it did't work thats why I am back
Matt Green
@mattxgreen
May 04 2016 03:22
@shanoysinc what are you wanting to test for? null, undefined, or ""?
Ronique Ricketts
@RoniqueRicketts
May 04 2016 03:22
I almost killed my laptop.
lol
Matt Green
@mattxgreen
May 04 2016 03:23
result=lookup[val];
Ronique Ricketts
@RoniqueRicketts
May 04 2016 03:23
I had value. not val. how dumb of me. auugh. thanks @mattxgreen @AIRyndon
CamperBot
@camperbot
May 04 2016 03:23
roniquericketts sends brownie points to @mattxgreen and @airyndon :sparkles: :thumbsup: :sparkles:
Angelo Ryndon
@AIRyndon
May 04 2016 03:23
@RoniqueRicketts
function phoneticLookup(val) {
var result = "";

// Only change code below this line
switch(val) {
case "alpha":
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}

// Only change code above this line
return result;
}
Matt Green
@mattxgreen
May 04 2016 03:23
@RoniqueRicketts np
Kelvin-penang
@Kelvin-penang
May 04 2016 03:23
Hi, its me the noob again. need help in the bonfire projects


function reverseString(str) {
var arrayOfStrings = str.split();
function arrayReversed(arrayOfStrings){
var reversed = arrayOfStrings.revere();

function arrayJoined(reversed) {
var joined = reversed.join();

return joined;}

}
}

reverseString("hello");
Shanoy Sinclair
@shanoysinc
May 04 2016 03:23
@mattxgreen i figured it out
Angelo Ryndon
@AIRyndon
May 04 2016 03:23
@RoniqueRicketts np :smile:
Diego Mayer
@Chrono79
May 04 2016 03:24
@Kelvin-penang why so many functions?
Kelvin-penang
@Kelvin-penang
May 04 2016 03:24
need to make the string an array, then reverse it and rejoin it
Coy Sanders
@coymeetsworld
May 04 2016 03:24
@Kelvin-penang reverse spelled wrong, for one
Kelvin-penang
@Kelvin-penang
May 04 2016 03:24
haha @Chrono79 no idea where to start
Diego Mayer
@Chrono79
May 04 2016 03:24
@Kelvin-penang just chain methods
Coy Sanders
@coymeetsworld
May 04 2016 03:24
don't think you need that many functions either
you're not even calling arrayJoined
Matt Green
@mattxgreen
May 04 2016 03:24
@shanoysinc great
Kelvin-penang
@Kelvin-penang
May 04 2016 03:25
@Chrono79 chain methods? can gimme an example for me to follow?
Diego Mayer
@Chrono79
May 04 2016 03:25
@Kelvin-penang and split and join need a param
str.split("").reverse().join("");
Jack C
@JackCameo
May 04 2016 03:25
Is anyone on the blackjack challenge? I completed the challenge but I dont think my code is the best possible version, I'd love to see others.
Dayne Wright
@daynewright
May 04 2016 03:25
@Kelvin-penang you don't need to make functions inside that function and you are not envoking them. They are not running.
Angelo Ryndon
@AIRyndon
May 04 2016 03:25
@Kelvin-penang chain them methods like in LINQ... a.where().OrderBy
:)
Jack C
@JackCameo
May 04 2016 03:25
var count = 0;

function cc(card) {
// Only change code below this line
if (card <= 6) {
count++;
} else if (card <= 9) {
} else {
count--;
}

if (count > 0) {
return count + " Bet";
}
return count + " Hold";
// Only change code above this line
}
CJ Jugarap
@cjjugarap
May 04 2016 03:26
Kelvin-penang
@Kelvin-penang
May 04 2016 03:27
@AIRyndon @Daynewr .....brain not functioning well....can point me in the direction to a reference page?
Hamelth
@mrWolfhouse
May 04 2016 03:27
don't you need to use a switch funtion?
John Welch
@ieldanth
May 04 2016 03:27
@JackCameo what are you trying to accomplish in that first else?
Dennis Niemeijer
@daniemeijer
May 04 2016 03:28
i'm trying to sort a multi-dimensional numeric array. But it does not seem to consider numbers >999?
Angelo Ryndon
@AIRyndon
May 04 2016 03:28
@Kelvin-penang http://javascriptissexy.com/beautiful-javascript-easily-create-chainable-cascading-methods-for-expressiveness/...for Javascript..don't want to give C# one here in a javascript chat
Dayne Wright
@daynewright
May 04 2016 03:28
@Kelvin-penang no problem. It takes a little bit to get and I am trying to type this from my phone so that makes it challenging. :)
Jack C
@JackCameo
May 04 2016 03:28
@ieldanth it was meant to exit the if statement with no change
Dayne Wright
@daynewright
May 04 2016 03:30
@Kelvin-penang first. You called reversestring by envoking it with (). The other functions you never envoked. Does that make sense?
So they will never run.
John Welch
@ieldanth
May 04 2016 03:30
couldn't that be accomplised with else if(card>9){count--;} ?
Kelvin-penang
@Kelvin-penang
May 04 2016 03:30
@Daynewr I see...sort of
Dayne Wright
@daynewright
May 04 2016 03:30
Second. You don't need them. You can do method chaining like @AIRyndon mentioned
So you have two issues going on
Kelvin-penang
@Kelvin-penang
May 04 2016 03:31
@Chrono79 I'm trying to chain them all together....


function reverseString(str) {
var arrayOfStrings = str.split("").reverse().join("");

}

reverseString("hello");
but seems like I'm missing out on a big chunk here :P
Diego Mayer
@Chrono79
May 04 2016 03:31
@Kelvin-penang you're missing return...
Kelvin-penang
@Kelvin-penang
May 04 2016 03:31
HAHA!
Jack C
@JackCameo
May 04 2016 03:31
@ieldanth that would only apply for 10 but not "J","Q","K","A"
96street
@96street
May 04 2016 03:32
Return Largest Numbers in Arrays
Kelvin-penang
@Kelvin-penang
May 04 2016 03:32
but its still wrong
Diego Mayer
@Chrono79
May 04 2016 03:32
@Kelvin-penang how so?
Kelvin-penang
@Kelvin-penang
May 04 2016 03:32
Dayne Wright
@daynewright
May 04 2016 03:33
Do you understand what is happening @Kelvin-penang ?
Kelvin-penang
@Kelvin-penang
May 04 2016 03:33
thanks @Chrono79 @coymeetsworld @Daynewr @AIRyndon !!
CamperBot
@camperbot
May 04 2016 03:33
kelvin-penang sends brownie points to @chrono79 and @coymeetsworld and @daynewr and @airyndon :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 04 2016 03:33
np @Kelvin-penang
John Welch
@ieldanth
May 04 2016 03:33
@JackCameo ah, got it, the variable is mixed type. Spent too much time in strongly typed languages...
Diego Mayer
@Chrono79
May 04 2016 03:33
@Kelvin-penang maybe you want to name your var (you don't need it) like something else, because it's not an array of strings
Jack C
@JackCameo
May 04 2016 03:34
@ieldanth Thanks for taking a look
CamperBot
@camperbot
May 04 2016 03:34
jackcameo sends brownie points to @ieldanth :sparkles: :thumbsup: :sparkles:
96street
@96street
May 04 2016 03:34
function largestOfFour(arr) {

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

arr[i];

if(arr[i] > i) {
i.push(arr[0]);
i.push(arr[1]);
i.push(arr[2]);
i.push(arr[3]);
}

}

return arr;

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
abit lost on Return Largest Numbers in Arrays. Am I on the right track?
Alexis
@alexisgcn
May 04 2016 03:34
helpv

function chunkArrayInGroups(arr, size) {
// Break it up.
var newArray = [];
for(var i = 0; i < size; i++){

newArray.push(arr.slice(0, size));

}
return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Kelvin-penang
@Kelvin-penang
May 04 2016 03:35
@Chrono79 thanks for the tip. yah, might confuse me in the future
CamperBot
@camperbot
May 04 2016 03:35
kelvin-penang sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: kelvin-penang already gave chrono79 points
Diego Mayer
@Chrono79
May 04 2016 03:35
@alexisgcn move your slice starting and ending point
Alexis
@alexisgcn
May 04 2016 03:35
where?
Diego Mayer
@Chrono79
May 04 2016 03:35
you don't want to take the same piece every time
Alexis
@alexisgcn
May 04 2016 03:36
nop
Diego Mayer
@Chrono79
May 04 2016 03:36
also your for loop need a little correction
Alexis
@alexisgcn
May 04 2016 03:37
?
Diego Mayer
@Chrono79
May 04 2016 03:37
think in the function call, how many groups you get when you call your function
4 elements in groups of 2 elements, means how many groups?
Alexis
@alexisgcn
May 04 2016 03:38
2
Diego Mayer
@Chrono79
May 04 2016 03:38
so, your for loop should have 2 iterations
now, think of a way to not have it fixed, think of a formula to get that number
Alexis
@alexisgcn
May 04 2016 03:39
<= size?
Diego Mayer
@Chrono79
May 04 2016 03:39
based on arr.length and size, both values should be involved
Chris Cullen
@123xylem
May 04 2016 03:50

function getIndexToIns(arr, num) {
var newarr = Array.prototype.slice.call(arguments);

newarr.sort(function(a, b) {
return a - b;
});

return newarr;
}

getIndexToIns([70, 60], 50);
Does anyone know why this isnt this sorting the first sub array numerically?
Coy Sanders
@coymeetsworld
May 04 2016 03:52
you don't want to sort the arguments, you want to sort arr
Chris Cullen
@123xylem
May 04 2016 03:53
Isnt newarr an array though?
Coy Sanders
@coymeetsworld
May 04 2016 03:53
yes, the array of arguments
but you don't want to sort that
you only want to sort the first argument, which is arr
Chris Cullen
@123xylem
May 04 2016 03:54
right
Coy Sanders
@coymeetsworld
May 04 2016 03:54
the second argument is where you would insert that in the array
Chris Cullen
@123xylem
May 04 2016 03:54
But is sort not working because its used on a sub array or did i do something wrong with sort syntax?
Coy Sanders
@coymeetsworld
May 04 2016 03:54
its not working because you don't want to sort your arguments
you want to sort the first argument, not all of them
Chris Cullen
@123xylem
May 04 2016 03:55
So sort doesnt work on subarrays?
Coy Sanders
@coymeetsworld
May 04 2016 03:55
sort works on any array
Norvin Burrus
@ndburrus
May 04 2016 03:55
This message was deleted
Coy Sanders
@coymeetsworld
May 04 2016 03:55
its an array function
Chris Cullen
@123xylem
May 04 2016 03:55
Why doesnt it sort my one then? :)
Coy Sanders
@coymeetsworld
May 04 2016 03:56
it doesn't matter because I'll say it again, you don't want to sort the arguments array :)
just arr
Chris Cullen
@123xylem
May 04 2016 03:57
... I was mainly asking about sort method and why it wasnt working but .. thanks for helping @coymeetsworld
CamperBot
@camperbot
May 04 2016 03:57
123xylem sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 04 2016 03:57
its not working because you're trying to compare an array (arr) to a value
newArr = [[70,60], 50]
you can't compare [70,60] and 50 together, which is why your comparator function isn't working
Chris Cullen
@123xylem
May 04 2016 04:00
Thanks for clarifying that.. I was comparing [subaray] with 50 which makes no sense in computer speaky... Thanks! :)
Coy Sanders
@coymeetsworld
May 04 2016 04:00
yep, np
Chris Cullen
@123xylem
May 04 2016 04:01
i pushed num into arr and sorted it which is problem half solved already
Coy Sanders
@coymeetsworld
May 04 2016 04:01
yep
Chris Cullen
@123xylem
May 04 2016 04:05
Wow that was so easy,,,
prashant
@findname
May 04 2016 04:10
can anyone tell whats wrong with the code
function diffArray(arr1, arr2) {
var newArr = [];
var leng =max(arr1.length,arr2.length);
newArr=arr1.concat(arr2);

for(i=0;i<arr1.length+arr2.length;i++)
for(j=i+1;j<=arr1.length+arr2.length;j++)
{
if(arr[i]==arr[j])
{
arr[i].filter(filterfunction(arr[i]){

return arr[i];

});
}

}

return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
 arr[i].filter(filterfunction(arr[i]){

return arr[i];

});
this line is generating semicolonerror
John Welch
@ieldanth
May 04 2016 04:16
may not be it, but try putting curly braces around your first for loop
May 04 2016 04:19
@findname - I don't see where arr is declared? Maybe you need to be using arr1 and arr2 in those inner loops?
bleujai
@bleujai
May 04 2016 04:20
Time for a little help. I'm working on the Sum All Primes challenge and my algorithm seems to be working but when I try to .push the primes into my storage array it does not work right.
Any reason numbers would not work well for the .push function( maybe method)?
May 04 2016 04:21
@bleujai - can you post your code? You have to make sure that you are pushing onto an array.
bleujai
@bleujai
May 04 2016 04:21
how do I do that?
May 04 2016 04:21
help format
CamperBot
@camperbot
May 04 2016 04:21

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

May 04 2016 04:21
@bleujai ^^^^ posting code
bleujai
@bleujai
May 04 2016 04:22
That's what I type in here for it to show?
still showing error
function diffArray(arr1, arr2) {
var newArr = [];
var leng =max(arr1.length,arr2.length);
newArr=arr1.concat(arr2);

for(i=0;i<arr1.length+arr2.length;i++){
for(j=i+1;j<=arr1.length+arr2.length;j++)
{
if(arr[i]==arr[j])
{
newArr[i].filter(filterfunction(newArr[i]){

return newArr[i];

});
}}}
return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
bleujai
@bleujai
May 04 2016 04:24
I am pushing into an array that I created.
How do I post code?
May 04 2016 04:25
@findname - oh, now that I saw the code in the editor - it looks like you are trying to use a function name filterfunction(), or at least that's how I think that is being interpreted. You don't have a function by that name. Also, I cannot see where you are getting the arr variable - that is not defined anywhere in your code?
@bleujai - look at this following information:
help format
CamperBot
@camperbot
May 04 2016 04:25

## :point_right: code formatting [wiki]

### Multi line Code

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

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

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

May 04 2016 04:25
prashant
@findname
May 04 2016 04:26
@bleujai use  then press enter the n paste code then again same three for closing
bleujai
@bleujai
May 04 2016 04:27

function sumPrimes(num) {
var arr=[2,3];
var ctr;

for (var i=4; i<=num ; i++){
ctr=0;
for (var j = 2; j <= num/2 ; j++) {
if ((i%j) === 0){
ctr++;
break;
}
}
if (ctr === 0 ){

arr.push(i);
}  //else {return j;}
}

return arr;
}

sumPrimes(9);
ahhh! There we go.
prashant
@findname
May 04 2016 04:28
 if(newArr[i]==newArr[j])
{
newArr[i].filter(function(newArr[i]){

return newArr[i];

});
}}}
return newArr;
@khaduch is that ok still shows
bleujai
@bleujai
May 04 2016 04:28
So when I do 9 as my argument it works (I'm not summing them yet) but when I use 10 the .push doesn't give the same numbers.
arr (when num is 9) = [ 2,3,5,7 ] but when 10 it shows [ 2,3,7 ].
May 04 2016 04:30
@findname - I'm not following your code. .filter() is an Array method, but if you have an array called newArr, then newArr[i] is no longer an array? Does that make sense? I cannot really see what you're trying to do there.
prashant
@findname
May 04 2016 04:31
This message was deleted
newArr.filter(function(newArr[i]){

return newArr[i];

});
Travis
@dukenukethem
May 04 2016 04:34
help Profile Lookup
CamperBot
@camperbot
May 04 2016 04:34

# Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

May 04 2016 04:35
@findname - it's probably getting better, but you probably don't need the newArr[i] as the function arg, because the .filter() method should pass each element of the array as the argument, so it will walk through the entire array. I think that you have to change what you're doing inside the function - test the value against another array using .indexOf or something? (I don't remember what the solution is for this challenge.)
96street
@96street
May 04 2016 04:36
How do you iterate through an array in an array?
Martialis39
@Martialis39
May 04 2016 04:36
@96street Hey
@96street basically you can use a for loop
i has to be less than array length
and you set array index to i
96street
@96street
May 04 2016 04:37
I've used a for loop to iterate through the parent array, but how do I iterate through the children? @Martialis39
for(var i = 0; i < arr.length; i++) {

arr[i];
}
May 04 2016 04:38
@96street - you use for loops, but you have to use nested for loops - the outer loop iterates over the array of arrays, and the inner one iterates through each array that is an element of the "parent" array.
Martialis39
@Martialis39
May 04 2016 04:38
you can add another for loop, use J as a variable :)
96street
@96street
May 04 2016 04:38
another for loop..right thanks @khaduch @Martialis39
CamperBot
@camperbot
May 04 2016 04:38
96street sends brownie points to @khaduch and @martialis39 :sparkles: :thumbsup: :sparkles:
96street
@96street
May 04 2016 04:38
ill be back soon
May 04 2016 04:38
@96street - you're welcome...
Martialis39
@Martialis39
May 04 2016 04:39
We'll be here!
khaduch @khaduch - I have to cut out for now... it's late. Good luck everyone!
Joseph
@revisualize
May 04 2016 04:40
Hi.
prashant
@findname
May 04 2016 04:40
@khaduch thanks , it showing the syntax error in line 12
CamperBot
@camperbot
May 04 2016 04:40
findname sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Martialis39
@Martialis39
May 04 2016 04:40
@revisualize hello!
Mike Moss
@MMux
May 04 2016 04:41
help missing letters
CamperBot
@camperbot
May 04 2016 04:41

# Problem Explanation:

• You will create a program that will find the missing letter from a string and add it. If there is not missing letter it will return undefined. There is currently no test case for it missing more than one letter, but if anything recursion can be implemented or a second or more calls to the same function as needed. Also the letters are always provided in order so there is no need to sort them.
prashant
@findname
May 04 2016 04:41
and i guess it should be Arr as an argument
Joseph
@revisualize
May 04 2016 04:41
Anyone need the help with something?
prashant
@findname
May 04 2016 04:41
is not change later once there is no syntax err
wlcm @revisualize
Joseph
@revisualize
May 04 2016 04:43
@MMux That one looks pretty easy.
96street
@96street
May 04 2016 04:44
function largestOfFour(arr) {

var largest = 0;

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

for(var j = 0;j < arr[i].length; j++) {
if(j > largest) {
j = largest;
largest.push(arr[i]);
}
}
}

return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
am i on the right track? @khaduch
Joseph
@revisualize
May 04 2016 04:44
96street
@96street
May 04 2016 04:45
This is for Return Largest Numbers in Arrays @revisualize
Joseph
@revisualize
May 04 2016 04:45
arr[i][j]
96street
@96street
May 04 2016 04:45
hmm let me have a look
Joseph
@revisualize
May 04 2016 04:45
@96street I know.
96street
@96street
May 04 2016 04:46
Ok i'm stumped, where would that go? @revisualize
Joseph
@revisualize
May 04 2016 04:47
function largestOfFour(arr) {
var place = [];
var largest = 0;

for(var i = 0; i < arr.length; i++) {
for(var j = 0;j < arr[i].length; j++) {
if(arr[i][j] > largest) {
largest = arr[i][j];
}
}
place.push(largest);
}
return place;
}
Oh... That still isn't correct.
hmm.
Still not correct.
is that correct?!
Frank XC
@tenkdayz
May 04 2016 04:49
@revisualize what does it need to do?
kirbyedy
@kirbyedy
May 04 2016 04:50
for(var j = 0;j < arr[i].length; j++) <--- j and i ?
Joseph
@revisualize
May 04 2016 04:50
@96street Do you see what I've been doing?
kirbyedy
@kirbyedy
May 04 2016 04:50
is that correct?
Chris Cullen
@123xylem
May 04 2016 04:50
Easy error here... Why is property Push undefined??
function rot13(str) {
for(i=0;i<str.length;i++){
var arr= arr.push(str[i]);
return arr;
}
}

rot13("Egghj");
96street
@96street
May 04 2016 04:50
why are you creating an empty array (place) when it's already been created as 'arr'? @revisualize
Joseph
@revisualize
May 04 2016 04:50
@tenkdayz I'm trying to poke @96street
Martin Li
@Mertiant
May 04 2016 04:50
function countTo(int){
for(var i = 1; i<=int; i++){
console.log(i);
}
}
countTo(5);
Joseph
@revisualize
May 04 2016 04:50
@96street Because you don't want to modify your base array.
Martin Li
@Mertiant
May 04 2016 04:50
does this display 1-5
none of the js ides would show me anything
Joseph
@revisualize
May 04 2016 04:51
@96street If you constantly modify arr you'll end up with a mess at the end.
@96street What happens if I do this:
96street
@96street
May 04 2016 04:51
the whole point of the exercise is to modify the base array by pushing the highest number to it? isnt it? @revisualize
Joseph
@revisualize
May 04 2016 04:51
@96street NO!
96street
@96street
May 04 2016 04:51
explain
CamperBot
@camperbot
May 04 2016 04:51
usage:
wiki $topic info on that topic prashant @findname May 04 2016 04:51 @123xylem maybe you shouldn't assign it to arr Joseph @revisualize May 04 2016 04:51 @96street The point is to RETURN the largest number from a set of arrays. DJ @qualitymanifest May 04 2016 04:51 @Mertiant https://repl.it/CMtQ hit the run button 96street @96street May 04 2016 04:52 but isn't the highest number of each array being pushed to the base array (arr)? @revisualize Chris Cullen @123xylem May 04 2016 04:52 Well I defined arr before the forloop and it seemed to help but its only pushing E for some reason... function rot13(str) { var arr=[]; for(i=0;i<str.length;i++){ arr.push(str[i]); return arr; } } rot13("Egghj"); Joseph @revisualize May 04 2016 04:53 @96street Let me write some code for you. Coy Sanders @coymeetsworld May 04 2016 04:53 your return statement is in the for loop @123xylem Chris Cullen @123xylem May 04 2016 04:53 @coymeetsworld Yep thanx just spotted that :) .. im getting quicker CamperBot @camperbot May 04 2016 04:53 :warning: 123xylem already gave coymeetsworld points 123xylem sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles: Coy Sanders @coymeetsworld May 04 2016 04:53 np prashant @findname May 04 2016 04:53 This message was deleted Joseph @revisualize May 04 2016 04:54 @96street var arr = [1,2,3,4,5]; for (var i = 0; i < arr.length; i++) { arr.push(i); } return arr; What happens with this code? prashant @findname May 04 2016 04:55 any one why is there syntax error newArr.filter(function(newArr[i]){ return newArr[i]; }); Joseph @revisualize May 04 2016 04:55 @96street Don't run the code.. Just look at it and tell me what happens. 96street @96street May 04 2016 04:55 hmm nothing same array get's pushed Joseph @revisualize May 04 2016 04:56 [1,2,3,4,5,0] [1,2,3,4,5,0,1] [1,2,3,4,5,0,1,2] [1,2,3,4,5,0,1,2,3] 96street @96street May 04 2016 04:56 Explain?^ CamperBot @camperbot May 04 2016 04:56 usage: wiki$topic info on that topic
Joseph
@revisualize
May 04 2016 04:57
@96street The array keeps growing and growing and growing and growing and growing.
96street
@96street
May 04 2016 04:57
How can it go past arr[4] if i < arr.length? @revisualize
Joseph
@revisualize
May 04 2016 04:57
Because the evaluation is always tested to see if it SHOULD run again.
96street
@96street
May 04 2016 04:57
explain^
CamperBot
@camperbot
May 04 2016 04:57
usage:
wiki $topic info on that topic vivekraj @vivekraj-kr May 04 2016 04:58 Hi Joseph @revisualize May 04 2016 04:58 Each iteration the evaluation is re-tested. 96street @96street May 04 2016 04:58 what part of the code shows that i's always tested? it's* vivekraj @vivekraj-kr May 04 2016 04:58 can anyon explain whats wrong with this code snippet function nextInLine(arr, item) { // Your code here testArr.push(item); var rmEle = testArr.shift(arr); return rmEle; // Change this line } // Test Setup var testArr = [1,2,3,4,5]; nextInLine([5,6,7,8,9], 1); // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr, 6)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); Joseph @revisualize May 04 2016 04:58 That is how a FOR loop works. @96street This part i < arr.length; vivekraj @vivekraj-kr May 04 2016 04:59 Hello Joseph @revisualize May 04 2016 04:59 @vivekraj-kr Hi. vivekraj @vivekraj-kr May 04 2016 04:59 Im stuck here function nextInLine(arr, item) { // Your code here testArr.push(item); var rmEle = testArr.shift(arr); return rmEle; // Change this line } // Test Setup var testArr = [1,2,3,4,5]; nextInLine([5,6,7,8,9], 1); Joseph @revisualize May 04 2016 04:59 @vivekraj-kr You just pasted your code! 96street @96street May 04 2016 04:59 i < arr.length - so how does it create [1,2,3,4,5,0,1,2,3] Joseph @revisualize May 04 2016 04:59 Why repaste it? READ! Rhys @LucidNightmare May 04 2016 05:00 Hey all, reading through eloquent javascript and just hoping someone can explain this to me. function multiplier(factor) { return function(number) { return number * factor; }; } var twice = multiplier(2); console.log(twice(5)); // → 10 Why does an argument in twice() get taken as the number parameter? Related to that, why can you not omit an argument in multiplier(), and then pass two arguments to twice()? Joseph @revisualize May 04 2016 05:00 @96street var arr = [1,2,3,4,5]; for (var i = 0; i < arr.length; i++) { arr.push(i); } return arr; @96street each time the for loop runs i is being pushed to the end of the array. Thomas G. @CaptainMurphey May 04 2016 05:01 function multiplyAll(arr) { var product = 1; // Only change code below this line for(i=0;i<multiplyAll.length;i++){ for(j=0;j<multiplyAll[i];j++){ product = product * multiplyAll[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]]); Hey guys it wants me to multiply product with each item in the multiply array, what exactly is it that I supposed to multiply it with multiplyAll[i][j] doesnt seem to be it Joseph @revisualize May 04 2016 05:01 @96street therefore the array is getting longer and longer and longer. 96street @96street May 04 2016 05:01 oh shit i get it now Joseph @revisualize May 04 2016 05:01 @CaptainMurphey You're using multiplyAll and recalling the function over and over and over and over. 96street @96street May 04 2016 05:01 ok i understand that @revisualize Joseph @revisualize May 04 2016 05:01 @96street Now look at your code. @96street And see why you don't want to always be adding to your current arr. prashant @findname May 04 2016 05:02 newArr.filter(function(newArr[i]){ return newArr[i]; }); syntx err Joseph @revisualize May 04 2016 05:02 @96street Does that make a little more sense now? Thomas G. @CaptainMurphey May 04 2016 05:02 @revisualize so what would be the end product of each iteration of the for loop, like what variable holds that? Joseph @revisualize May 04 2016 05:03 @CaptainMurphey arr 96street @96street May 04 2016 05:03 kinda but would prefer you to explain it in your words Thomas G. @CaptainMurphey May 04 2016 05:03 @revisualize just the array itself? 96street @96street May 04 2016 05:03 why i shouldnt add to my current arr @revisualize Joseph @revisualize May 04 2016 05:04 @96street Because you'll just be making your current array longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer and longer @CaptainMurphey just the arr 96street @96street May 04 2016 05:04 but mine is different to that example? i'm only pushing the largest number 4 times function largestOfFour(arr) { var largest = 0; for(var i = 0; i < arr.length; i++) { for(var j = 0;j < arr[i].length; j++) { if(arr[i][j] > largest) { largest = arr[i][j]; arr[i].push(largest); } } } return arr; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); Thomas G. @CaptainMurphey May 04 2016 05:05 @revisualize ok cool thx CamperBot @camperbot May 04 2016 05:05 captainmurphey sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: Joseph @revisualize May 04 2016 05:05 @96street Where are you pushing the largest of four to? CamperBot @camperbot May 04 2016 05:05 :star2: 1063 | @revisualize |http://www.freecodecamp.com/revisualize 96street @96street May 04 2016 05:05 oh whoops look now Joseph @revisualize May 04 2016 05:06 [[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1],5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001,5,27,39,1001] 96street @96street May 04 2016 05:07 really? Joseph @revisualize May 04 2016 05:07 Really. That's what you're doing. But, it's not stopping. Ever. This message was deleted Chris Cullen @123xylem May 04 2016 05:08 Is there a way of pushing an array of numbers into String.fromCharCode ??? 96street @96street May 04 2016 05:08 explain to me how this doesn't just push the highest number of each array to the parent array:  for(var j = 0;j < arr[i].length; j++) { if(arr[i][j] > largest) { largest = arr[i][j]; arr[i][j].push(largest); } } CamperBot @camperbot May 04 2016 05:08 no wiki entry for: to me how this doesnt just push the highest number of each array to the parent array forvar j 0j arrilength j ifarrij largest largest arrij arrijpushlargest Joseph @revisualize May 04 2016 05:09 @96street DO NOT PUSH TO PARENT ARR! You're breaking your data set. 96street @96street May 04 2016 05:09 wait i think i understand is it because Joseph @revisualize May 04 2016 05:10 You want to keep the base data clean. And not pollute it with new data. 96street @96street May 04 2016 05:10 there's a new bigger number more than once in each individual array? Joseph @revisualize May 04 2016 05:10 OH! Snap. Joseph @revisualize May 04 2016 05:10 It is 10:10pm for me. Travis @dukenukethem May 04 2016 05:11 Hello everyone, I was curious if I'm setting this challenge up properly  var Car = function() { // this is a private variable var speed = 10; // these are public methods this.accelerate = function(change) { speed += change; }; this.decelerate = function() { speed -= 5; }; this.getSpeed = function() { return speed; }; }; var Bike = function() { // Only change code below this line. var gear = 1; this.getGear = function() { return gear; }; this.setGear = function() { gear += myBike; }; }; var myCar = new Car(); var myBike = new Bike(); 96street @96street May 04 2016 05:11 ok i'm making a seperate array @revisualize Travis @dukenukethem May 04 2016 05:11 Joseph @revisualize May 04 2016 05:11 @96street :clap: :fireworks: 96street @96street May 04 2016 05:11 but i don't change the parameter right? function largestOfFour(arr) <<<keep 'arr' ? Joseph @revisualize May 04 2016 05:11 Keep that the same. :clock1030: I need to get to bed. 96street @96street May 04 2016 05:14 wait definately getting close now: function largestOfFour(arr) { var largest = 0; var answer = []; for(var i = 0; i < arr.length; i++) { for(var j = 0;j < arr[i].length; j++) { if(arr[i][j] > largest) { largest = arr[i][j]; answer.push(largest); } } } return answer; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); Anurag Lahon @anuraglahon16 May 04 2016 05:15 @revisualize which exercise it is Joseph @revisualize May 04 2016 05:16 @96street Great! @anuraglahon16 I'm not working on it. Anurag Lahon @anuraglahon16 May 04 2016 05:16 @96street which exercise Joseph @revisualize May 04 2016 05:16 I'm helping. @96street Now move.. @96street answer.push(largest); out of the nested for loop and you're done. 96street @96street May 04 2016 05:16 it's pushing the newest biggest number to the console, but not THE biggest number of each array not sure how to fix atm... Joseph @revisualize May 04 2016 05:17 @96street I just told you. Alhaji Turay @Alhaji24 May 04 2016 05:17 I cant understand Introducing JavaScript Object Notation JSON Joseph @revisualize May 04 2016 05:17 You want the largest to be pushed after you iterate through the loop. 96street @96street May 04 2016 05:17 doesn't work it consoles [5,27,39,1001] :/ wtf Joseph @revisualize May 04 2016 05:18 @96street Okay! 96street @96street May 04 2016 05:18 shouldn't that work Joseph @revisualize May 04 2016 05:18 @96street What are the other tests? 96street @96street May 04 2016 05:18 largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return [27,5,39,1001]. that's the error Hung Truong @hungtruong97 May 04 2016 05:19 help code CamperBot @camperbot May 04 2016 05:19 ## :point_right: 10 steps to plan better so you can write less code [wiki] # Learn how to plan your future project! Blog post written by BiancaMihai - GitHub / Twitter An ounce of preparation is worth a pound of cure. That's true in medicine, and that's definitely true in software development. Here's a structured 10-step workflow that will guide you through the app planning process, with the goal of saving you from writing a lot of unnecessary code. Together, we'll plan out a simple "To-do" single-page web app. We'll also plan for an API backend for a future mobile app. 96street @96street May 04 2016 05:19 Nah it's just an FCC error, that's the correct answer Travis @dukenukethem May 04 2016 05:19  var Car = function() { // this is a private variable var speed = 10; // these are public methods this.accelerate = function(change) { speed += change; }; this.decelerate = function() { speed -= 5; }; this.getSpeed = function() { return speed; }; }; var Bike = function() { // Only change code below this line. var gear = 0; this.setGear = function(change) { gear += change; }; this.getGear = function() { return gear; }; }; var myCar = new Car(); var myBike = new Bike(); myBike.setGear(4); myBike.getGear(); could anyone tell me what im doing wrong? Hung Truong @hungtruong97 May 04 2016 05:19  function factorialize(num) { if (num ===0) { return 1; } else {var arr = [num]; for (i=1; i<num; i++) { arr.unshift(i); } fac = arr.reduce(function(a,b) { return a*b; }); return fac; } } factorialize(0); 96street @96street May 04 2016 05:19 THANKYOU @revisualize CamperBot @camperbot May 04 2016 05:19 96street sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :star2: 1064 | @revisualize |http://www.freecodecamp.com/revisualize Joseph @revisualize May 04 2016 05:19 @96street No no.. It is erroring. You're code isn't correct. 96street @96street May 04 2016 05:19 what Joseph @revisualize May 04 2016 05:20 Look where you're setting Largest Hung Truong @hungtruong97 May 04 2016 05:20 I passed this challenge, but I wonder if there are any other simpler ways to do it? Joseph @revisualize May 04 2016 05:20 @96street You need... 96street @96street May 04 2016 05:20 but the output is correct? [5,27,39,1001] Joseph @revisualize May 04 2016 05:20 @96street var largest = 0; inside the first for loop. 96street @96street May 04 2016 05:21 COMPLETED Travis @dukenukethem May 04 2016 05:21 help Make Object Properties Private CamperBot @camperbot May 04 2016 05:21 ## :point_right: challenge make object properties private [wiki] Objects have their own attributes, called properties_, and their own functions, called _methods. You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope. var Bike = function() { var speed = 100; // private function addUnit(value) { // private return value + "KM/H"; } this.getSpeed = function () { // public return addUnit(speed); }; }; Another example: 96street @96street May 04 2016 05:21 much appreciated! @revisualize prashant @findname May 04 2016 05:21 @dukenukethem your code ran fine Joseph @revisualize May 04 2016 05:21 @96street Do you understand why? AKINNUBI ABIOLA SYLVESTER @nakinnubis May 04 2016 05:21 i am not getting how the freecodecamp questions are written for the algorithm section i am only able to solve the first two challenges after reading and reading for several hour they need to restructure how they ask question Travis @dukenukethem May 04 2016 05:22 its not passing the last parameters of the challenge though Christina @cgraham74 May 04 2016 05:22 help sorted union CamperBot @camperbot May 04 2016 05:22 ## :point_right: algorithm sorted union [wiki] # Problem Explanation: • The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates. :pencil: read more about algorithm sorted union on the FCC Wiki 96street @96street May 04 2016 05:22 not clearly, please explain @revisualize Joseph @revisualize May 04 2016 05:22 @96street Here's my code: function largestOfFour(arr) { var pushArray = []; for (var i = 0; i < arr.length; i++) { for (var x = 0, largestNumber = 0; x < arr[i].length; x++) { if (arr[i][x] > largestNumber) { largestNumber = arr[i][x]; } } pushArray.push(largestNumber); } return pushArray; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]); largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]); DJ @qualitymanifest May 04 2016 05:23 @hungtruong97 yes, it can be done with one for loop and without an if/else statement, without the .reduce Joseph @revisualize May 04 2016 05:23 @96street What happens if the first arr is [1000,2000,3000] but the second set is [2,8,6] Travis @dukenukethem May 04 2016 05:23 there was a + where it didnt belong! Hung Truong @hungtruong97 May 04 2016 05:23 @qualitymanifest At first I tried the for loop like this Joseph @revisualize May 04 2016 05:23 @96street If you don't reset the largest to 0 on each set run.. It won't return the largest of the second set. 96street @96street May 04 2016 05:23 ohh it only iterates through the same about of spots than the parent (4)? Joseph @revisualize May 04 2016 05:24 So, you need to reset the largest to 0. And start again. Rhys @LucidNightmare May 04 2016 05:24 Hey all, reading through eloquent javascript and just hoping someone can explain this to me. function multiplier(factor) { return function(number) { return number * factor; }; } var twice = multiplier(2); console.log(twice(5)); // → 10 Why does an argument in twice() get taken as the number parameter? Related to that, why can you not omit an argument in multiplier(), and then pass two arguments to twice()? 96street @96street May 04 2016 05:24 right AKINNUBI ABIOLA SYLVESTER @nakinnubis May 04 2016 05:24 please can anyone help explain the Check for Palindromes? i mean the algorithm challenges prashant @findname May 04 2016 05:24 @dukenukethem you mean speed += change; Joseph @revisualize May 04 2016 05:24 @nakinnubis Sure. What do you need? Hung Truong @hungtruong97 May 04 2016 05:24 for (i=1; i<num; i++) { fac = 1; fac= fac * (i+1); } return fac; 96street @96street May 04 2016 05:25 that makes sense, thankyou @revisualize CamperBot @camperbot May 04 2016 05:25 96street sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :warning: 96street already gave revisualize points 96street @96street May 04 2016 05:25 all cleared up pretty sure Joseph @revisualize May 04 2016 05:25 @nakinnubis A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing. Note You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes. Hung Truong @hungtruong97 May 04 2016 05:25 @qualitymanifest it dont know why it doesnt run. DJ @qualitymanifest May 04 2016 05:25 @hungtruong97 well there you're resetting fac to 1 with each run of the loop Joseph @revisualize May 04 2016 05:26 @96street Do you see how I did... for (var x = 0, largestNumber = 0; x < arr[i].length; x++) { AKINNUBI ABIOLA SYLVESTER @nakinnubis May 04 2016 05:26 96street @96street May 04 2016 05:26 what differecne does it make putting it in the for loop? @revisualize AKINNUBI ABIOLA SYLVESTER @nakinnubis May 04 2016 05:26 okay @revisualize Joseph @revisualize May 04 2016 05:26 @96street None really, it's just a little cleaner. @96street Doing multiple var initialization at once. 96street @96street May 04 2016 05:27 so var largest doesn't reset to 0 when declared outside the parent for loop? Joseph @revisualize May 04 2016 05:27 Nope. largest = 0; for .... { for ... { } } Largest wouldn't get reset. 96street @96street May 04 2016 05:28 gotcha Joseph @revisualize May 04 2016 05:28 for .... { largest = 0; for ... { } } that way it does. Damn.. :clock1030:pm .. I need to get to bed. :zzz: ... :sailboat: ... :zzz: ... :sailboat: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :dolphin: :whale2: :sunrise: ... :zzz: prashant @findname May 04 2016 05:33 { newArr.filter(function(newArr[i]){ return newArr[i]; }); i am getting syntax err Coryphaeus @cvdeby May 04 2016 05:41 @findname you cannot use variable value like a parameter name , you have to define unique parameter name instead. For example var a = "2"; arr.map(function (a) { return a; // will return each array element, not 2, because you defined New attribute/parameter 'a' and replaced global variable 'a'; }); Hung Truong @hungtruong97 May 04 2016 05:41 @qualitymanifest I did it now. I put the "fac = 1" outside of the loop and it worked. thanks a lot CamperBot @camperbot May 04 2016 05:41 hungtruong97 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles: :star2: 1150 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest DJ @qualitymanifest May 04 2016 05:41 @hungtruong97 nice :+1: Chris Cullen @123xylem May 04 2016 05:42 Any tips on my use of foreach with charCodeAt method? Im getting blank answer  function charcode(value){ String.fromCharCode(value); return value; } return codeArr.forEach(charcode); John KM J @rkdmen May 04 2016 05:45 hello guys...I'm having trouble finding the longest word function findLongestWord(str) { var longWord = ""; for (var i=0; i<str.length;i++) if( str[i].length>longWord.length){ longWord = str[i]; } return longWord; } findLongestWord("The quick brown fox jumped over the lazy dog"); anyone know what's wrong.. kirbyedy @kirbyedy May 04 2016 05:47 @rkdmen you might want to split your string first Coryphaeus @cvdeby May 04 2016 05:48 @123xylem If I'm right(It is simple to check :smile:) forEach works like a loop, so after first return your loop will stop, and actually your value hasn't been changed, you got character from that value, but you did nothing with that character. @rkdmen str.length is always equal to 1. Because it is just one character you got within an index of that string. Chris Cullen @123xylem May 04 2016 05:52 @cvdeby I tried adding a var to assign forEach output to and even seperated the return with a bracket but still no output  function charcode(value){ String.fromCharCode(value); return value; } var answer=""; answer = codeArr.forEach(charcode); return answer; Coryphaeus @cvdeby May 04 2016 05:54 @rkdmen Instead you should convert given string to words(you can use split, like @kirbyedy offered or you can to use Regex, but in your case split is more convenient method) @123xylem The problem is what your callback function returns. John KM J @rkdmen May 04 2016 05:57 @kirbyedy @cvdeby Thank you guys! its working now with str.split(" ") CamperBot @camperbot May 04 2016 05:57 rkdmen sends brownie points to @kirbyedy and @cvdeby :sparkles: :thumbsup: :sparkles: :cookie: 398 | @cvdeby |http://www.freecodecamp.com/cvdeby :cookie: 950 | @kirbyedy |http://www.freecodecamp.com/kirbyedy Coryphaeus @cvdeby May 04 2016 05:57 @123xylem You returned value, but what that value contains? For now nothing changed, you can try to return String.fromCharCode(value) instead of value. But actually you don't need to return something within a forEach, because forEach works like a loop Chris Cullen @123xylem May 04 2016 05:58 Yea i tried to return String.fromCharCode; But no ouput If I add (value) it may help... Or are you saying have no return? RJsauce @RJsauce May 04 2016 05:58 This message was deleted Chris Cullen @123xylem May 04 2016 06:00 Ive tried the function with no return... Still nothing... Coryphaeus @cvdeby May 04 2016 06:00 Yeah, you can generate new one array or replace each codeArr charcode with the character. You can replace it with splice function RJsauce @RJsauce May 04 2016 06:01 Hello everyone! This is a function for the Seek and Destroy Bonfire, I understand everything except for where the .filter function gets its element parameter from. Can you please explain?  function destroyer(arr) { var elemToDestroy = []; for (var i = 1; i < arguments.length; i++) { elemToDestroy.push(arguments[i]); } var survived = arguments[0].filter(function(element, index) { var toReturn = true; for (var i = 0; i < elemToDestroy.length; i++) { if (element === elemToDestroy[i]) { toReturn = false; } } return survived; }); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Coryphaeus @cvdeby May 04 2016 06:01 forEach function returns nothing, If you need cycle - you can to use map function instead @123xylem This one should work var callback = function(value) { return String.fromCharCode(value); }; return codeArr.map(func); Chris Cullen @123xylem May 04 2016 06:03 ah I see what your saying. Anurag Lahon @anuraglahon16 May 04 2016 06:04 hey guys wht dz line do str.split(/\s+/); ?? Coryphaeus @cvdeby May 04 2016 06:06 @anuraglahon16 It'll split 'str' by multiple spaces var str = ' so many spaces '; console.log(str.split(/\s+/)); // ['so', 'many', 'spaces'] Anurag Lahon @anuraglahon16 May 04 2016 06:08 @cvdeby oh lyt dat Coryphaeus @cvdeby May 04 2016 06:09 @anuraglahon16 I'm sry, but what is lyt dat, English is not my native language) Anurag Lahon @anuraglahon16 May 04 2016 06:09 @cvdeby it is used for multiple spaces ionakathryn @ionakathryn May 04 2016 06:10 function palindrome(str) { // Good luck! var x= str.replace((/[^A-Za-z0-9/s\,\.]/g),""); x.toLowerCase(); var o = x.split(""); o.reverse(); var p = o.join(""); var n=str.split(""); n.reverse(); var s=n.join(); if(p ===str || s===str) { return true; } else{ return false; } } palindrome("738dsa!!!3$KKo!!");
Hi i am trying to work on this problem but having problems checking strings whoch have spaces & non alphanumeric don't match . can you help please? :)
Brendon
@Balvamar
May 04 2016 06:13
Hi All, I am working on "Where Do I Belong" at the moment. " getIndexToIns([3, 10, 5], 3) should return 0." when I run array.sort , it returns [10,3,3,5], therefore my index is incorrect. Can anyone explain why this happens?
Chris Cullen
@123xylem
May 04 2016 06:13
@cvdeby Btw the .map worked... So it was because forEach doesnt give an output it just puts an arrays elements through an already created function?
@cvdeby and thanks
CamperBot
@camperbot
May 04 2016 06:13
123xylem sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
Brendon
@Balvamar
May 04 2016 06:14
also codepen keeps freezing then crashing on me, am using chrome
Chris Cullen
@123xylem
May 04 2016 06:15
Im getting 2 errors here. One is My mid char N isnt being sorted correctly and 2nd error is its hyphenating spaces... My IF statements should be ignoring any char outside the A-Z range Including the N but for some reason I havent got my IF statements right. Am I missing something?

function rot13(str) {
var arr=[];
var code=0;
var codeArr=[];

for(i=0;i<str.length;i++){
arr.push(str[i]);}

for (j=0;j<arr.length;j++){
code= arr[j].charCodeAt();
codeArr.push(arr[j].charCodeAt());
}

for (k=0;k<codeArr.length;k++){

if(codeArr[k] < 65 || codeArr[k] > 91)
{codeArr[k] =codeArr[k];}

if(codeArr[k]  <77  ){
codeArr[k] += 13;}

else if (codeArr[k]  >78){
codeArr[k] -= 13;}

else {codeArr[k] =codeArr[k];}}

function charcode(value){
String.fromCharCode(value);
return String.fromCharCode(value);
}

}
rot13("SERR PBQR PNZC");
96street
@96street
May 04 2016 06:18
how do I set opacity 0.8 to the whole window outside my div?
Robert Richey
@0x0936
May 04 2016 06:19
@Balvamar to sort by numeric values, instead of the default lexical values, you'll need to pass a function to sort to define a custom behavior.
arr.sort(function(a, b) {
// plus sign prefixing variable is a short-hand conversion to a number
return +a - +b
})`
dheerajahuja000
@dheerajahuja000
May 04 2016 06:19
i am dynamically creating buttons
but they dont have space between them
Brendon
@Balvamar
May 04 2016 06:20
@0x0936 ok thanks, will try that :)
CamperBot
@camperbot
May 04 2016 06:20
balvamar sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1298 | @0x0936 |http://www.freecodecamp.com/0x0936