27th
May 2017
Christopher McCormack
@cmccormack
May 27 2017 00:01
@clareagarcia right, number is a function name, it applies `Number(item)` to each item in numStr
Long Nguyen
@longnt80
May 27 2017 00:01
can anyone test my calculator:
https://codepen.io/longnt80/full/Kmeoaq/
lesleywayne
@Lwave
May 27 2017 00:02
@longnt80 works fine :) i think and its cool haha
Christopher McCormack
@cmccormack
May 27 2017 00:03
@clareagarcia equivalent using an anonymous function: `numStr.split(' ').map( function(item) { return Number(item); } )` //[ 101, 1, 11 ]
Clare
@clareagarcia
May 27 2017 00:04
@cmccormack Oh okay I see. That makes sense, guessing that Number is a built in function to the browser then
Long Nguyen
@longnt80
May 27 2017 00:04
@Lwave thanks
you can give it any weird type of inputs combination to make it break
CamperBot
@camperbot
May 27 2017 00:04
longnt80 sends brownie points to @lwave :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
May 27 2017 00:05
@clareagarcia built in to Javascript - https://mdn.io/Number
@clareagarcia beware if it cannot be converted, you'll get a `NaN` back, and if you need to check for `NaN` you can use `Number.isNaN(variable)`
lesleywayne
@Lwave
May 27 2017 00:07
does anyone know how to make the celsius to fahrenheit work for all of them?
Christopher McCormack
@cmccormack
May 27 2017 00:07
that said, I'm out of here :wave:
Clare
@clareagarcia
May 27 2017 00:07
gotcha, thanks
Victor Romero
@vromero2017
May 27 2017 00:10
@Lwave what do you mean by work for all of them??
Victor Romero
@vromero2017
May 27 2017 00:12
you just have to do it once, then you just have to chance the numbers below and it will work for all.
lesleywayne
@Lwave
May 27 2017 00:13
@vromero2017 chance?
Victor Romero
@vromero2017
May 27 2017 00:13
sorry *change
lesleywayne
@Lwave
May 27 2017 00:13
I think i tried that but it wont mark green for each one for some reason.
see how 20 and 30 is on there but it wont complete it
@vromero2017
Victor Romero
@vromero2017
May 27 2017 00:14

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

fahrenheit = 0 9/5 + 32;
fahrenheit = 20
9/5 + 32;
fahrenheit = -30 * 9/5 + 32;

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

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

lesleywayne
@Lwave
May 27 2017 00:14
yes
@vromero2017
Victor Romero
@vromero2017
May 27 2017 00:15
ok, you declared fahrenheit just right after the function.
lesleywayne
@Lwave
May 27 2017 00:15
ok.. ?
Victor Romero
@vromero2017
May 27 2017 00:15
forget about the 3 values that the test give, and concentrate just on 1
lesleywayne
@Lwave
May 27 2017 00:15
oh okat
Victor Romero
@vromero2017
May 27 2017 00:16
what is the formula to convert celsius to fahrenheit
??
dyon3334
@dyon3334
May 27 2017 00:16
do someone know good books for learning javascript
lesleywayne
@Lwave
May 27 2017 00:16

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

fahrenheit = 20 * 9/5 + 32;

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

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

Victor Romero
@vromero2017
May 27 2017 00:17
ok, almost
lesleywayne
@Lwave
May 27 2017 00:17
it checked the one for 20
Victor Romero
@vromero2017
May 27 2017 00:17
now, FH = (9/5 Celc + 32)
to make it easy 9/5 is equal to???
Joseph
@revisualize
May 27 2017 00:18

@Lwave There is the function declaration of `function convertToF(celsius) {` .. You have a function name of `convertToF` and a parameter of `celsius`
Parameters are used just like variables. So, inside of the function you can use `celsius` JUST like any other variable.
If I have this code:

``````function addThree (num) {
var result;
result = num + 3;
return result;
}``````

So, when we make the function call of:

``addThree(10);``

You're calling the function `addThree` You're also passing a value `10` as an argument.
In the function declaration of `function addThree (num) {` You see that there is a parameter defined of `num`
When we do `addThree(10)` then the value of the parameter `num` is passed the argument value of ... `10`
Then if you follow the code through.. `result = num + 3;` ... and we know the value of `num` is `10`.
Therefore, if we follow through the function we end up with ... `result = 10 + 3;` then `result = 13;` then we return the `result`.
...
If you then make another function call..

``addThree(39);``

You can use the same function to follow the operation:
When we do `addThree(39)` then the value of the parameter `num` is passed the argument value of ... `39`
Then if you follow the code through.. `result = num + 3;` ... and we know the value of `num` is now `39`.
Therefore, if we follow through the function we end up with ... `result = 39 + 3;` then `result = 42;` then we return the `result`.

If you make the function call of `addThree(21)` the value of `num` inside the function is 21.
If you make the function call of `addThree(1000)` the value of `num` inside the function is 1000.
If you make the function call of `addThree(123456)` the value of `num` inside the function is 123456.
function declaration of `function convertToF(celsius) { }` making the function call `convertToF(55)` the parameter `celsius` inside of the function has a value of 55
function declaration of `function convertToF(celsius) { }` making the function call `convertToF(23)` the parameter `celsius` inside of the function has a value of 23

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32

Victor Romero
@vromero2017
May 27 2017 00:18
yes, but what happen is that you are assigning the value of 20 manually to the var, instead you have to call the function argument, and change the values below
if I am not being clear enought see @revisualize sample, he always gave the answers as samples.
hey @revisualize I am stuck again,
lesleywayne
@Lwave
May 27 2017 00:20
@revisualize @vromero2017 okay got it guys. thanks!!
CamperBot
@camperbot
May 27 2017 00:20
lwave sends brownie points to @revisualize and @vromero2017 :sparkles: :thumbsup: :sparkles:
:star2: 4019 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 27 2017 00:21
@vromero2017 With?
Victor Romero
@vromero2017
May 27 2017 00:21
Stand in Line
Damien
@DubbDevs
May 27 2017 00:21
need a bit of guidance with the Chunky monkey algo
``````function chunkArrayInGroups(arr, size) {
var chunkedArr = [];           //array initialized

for (var i = 0; i < arr.length; i++) {
chunkedArr = arr.slice(0, size);
}                              //loop should break array into size
return chunkedArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);``````
Victor Romero
@vromero2017
May 27 2017 00:21

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

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

Joseph
@revisualize
May 27 2017 00:21

@vromero2017 Stand In Line is a CheckPoint where you're supposed to:
Write a function `nextInLine` which has two parameters
an array (`arr`) and a number (`item`).
That part has been done for you here:

``function nextInLine(arr, item) { }``

With that function declaration you have a function name of `nextInLine`. You have two parameters `arr` which represents an array passed into the function and `item` that represents a number passed to the function.
A few example function calls:

`nextInLine([4,3,2] , 1)` the values passed to `arr` is `[4,3,2]` and the value passed to `item` is `1`

`nextInLine([2,4,6,8] , 10)` ... `arr` is `[2,4,6,8]` & `item` is `10`

`nextInLine([2,3,5,7,11] , 13)` ... `arr` is `[2,3,5,7,11]` & `item` is `13` (first 5 and 6th prime numbers)

`nextInLine([] , 0)` ... `arr` is `[]` & `item` is `0`

`var myArr = [1,3,5,7]; nextInLine(myArr , 9)` ... `arr` is `[1,3,5,7]` a copy of the value of the global variable `myArr` & `item` is `9`

Parameters are treated like `variables` that represent the values that get passed into your function from the function call (arguments).

Again the two parameters for the `nextInLine` function are `arr` & `item`.

Per the instructions: Add the number to the end of the array, then remove the first element of array. The `nextInLine` function should then return the element that was removed.

You need to add the number (`item`) to the end of an array (`arr`).
You also need to remove the first element from an array (`arr`).

Then you need to have your function `return` the removed element from the array `arr`.

Victor Romero
@vromero2017
May 27 2017 00:22
I have problems sometimes understanding the text, English is not my first language even if the samples are very clear, sorry
Clare
@clareagarcia
May 27 2017 00:22
Is there a simple way to check if an objects property is not Nan, undefined, empty string, etc. ?
Joseph
@revisualize
May 27 2017 00:23
@clareagarcia Object Property?
@clareagarcia Like
``````var myObj = {
"key": "value"
}``````
Clare
@clareagarcia
May 27 2017 00:24
yes
I want "key" to not be undefined, NaN, or emtpy string
or a way to check that
Joseph
@revisualize
May 27 2017 00:24
@clareagarcia Can't do that.
Key can't be `undefined`
Never.
Note: "undefined" and `undefined` are two different things.
Clare
@clareagarcia
May 27 2017 00:25
hm
Joseph
@revisualize
May 27 2017 00:25
@clareagarcia What are you actually trying to do?
Clare
@clareagarcia
May 27 2017 00:26
Here's what I'm working with
``````
function truthCheck(collection, pre) {

// Is everyone being true?
return collection.every(obj => obj.hasOwnProperty(pre));
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");``````
Right now, it returns true if they have the property, but also needs to return false if the property listed is say "", or maybe the property we are searching is age, and age is set to 0! I need to return false
Joseph
@revisualize
May 27 2017 00:26
@clareagarcia Oh...You're looking to see if the VALUE is true
Clare
@clareagarcia
May 27 2017 00:27
yes
Joseph
@revisualize
May 27 2017 00:27
@clareagarcia `Boolean()`
Clare
@clareagarcia
May 27 2017 00:28
@revisualize Worked perfectly, thanks!
``````
function truthCheck(collection, pre) {

// Is everyone being true?
return collection.every(obj => obj.hasOwnProperty(pre) && Boolean(obj[pre]));
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");``````
CamperBot
@camperbot
May 27 2017 00:28
clareagarcia sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4020 | @revisualize |http://www.freecodecamp.com/revisualize
Clare
@clareagarcia
May 27 2017 00:28
Boolean wasn't even on my radar
Joseph
@revisualize
May 27 2017 00:28
@clareagarcia That's exactly how I solved that challenge.
Clare
@clareagarcia
May 27 2017 00:29
awesome. I'm glad to finally use .every() lol
Joseph
@revisualize
May 27 2017 00:34
@vromero2017 Stil there?
Damien
@DubbDevs
May 27 2017 00:39
can I get some assistance with my logic for the Chunky Monkey algorithm
``````function chunkArrayInGroups(arr, size) {
var chunkedArr = [];           //array initialized

for (var i = 0; i < arr.length; i++) {
chunkedArr = arr.slice(0, size);
}                              //loop should break array into size
return chunkedArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);``````
I know the loop should keep going and I still need to push the result into a new array...seems my loop is flawed
c0d0er2
@c0d0er2
May 27 2017 00:48

Can somebody please help me with Iterate Through an Array with a For Loop in JavaScript? Here is my code:

``````// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

for (var i = 0; i < arr.length; i++) {
ourTotal += ourArr[i];
}``````
Damien
@DubbDevs
May 27 2017 00:50
Stephen James
@sjames1958gm
May 27 2017 00:55
@DubbDevs You need to loop arr.length / size times (you can increment i by size to do that)
you should think of a way to use i in your slice parameters
@Lwave Your escape sequences should be on either side of SecondLine, newline backslash and backslash carriage-return
`newlinebackslashSecondLinebackslashcarriage-return`
Victor Romero
@vromero2017
May 27 2017 01:01
hi @revisualize I am still here, but have to so something else, I am looking again
Zachary David Saunders
@ZacharyDavidSaunders
May 27 2017 01:01
Hello. Is it bad practice to use whether or not a variable has been initialized as an indicator if something has happened?
For example, the `while()` in this code:
``````function createAccount(){

var firstName;
var lastName;
var email;

while(firstName == undefined){
var firstNameEntered = utils.getUserInput(false);
if(firstNameEntered === "")
{
console.log("The first name that you entered is too short. Please try again!")
}else{
firstName = utils.encrypt(firstNameEntered);
}
}``````
lesleywayne
@Lwave
May 27 2017 01:02
@sjames1958gm myStr should have encoded text with the proper escape sequences and no spacing.
RyanHuang06
@RyanHuang06
May 27 2017 01:04
Can someone help me on the challene called Stand in Line?
Victor Romero
@vromero2017
May 27 2017 01:05
i am looking at the same @RyanHuang06
RyanHuang06
@RyanHuang06
May 27 2017 01:05

```function nextInLine(arr, item) {
arr.unshift(arr[0]);
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 27 2017 01:07
@RyanHuang06 You should only be pushing item onto arr.
shift() is used to remove the value not unshift
Damien
@DubbDevs
May 27 2017 01:07
``````@DubbDevs  You need to loop arr.length / size times (you can increment i by size to do that)
you should think of a way to use i in your slice parameters``````
I think I get hat you're saying just lost as to how to implement it.
Stephen James
@sjames1958gm
May 27 2017 01:08
@DubbDevs You can do i += size instead of i++
then `slice(i, i+size)`
@Lwave What does your string look like?
@RyanHuang06 Perhaps go back and review the push/shift challenges?
lesleywayne
@Lwave
May 27 2017 01:08
@sjames1958gm var myStr = "FirstLine\n\rSecondLine\\ThirdLine\";
RyanHuang06
@RyanHuang06
May 27 2017 01:09
@sjames1958gm mistyped
Stephen James
@sjames1958gm
May 27 2017 01:09
@Lwave You have newline carriage-return SecondLine backslash backslash (with an extra escape at the end.
Should be `newline backslash SecondLine backslash carriage-return`
RyanHuang06
@RyanHuang06
May 27 2017 01:10
`testing`
`testing`
`testing`
how to type code
not like what I typed
Stephen James
@sjames1958gm
May 27 2017 01:12
@RyanHuang06 Use three ` then shift-enter then paste then shift-enter then three `
lesleywayne
@Lwave
May 27 2017 01:13
@sjames1958gm hmm, still not getting anything
Osvaldo Rodriguez
@orodrig6
May 27 2017 01:15
Can you debug in the free code camp compiler? like step through each line
slavastarikov
@slavastarikov
May 27 2017 01:15
hello could use some help with Escape Sequences in Strings. Trying to convert this string ˆˆ
and here is my codeˆˆ
if someone could please take a look, I would really appreciate it
lesleywayne
@Lwave
May 27 2017 01:17
@slavastarikov im on the same problem but if you get the answer let me know
Stephen James
@sjames1958gm
May 27 2017 01:17
@slavastarikov Your string is correct - it will not show the string as three lines (instructions are misleading)
slavastarikov
@slavastarikov
May 27 2017 01:17
haha, wow just joined
Stephen James
@sjames1958gm
May 27 2017 01:18
@orodrig6 You cannot. But people have suggested python tutor (with javascript mode) for just that
slavastarikov
@slavastarikov
May 27 2017 01:18
aw crap i was missing the semicolon
thanks @sjames1958gm !!
CamperBot
@camperbot
May 27 2017 01:18
slavastarikov sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7507 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
May 27 2017 01:18
@RyanHuang06 Did you solve your challenge?
slavastarikov
@slavastarikov
May 27 2017 01:19
@Lwave i guess my code was right, just need a semicolon. let me know if you'd like an explanation :-)
(semicolon at the end)
lesleywayne
@Lwave
May 27 2017 01:19
@slavastarikov yeah i just got it from yours.. the only problem was setting it up for me??
Stephen James
@sjames1958gm
May 27 2017 01:20
@slavastarikov :+1:
Clare
@clareagarcia
May 27 2017 01:20

I don't get this exercise. http://beta.freecodecamp.com/en/challenges/intermediate-algorithm-scripting/make-a-person

Our Person constructor is made up of only functions. Where can I store the full name of the object when it's created?

``````var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
this.setFirstName = function (name) {
var arrName = name.split(" ");
this.firstName = arrName[0];
};
this.setLastName = function(firstAndLast) {
var arrName = name.split(" ");
this.lastName = arrName[1];
};

this.setFullName = function (firstAndLast){
var arrName = name.split(" ");
this.fullName = arrName[0] + " " + arrName[1];
};

this.getFullName = function() {
return "";
};
this.getFirstName = function () {
return this.firstName;
};
this.getLastName = function () {
return this.lastName;
};
return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFullName();``````
In all my notes, we assign this.name to the name that is passed in the function
Stephen James
@sjames1958gm
May 27 2017 01:21
@clareagarcia create local variables to function -
Request-Off-Work
@Request-Off-Work
May 27 2017 01:23
Hello room :)
Clare
@clareagarcia
May 27 2017 01:23
@sjames1958gm What do you mean local variables to function? Create local variables outside functions? Create local variables inside each function?
Stephen James
@sjames1958gm
May 27 2017 01:23

@clareagarcia You can do

``````var Person = function(firstAndLast) {
var firstName;
var lastName;
var fullName;``````

then refer to them in the functions (without this.)
also, don't `return firstAndLast` return this

Clare
@clareagarcia
May 27 2017 01:23
I have that now, nothing seemed to change
Except for return this, ill check
slavastarikov
@slavastarikov
May 27 2017 01:24
@Lwave I noticed you had: var myStr = "FirstLine\n\rSecondLine\ThirdLine\"
it seems with \n\r you're calling out both a new line and a carriage return, yet the instructions only asked for a \n, and after the second row the instructions asked for a return carriage so that's why i used \r. It also does not seem you need the last escape you put before the final quote
hope that helps
Stephen James
@sjames1958gm
May 27 2017 01:24
@clareagarcia Similar to this challenge `Make Object Properties Private`
Request-Off-Work
@Request-Off-Work
May 27 2017 01:24

I have an array of times. What I'd like to do is eliminate all times AFTER 12 hours. That means if it's 5pm, go back to the start of the array and remove 6am to 4:30pm... How do I go back to the start of an array?

Do I use a loop or if statements on this one?

Clare
@clareagarcia
May 27 2017 01:25
I don't see where we are using firstAndLast
``````var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
var fullName;
var firstName;
var lastName;

this.setFirstName = function (name){
var arrName = name.split(" ");
this.firstName = arrName[0];
};
this.setLastName = function(name) {
var arrName = name.split(" ");
this.lastName = arrName[1];
};

this.setFullName = function (name){
var arrName = name.split(" ");
this.fullName = arrName[0] + " " + arrName[1];
};

this.getFullName = function() {
return this.fullName;
};
this.getFirstName = function () {
return this.firstName;
};
this.getLastName = function () {
return this.lastName;
};
return this;
};

var bob = new Person('Bob Ross');
bob.getFullName();``````
Stephen James
@sjames1958gm
May 27 2017 01:25
@Request-Off-Work shift() will remove the first value in an array.
Request-Off-Work
@Request-Off-Work
May 27 2017 01:25
maybe slice the array 12 hours....
thanks @sjames1958gm
CamperBot
@camperbot
May 27 2017 01:25
request-off-work sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7508 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Clare
@clareagarcia
May 27 2017 01:26
Also aren't functions of objects supposed to be prototypes?
Stephen James
@sjames1958gm
May 27 2017 01:26
@clareagarcia You need to use firstAnd Last to set the local variables in the function (construction)
Don't use this.firstName - remove this (for all)
@clareagarcia They don't have to be - This way will work - but would be inefficient in that every Person would have a copy of all the functions.
@clareagarcia If they were on the prototype they couldn't access the private variables
Mithun reddy
@mithunreddyt
May 27 2017 01:28
can any one please help me, I think i understand a concept, but i am not able to solve a real world problem or example, how can i come up this problem.
Stephen James
@sjames1958gm
May 27 2017 01:28
@mithunreddyt Give us more detail
Victor Romero
@vromero2017
May 27 2017 01:29
@mithunreddyt what's up??
Mithun reddy
@mithunreddyt
May 27 2017 01:31
I mean I am not getting how to implement the concept which i learnt in solving a example
DaniellaMia
@DaniellaMia
May 27 2017 01:31
I know this is probably a super simple question but how would you get values to return undefined?
Clare
@clareagarcia
May 27 2017 01:32
Okay i don't know when to use this or not, im just guessing now and getting nowhere
"Constructors use the keyword this to set properties of the object they will create. Inside the constructor, this refers to the new object it will create", so I should use this with my local variables?
Mithun reddy
@mithunreddyt
May 27 2017 01:35
@sjames1958gm @vromero2017 Example if i want to solve a palindrome example i know we need create the variables and call them, use loops etc, but how to approach with logic
OlaNeat Ayoola
@olaneat
May 27 2017 01:37
sup guyz
i'm kinda confused here can somone help pls
Xarri Jorge
@xarrijorge
May 27 2017 01:38
@olaneat Heya
OlaNeat Ayoola
@olaneat
May 27 2017 01:38
hello @kodinglife

hw can i fix this an move on var myStr; // Change this line

myStr; = / Firstline;
\SecondLine\;
ThirdLine
/, cause i've done wat in the instruction but yet i'm still stuck here

Xarri Jorge
@xarrijorge
May 27 2017 01:39
Anyone here from new mexico, Albuquerque in particular?
Stephen James
@sjames1958gm
May 27 2017 01:40
@clareagarcia If you use this then they become public properties of the object. When you use local variables like this they are private by closure.
@olaneat Don't try to make it more than one line - just copy the string provided and replace the key words with escape sequences
@mithunreddyt Did you do the reverse a string challenge?
Mithun reddy
@mithunreddyt
May 27 2017 01:41
@sjames1958gm no
Stephen James
@sjames1958gm
May 27 2017 01:42
@mithunreddyt If you can reverse the string then you can compare the string to its reversed value
Xarri Jorge
@xarrijorge
May 27 2017 01:43
@sjames1958gm but it is not just reversing though. You have to make allowances for non alphanumeric characters
Stephen James
@sjames1958gm
May 27 2017 01:44
@kodinglife Sure, but get the basic example working and then add the removal of non alphanumerics
Don't get bogged down by trying to solve the whole thing at once.
Xarri Jorge
@xarrijorge
May 27 2017 01:45
@sjames1958gm Yeah, cuz the regex really had me for awhile on that one
Stephen James
@sjames1958gm
May 27 2017 01:45
@kodinglife :) yeah regex is not something that is easy to relate to real life
Xarri Jorge
@xarrijorge
May 27 2017 01:45
@sjames1958gm Yeah, REGEX is a bitch
Mithun reddy
@mithunreddyt
May 27 2017 01:45
@sjames1958gm Thank you james i will try to solve the problems and understand how they are working and If i get issue i will post here
CamperBot
@camperbot
May 27 2017 01:45
mithunreddyt sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7509 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Clare
@clareagarcia
May 27 2017 01:46
@sjames1958gm Yeah I see, thanks. I just need to slow down and take a break, been at it all day and getting frustrated ><
CamperBot
@camperbot
May 27 2017 01:46
clareagarcia sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7510 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 27 2017 01:46
@clareagarcia I have seen you online all day - making pretty good progress.
@mithunreddyt Often the later challenges will use early concepts.
Clare
@clareagarcia
May 27 2017 01:50
5 or 6 years ago I tried to learn programming and I remember making a similar person object with c++. But it was much easier to make it private. I think I just wrote the word private: lol @sjames1958gm
Stephen James
@sjames1958gm
May 27 2017 01:50
@clareagarcia Yes. Much more explicit
Clare
@clareagarcia
May 27 2017 01:51
Only wish I kept trying to learn programming I'd be much further, but now is as good a time to start again I suppose
May 27 2017 01:56
@clareagarcia - one thing that is good is that having some previous exposure should help you, you'll understand the concepts more readily, and pick up on the differences.
OlaNeat Ayoola
@olaneat
May 27 2017 02:06
sowie whats an identifier
Corri Taylor
@corritaylor
May 27 2017 02:12

Hello all, I’m stuck on the last part of this exercise and need a bit of help.

The following is my code…

``````function truncateString(str, num) {
// Clear out that junk in your trunk
if (str.length > num) {
str = str.replace(str.slice(num - 3),"...");
return str;
} else if (str.length <= 3) {
str = str.replace(str.slice(num),"...");
return str;
} else {
return str;
}

}

And my result so far is

I’m going to get use to typing in here one day lol
@ReactorboY
May 27 2017 02:14
``````
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
var string = str.substring(str.length -1, str.length);
// -- Falcor
if(string == target)
return true;
else
return false;
}

confirmEnding("Bastian", "n");``````
what I am doing wrong ?
Moisés Man
@moigithub
May 27 2017 02:16
confirmEnding("Bastian", "ian");
should return true @ReactorboY
@ReactorboY
May 27 2017 02:16
how I do that ?? @moigithub
code is working fine but some challenges condition is not full filling
Moisés Man
@moigithub
May 27 2017 02:17
on that example.. target parameter will be "ian"
soo what value will contain ur `string` variable on ur code??
Xarri Jorge
@xarrijorge
May 27 2017 02:18
@corritaylor what is the challenge instructions?
@ReactorboY
May 27 2017 02:18
@moigithub `n`
Moisés Man
@moigithub
May 27 2017 02:19
soo.. "n" == "ian" will return false..
`confirmEnding("Bastian", "ian");` making this fail
and should be true
Corri Taylor
@corritaylor
May 27 2017 02:19
@ReactorboY in your code you are calling for substring of `str.length` but not the `target.length` which in turn you’re looking at the specified string as a whole and not the target of the string you want to confirm

@kodinglife

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

@ReactorboY
May 27 2017 02:20
what should be my code then ?
Corri Taylor
@corritaylor
May 27 2017 02:22
`var string = str.substr(-target.length) === target;` Negative target because you are specifically tageting the end of the string.
Corri Taylor
@corritaylor
May 27 2017 02:29

@ReactorboY A key to remember is that `.substr` includes the start of a string and the length of it `str.substr(start, length)`

where as `.substring` includes the start of an index to the end of the index
`str.substring(indexStart, indexEnd)`

Thomas Lawless
@tlawless94
May 27 2017 02:31
so I'm doing the problem where you're supposed to convert a string of binary values to a string of ascii characters. This is the code I have, I think the function to convert the binary to base ten isn't working, any pointers?
``````function binaryAgent(str) {

var binaryArr = str.split(" ");
var newArr = [];

function binaryConversion(binary){
var baseTen = 0;
for (var i = 0; i < binary.length; i++){
if (binary[i] == 1){
baseTen += Math.pow(2, i);
}
}
console.log(baseTen);
return baseTen;
}

for (var i = 0; i < binaryArr.lenght; i++){
newArr.push(String.fromCharCode(binaryConversion(binaryArr[i])));
}

return newArr.join(" ");
}``````
Joseph
@revisualize
May 27 2017 02:32
hmmm.
jrvscm
@jrvscm
May 27 2017 02:32
hey everyone, been at this sub array question for awhile now and need a little help. After i write my loops, i dont know how to return the biggest number from [j]. I think i am close but it returns 4 in each sub array because it sees 4 iterations in each sub array i think. if i'm wrong please inform me. or am i going about this wrong?
Joseph
@revisualize
May 27 2017 02:33
@tlawless94 Have you heard of `parseInt`?
Thomas Lawless
@tlawless94
May 27 2017 02:33
no, I'll look it up. do you think passing a string value to the binary conversion function is causing a problem?
Joseph
@revisualize
May 27 2017 02:33
@jrvscm You need to reset or `biggestNum` before each sub array run.
@jrvscm You just compare the biggestNum with the current sub array element.
@jrvscm Oh, I see. You're actually missing a varaible.
jrvscm
@jrvscm
May 27 2017 02:35
compare it in an if statement>
?
Joseph
@revisualize
May 27 2017 02:35
@jrvscm How do you write an if statement?
Thomas Lawless
@tlawless94
May 27 2017 02:35
thanks @revisualize
CamperBot
@camperbot
May 27 2017 02:35
tlawless94 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4021 | @revisualize |http://www.freecodecamp.com/revisualize
jrvscm
@jrvscm
May 27 2017 02:35
if (x < i)
return x
no?
Joseph
@revisualize
May 27 2017 02:36
@jrvscm what is `(x < i)` doing?
jrvscm
@jrvscm
May 27 2017 02:36
seeing if the value in x is less than i?
Joseph
@revisualize
May 27 2017 02:36
Comparison
jrvscm
@jrvscm
May 27 2017 02:36
comparing
Joseph
@revisualize
May 27 2017 02:36
Great.
Moisés Man
@moigithub
May 27 2017 02:36
@tlawless94
``````function binaryConversion(binary){
var bin=binary.split("").reverse().join("");
var baseTen = 0;
for (var i = 0; i < binary.length; i++){
if (bin[i] == 1){
baseTen += Math.pow(2, i);
}
}
console.log(baseTen);
return baseTen;
}``````
Joseph
@revisualize
May 27 2017 02:37
@revisualize You need a new variable.
jrvscm
@jrvscm
May 27 2017 02:37
i think i know what your saying
im going to give it some more thought i think i'm on the right track.
Joseph
@revisualize
May 27 2017 02:37
@jrvscm Also, by doing `biggestNum = 0;` You're going to have a problem. You're setting `biggestNum` to the value of a number.
jrvscm
@jrvscm
May 27 2017 02:37
thank you
Joseph
@revisualize
May 27 2017 02:37
@jrvscm You can't `.push()` to a number.
jrvscm
@jrvscm
May 27 2017 02:37
yes i meant to change it back to [0]
i was playing around trying to get it to work
Joseph
@revisualize
May 27 2017 02:38
@jrvscm What happens if you have `myArr = [0];` and then you `myArr.push(2);` ?? What's the value of `myArr` after the `.push()`
Xarri Jorge
@xarrijorge
May 27 2017 02:39
@revisualize [0,2]
jrvscm
@jrvscm
May 27 2017 02:39
right
i can get the push to the array
Joseph
@revisualize
May 27 2017 02:39
@kodinglife I was asking @jrvscm ... But...
Thanks.
Thomas Lawless
@tlawless94
May 27 2017 02:39
thanks @moigithub I also had a spelling error
CamperBot
@camperbot
May 27 2017 02:39
tlawless94 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3265 | @moigithub |http://www.freecodecamp.com/moigithub
Thomas Lawless
@tlawless94
May 27 2017 02:40
I guess my array was the wrong way too haha
Xarri Jorge
@xarrijorge
May 27 2017 02:40
@revisualize yw
jrvscm
@jrvscm
May 27 2017 02:40
are you saying i should create a new variable, biggest = 0 then compare the sub arrays before i push?
compare them to biggest = 0
Corri Taylor
@corritaylor
May 27 2017 02:41
ahhh i see the error I made, i got it
Joseph
@revisualize
May 27 2017 02:41
@jrvscm Think about this... What would you do if you just had a normal array `var myArr = [2,8,4,6];` and you had to return the largest number from the Array?
jrvscm
@jrvscm
May 27 2017 02:42
biggest = 0
whoops
Joy Bhalla
@JoyBhalla
May 27 2017 02:43
help guys i'm zoning out can you help me with the word banks assignment
Joseph
@revisualize
May 27 2017 02:43
@JoyBhalla What have you written?
Joy Bhalla
@JoyBhalla
May 27 2017 02:46
i haven't done antything, i don't know what string to write as it's been a busy couple of days and i can't remember anything
Joseph
@revisualize
May 27 2017 02:46

The function declaration was set up as... `function wordBlanks(myNoun, myAdjective, myVerb, myAdverb)` giving the function name as `wordBlanks` and with four parameter of `myNoun`, `myAdjective`, `myVerb` and `myAdverb`.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

``````function hello(fName, uName) {
var result;
result = "Hello " + fName + " " + uName + ", How is your day?";
return result;
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"``````

You can use the `fName` and `uName` parameters just like a variable inside of your function.
Now this example only uses two parameters `fName` and `uName`. Whereas, `wordBlanks` has four parameters.

When you have the function declaration of:

``function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { }``

and you make the function call of:
`wordBlanks("dog", "big", "ran", "quickly");`
The parameter `myNoun` gets the first argument from the function call of a string `"dog"`
The parameter `myAdjective` gets the second argument from the function call of a string `"big"`
The parameter `myVerb` gets the third argument from the function call of a string `"ran"`
The parameter `myAdverb` gets the second argument from the function call of a string `"quickly"`

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

So, you need to use the parameters to create a string and assign that string value to the variable `result`. (String Concatenation)

@JoyBhalla --^^
Joy Bhalla
@JoyBhalla
May 27 2017 02:48
@revisualize thank you !
CamperBot
@camperbot
May 27 2017 02:48
joybhalla sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4022 | @revisualize |http://www.freecodecamp.com/revisualize
Dovydas Stirpeika
@Giveback007
May 27 2017 02:50
hey there peeps
Cascarr Alejandro Ihesie
@cascarr
May 27 2017 02:57
This abstract.. but then, just see it as you are saving a life...
Who has ever gotten tired of life pursuit?
tommy
@tommygebru
May 27 2017 02:58
I believe the answer to this challenge is basically "concatenation"

my solution is

``       .text((d) => d[0] + ", " + d[1]);``

Im confused do I have the wrong answer or do i not understand the instructions...?

Nick Gray
@nicholasnbg
May 27 2017 02:59
everyone gets burnt out sometimes @cascarr
Dovydas Stirpeika
@Giveback007
May 27 2017 03:04
hey could you guys test my unbeatable tic tac toe?
https://codepen.io/giveback007/full/YVRONB/
Anthony Contreras
@AmazeCPK
May 27 2017 03:15
@Giveback007 I won: http://prntscr.com/fcl94c
wait.. I just realized the game beat me.
lol I feel dumb.
Dovydas Stirpeika
@Giveback007
May 27 2017 03:18
lol
@AmazeCPK tnx for trying :)
CamperBot
@camperbot
May 27 2017 03:18
giveback007 sends brownie points to @amazecpk :sparkles: :thumbsup: :sparkles:
Dovydas Stirpeika
@Giveback007
May 27 2017 03:20
anyone else wana try the unbeatable ai?
haris8
@haris8
May 27 2017 03:22
Hello, could anyone help me with Profile Lookup challenge?
Joseph
@revisualize
May 27 2017 03:22
@haris8 What is the state of your function? (not the large array of object ... please just post the function)
haris8
@haris8
May 27 2017 03:23

function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while (contacts[i].hasOwnProperty(firstName) === false) {
i++;
}

``````if ((contacts[i].hasOwnProperty(firstName) === true) &&                    (contacts[i].hasOwnProperty(prop) === true)) {
return contacts[i].prop;
}

else if (contacts[i].hasOwnProperty(firstName) === false) {
return "No such contact";
}

else {
return "No such property";
}``````

// Only change code above this line
}

Joseph
@revisualize
May 27 2017 03:23
@haris8 This: `(contacts[i].hasOwnProperty(firstName) === true)` Will never be `true`
@haris8 `(contacts[i].hasOwnProperty(firstName) === false)` will always be `true`
yjaved01
@yjaved01
May 27 2017 03:24

Hello! I'm trying to figure out this exercise "Nesting for Loops"m where I'm supposed to modify function "multiplyAll" so that it multiplies the "product" variable by each number in the subarrays of "arr". So far, I can multiply the first subarray, but cannot multiply subsequent arrays.

'''
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];}

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

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);
'''

Joseph
@revisualize
May 27 2017 03:24
@yjaved01 What is the purpose of `j`?
Frank Amor
@famor3
May 27 2017 03:24
Hi there. I had a question about Stand in Line challenge. Could someone help?
Joseph
@revisualize
May 27 2017 03:25
yjaved01
@yjaved01
May 27 2017 03:26
@revisualize my goal with was to iterate through an array within the array
Joseph
@revisualize
May 27 2017 03:26
@yjaved01 Okay.
@yjaved01 if you have `var arr = [[1],[2],[3]];`
@abohannon
May 27 2017 03:26
Hey all - new here. Can someone explain to me where val is defined in this? I had a hell of a time with this one.
``````// 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[val];

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

// Change this value to test
phoneticLookup("charlie");``````
Joseph
@revisualize
May 27 2017 03:26
@yjaved01 What is `arr[0]`?\
Frank Amor
@famor3
May 27 2017 03:26
@revisualize If I am understanding the challenge correctly, we should use the array commands to remove the old items from the front of the queue and then add to the end of the array, correct? Or am I way out in left field?
Joseph
@revisualize
May 27 2017 03:27
@famor3 You need to reevaluate your order of operations.
@abohannon `val` is the parameter
@abohannon Can I give you a side example that talks about parameters?
jrvscm
@jrvscm
May 27 2017 03:28
@revisualize hey thanks man i finally understood what you were saying about comparing it to zero, and moving the lowest number into the variable. really made me understand how the loops were working together, thank you.
CamperBot
@camperbot
May 27 2017 03:28
jrvscm sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4023 | @revisualize |http://www.freecodecamp.com/revisualize
@abohannon
May 27 2017 03:28
absolutely, thank you @revisualize
yjaved01
@yjaved01
May 27 2017 03:28
@revisualize 1
Frank Amor
@famor3
May 27 2017 03:28
@revisualize Would you mind elaborating please?
Joseph
@revisualize
May 27 2017 03:29
@famor3 Write a function nextInLine which takes an array (arr) and a number (item) as arguments.
Add the number to the end of the array,
then remove the first element of array.
The nextInLine function should then return the element that was removed.

@famor3 You write:

we should use the array commands to remove the old items from the front of the queue and then add to the end of the array,

The order of the operations that you stated are not in order with the challenge instructions.

@yjaved01 Incorrect.

@abohannon If I have this code:

``````function addThree (num) {
var result;
result = num + 3;
return result;
}``````

So, when we make the function call of:

``addThree(10);``

You're calling the function `addThree` You're also passing a value `10` as an argument.
In the function declaration of `function addThree (num) {` You see that there is a parameter defined of `num`
When we do `addThree(10)` then the value of the parameter `num` is passed the argument value of ... `10`
Then if you follow the code through.. `result = num + 3;` ... and we know the value of `num` is `10`.
Therefore, if we follow through the function we end up with ... `result = 10 + 3;` then `result = 13;` then we return the `result`.

....
@yjaved01 if you have `var arr = [[1],[2],[3]];` and you access `arr[0]` it is the value `[1]` (an array with a single element `1`)
....
@abohannon So to add to that...
If you make the function call of `addThree(21)` the value of `num` inside the function is 21.
If you make the function call of `addThree(1000)` the value of `num` inside the function is 1000.
If you make the function call of `addThree(123456)` the value of `num` inside the function is 123456.
....
@yjaved01 If you have `var arr = [[1],[2],[3]];` how do you access the value `1`?
AnthonyShot
@AnthonyShot
May 27 2017 03:33

function runSlots() {
var slotOne;
var slotTwo;
var slotThree;

``````var images = ["//i.imgur.com/9H17QFk.png", "//i.imgur.com/9RmpXTy.png", "//i.imgur.com/VJnmtt5.png"];

slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;

// Only change code below this line.
\$(\$(".slot")[0].html(slotOne));
\$(\$(".slot")[1].html(slotTwo));
\$(\$(".slot")[2].html(slotThree));
// Only change code above this line.

if (slotOne === slotTwo && slotTwo === slotThree) {
\$(".logger").html(" It's A Win")
return null;
}

if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){
\$(".logger").html(slotOne + " " + slotTwo + " " + slotThree);
}

\$(".logger").append(" Not A Win");

return [slotOne, slotTwo, slotThree];``````

}

\$(\$(".slot")[0]).html(slotOne);

jQuery将会获取到第一个老虎机，并更新它的HTML为正确的数字。

what's wrong with my program
Frank Amor
@famor3
May 27 2017 03:34
@revisualize Okay. I understand what you are referring to. But what about the other part of my question? Do I use array functions to add/remove within my nextInLine function?
@abohannon
May 27 2017 03:35
@revisualize that example is simple enough for me to understand since I can see the role of "num" in the function. I'm having difficulty interpreting the other example because "val" only appears as an argument for phoneticLookup and nowhere else. In objects, is "val" automatically connected to the key? (I hope this makes sense. I'm probably not using the vocabulary correctly!)
Joseph
@revisualize
May 27 2017 03:35
@famor3 You use array methods. Yes.
yjaved01
@yjaved01
May 27 2017 03:35
@revisualize k I get that.
Frank Amor
@famor3
May 27 2017 03:35
@revisualize Thanks man, I'm on the right path.
CamperBot
@camperbot
May 27 2017 03:35
famor3 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4024 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 27 2017 03:36

@abohannon The function declaration was set up as... `function phoneticLookup(val)` giving the function name as `phoneticLookup` and with the parameter of `val`. There is more that I could go into (if you want I can) but, I'll sum it up with: Parameters are variable-like objects that represent the values that get passed into your function from the function call (arguments). (You basically treat them like variables.)
So, as we learned in: Accessing Objects Properties with Variables you have to use bracket notation to access an object property with a variable. Example: `var num = 42;` `myObj[num];`

How do you modify the variable `result`? (Simple answer)
How do you access an object property value?
What if you need to access the object property value with a variable?
You need to re-assign the variable `result` the the object property value of the object that you created `lookup`. (As per the instructions)
With this code: `function phoneticLookup(val) { }` you have a function declaration with a function name of `phoneticLookup` and a parameter `val`.
When you make the function call: `phoneticLookup("charlie");` You are calling the function by name and passing the argument of `"charlie"` to the function parameter of `val` as a value.
You'll need to use bracket notation to access your object (`lookup`) property value. Note: Parameters are used inside of your function just like variables.
You need to assign the value of the object property to the variable `result`.
Then when your function `phoneticLookup` returns `result` it will return the correct object property value.

So, when you do `lookup[val];` you're accessing the `lookup` with the parameter `val` that has a value of `"charlie"` and to get the object property value of `"Chicago"`.
With `result = lookup[val];` You're assigning that object property value to the variable `result`. Then you're returning `result`.

@abohannon It's the same principle as the example that I gave you.
Jor
@joreyesl
May 27 2017 03:37
@tommygebru thats right, but dont forget the x and y attr also
tommy
@tommygebru
May 27 2017 03:37
CamperBot
@camperbot
May 27 2017 03:37
tommygebru sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
tommy
@tommygebru
May 27 2017 03:37
how do you mean though...
Joseph
@revisualize
May 27 2017 03:38

@abohannon With the function declaration of: `function phoneticLookup(val) { }`
When you make the function call:
`phoneticLookup("charlie");`
The parameter `val` gets the value of the argument passed `"charlie"`

When you make the function call:
`phoneticLookup("doug");`
The parameter `val` gets the value of the argument passed `"doug"`

When you make the function call:
`phoneticLookup("Happy Feet");`
The parameter `val` gets the value of the argument passed `"Happy Feet"`

tommy
@tommygebru
May 27 2017 03:38
@joreyesl for my solution I believe its just a string, not a point to position
Joseph
@revisualize
May 27 2017 03:39
@yjaved01 If you have `var arr = [[1],[2],[3]];` how do you access the value `1`?
PhoenixFarhan
@PhoenixFarhan
May 27 2017 03:39
``````
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {

if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];

}
}
for (var j = 0; j< contacts.length; j++)

if (contacts[j].firstName !== firstName) {
return "No such contact";
}
else if (contacts[j].hasOwnProperty(prop) !== true){
return "No such property";
}
}``````
So this code works for the challenge but I feel that I shouldnt have to have the contacts[j] for loop but i cannot seem to integrate into the contacts[i] loop
any ideas?
Jor
@joreyesl
May 27 2017 03:39
@tommygebru you see how they have `cx` and `cy` attr on the circle? that tells it where on the canvas to draw the circle. Same with your text, you need `x` and `y` attr so it can display the label in the right location.
Joseph
@revisualize
May 27 2017 03:40
@PhoenixFarhan You don't need the second for loop.
yjaved01
@yjaved01
May 27 2017 03:40
@revisualize arr[0][0]
oh!
Joseph
@revisualize
May 27 2017 03:40
@yjaved01 And what's the purpose of `j`? :D
PhoenixFarhan
@PhoenixFarhan
May 27 2017 03:41
``````function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {

if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}
else if (contacts[j].firstName !== firstName) {
return "No such contact";
}
else if (contacts[j].hasOwnProperty(prop) !== true){
return "No such property";

}
}

}``````
this one ^^ fails when i try to have only one loop
Joseph
@revisualize
May 27 2017 03:41
@PhoenixFarhan That one does fail.
@PhoenixFarhan Let me show you an example set of code?
@abohannon
May 27 2017 03:42
@revisualize thank you for taking the time to explain that. It makes more sense now! I wasn't looking hard enough at phoneticLookup("charlie");
CamperBot
@camperbot
May 27 2017 03:42
abohannon sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4025 | @revisualize |http://www.freecodecamp.com/revisualize
yjaved01
@yjaved01
May 27 2017 03:42
@revisualize ah! to get access to the actual value. that would mean if I just do this "product *= arr[i][j];"
Joseph
@revisualize
May 27 2017 03:42
@yjaved01 Did it work?
tommy
@tommygebru
May 27 2017 03:42
@joreyesl wow you are right I really overlooked that!
Dovydas Stirpeika
@Giveback007
May 27 2017 03:42
has anyone done the min max algorithm for the tic tac toe game? I need some help
yjaved01
@yjaved01
May 27 2017 03:42
@revisualize I should be able to evaluate... yep it worked!
@revisualize Thanks so much!
CamperBot
@camperbot
May 27 2017 03:42
yjaved01 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4026 | @revisualize |http://www.freecodecamp.com/revisualize
PhoenixFarhan
@PhoenixFarhan
May 27 2017 03:43
@revisualize that would be nice
yjaved01
@yjaved01
May 27 2017 03:43
@revisualize I've been racking my head around this for hours!
Joseph
@revisualize
May 27 2017 03:44

@PhoenixFarhan Let's say we have some code. Where where trying to look for a value in an array.

``````var val = "e"
var arr = ["a", "b", "c", "d", "e"];
for (var i = 0; i < arr.length; i++) {
if (val === arr[i]) { return "True"; }
else if (val !== arr[i]) { return "False" }
}``````

What is the value of `val`?
What is the value of `arr[0]`?
How is the first `if` condition evaluated?
How is the `else if` condition evaluated?

yjaved01
@yjaved01
May 27 2017 03:45
@revisualize I can't thank you enough. I'm going to call it a day! :)
CamperBot
@camperbot
May 27 2017 03:45
yjaved01 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: yjaved01 already gave revisualize points
LeSean Johnson
@leseanbiz
May 27 2017 03:45
can someone help me out for a minute? ive got a few issues with the current site
haris8
@haris8
May 27 2017 03:46
@haris8 This: `(contacts[i].hasOwnProperty(firstName) === true)` Will never be `true`
@revisualize, what do you recommend I do?
PhoenixFarhan
@PhoenixFarhan
May 27 2017 03:47
@revisualize first if takes the var arr array, the i being used in the iterative loop and the else if takes a negation under the same type of lofic and returns false
LeSean Johnson
@leseanbiz
May 27 2017 03:47
im trying to use object destructuring to get the few variables i need stowed away quickly, and it worked before, but now it doesnt seem to….
tommy
@tommygebru
May 27 2017 03:47
@joreyesl so I changed it to include the positions of the actual points so visually it lines up really well
however
I was not able to pass the challenge
Joseph
@revisualize
May 27 2017 03:47
@PhoenixFarhan I'm not following what you said. Could you please clarify?
tommy
@tommygebru
May 27 2017 03:47
it may have to do with my last line
Jor
@joreyesl
May 27 2017 03:48
@tommygebru They want you to use the same value as `cy` for `y`, but for `x` they want you to add `+5` to it.
PhoenixFarhan
@PhoenixFarhan
May 27 2017 03:48
What is the value of val?
What is the value of arr[0]?
How is the first if condition evaluated?
How is the else if condition evaluated?
tommy
@tommygebru
May 27 2017 03:49
@joreyesl right... does my solution not do that?
PhoenixFarhan
@PhoenixFarhan
May 27 2017 03:49
What is the value of val?
e
What is the value of arr[0]?
a
How is the first if condition evaluated?
and the first one uses an iterative approach.. equal to condition
How is the else if condition evaluated?
as does the second one.. not equal to condition
Cynthia Clinton
@Cynth42
May 27 2017 03:49
My code is not working - i'm getting two errors:
Jor
@joreyesl
May 27 2017 03:49
@tommygebru idk, I havent seen your updated solution
tommy
@tommygebru
May 27 2017 03:50
@joreyesl nevermind I was gonna send you a screenshot when I understood what you meant
Dovydas Stirpeika
@Giveback007
May 27 2017 03:50
I still can't figure out why the algorithm is assigning unequal values to parts parts that should be equal value
tommy
@tommygebru
May 27 2017 03:50
so basically I was trying to change the value of the string of the coordinate
but really i just needed to change the coordinate (+5)
@joreyesl thanks
Mukul Agrawal
@mukul09
May 27 2017 03:50
@Cynth42 what are the error?
Joseph
@revisualize
May 27 2017 03:50
@PhoenixFarhan `and the first one uses an iterative approach`
... That is a complicated answer. I just want `("e" == "a")`
Cynthia Clinton
@Cynth42
May 27 2017 03:50

here is my code:function golfScore(par, strokes) {
// Only change code below this line

if (strokes == 1){

``return "Hole-in-one!";``

}
else if(strokes <= (par-2)) {
return "Eagle";
}

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

else if(strokes == (par + 2)) {
return "Double Bogey";
}
else {
return "Go Home";
}

}

// Change these values to test
golfScore(5, 4);

errors: golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"
Jor
@joreyesl
May 27 2017 03:51
@tommygebru yea you keep the string the same, its just the x coordinate that needs to be changed.
Joseph
@revisualize
May 27 2017 03:51
@PhoenixFarhan
What is the value of val? `"e"`
What is the value of arr[0]? `"a"`
How is the first if condition evaluated? `("e" === "a")` false
How is the else if condition evaluated? `("e" !== "a")` true
@PhoenixFarhan I have no idea what you mean by:
and the first one uses an iterative approach.. equal to condition
nor do I understand:
as does the second one.. not equal to condition
@PhoenixFarhan once the if condition is evaluated to `true` the if statement is triggered.
PhoenixFarhan
@PhoenixFarhan
May 27 2017 03:54
@revisualize Thanks for trying; i must be just overly tired right now. Will pick it up tomorrow
CamperBot
@camperbot
May 27 2017 03:54
phoenixfarhan sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4027 | @revisualize |http://www.freecodecamp.com/revisualize
tommy
@tommygebru
May 27 2017 03:54
@joreyesl yeah I was able to pass the string is the same its the coordinates that need to change... let me review the instructions tho.. thats probably what messed me up LOL
Mukul Agrawal
@mukul09
May 27 2017 03:54
@Cynth42 what's the name of the challenge?
Joseph
@revisualize
May 27 2017 03:54
@PhoenixFarhan
``````var value = "e"
var arr = ["a", "b", "c", "d", "e"];
for (var i = 0; i < arr.length; i++) {
if (value === arr[i]) { return "True"; }
}
return "False";``````
tommy
@tommygebru
May 27 2017 03:56
@joreyesl nevermind the instructions look fine I guess, but for my desktop layout the lesson is not really readable ... here
:laughing: all that negative space amiright?
Joseph
@revisualize
May 27 2017 03:57
are people seriously trying to get help with the Beta?
Jor
@joreyesl
May 27 2017 03:58
@tommygebru ah i see the problem. Its the x attr that you need to add `+5` to. The text should just be `d[0]`
Cynthia Clinton
@Cynth42
May 27 2017 03:58
can somebody help me out here?
tommy
@tommygebru
May 27 2017 03:59
@joreyesl no worries I already passed the challenge earlier this was the screenshot from before :thumbsup:
Jor
@joreyesl
May 27 2017 03:59
@tommygebru oh i see lol
np :thumbsup:
Dovydas Stirpeika
@Giveback007
May 27 2017 04:00
@tommygebru have you by any chance done the min max algo for tic tac toe?
tommy
@tommygebru
May 27 2017 04:01
no im taking a break from algorithims Im doing d3 and trying d3 projects, if it ends up being too much I will try to take a run at react instead
Dovydas Stirpeika
@Giveback007
May 27 2017 04:02
it's driving me crazy... no one so far that I talked to has finished it
LeSean Johnson
@leseanbiz
May 27 2017 04:02
20:47
im trying to use object destructuring to get the few variables i need stowed away quickly, and it worked before, but now it doesnt seem to….
tommy
@tommygebru
May 27 2017 04:02
@revisualize haha yes
LeSean Johnson
@leseanbiz
May 27 2017 04:02
tommy
@tommygebru
May 27 2017 04:02
@Giveback007 have you tried just googling for a solution, perhaps if it has been a long time you should try SO or something
Dovydas Stirpeika
@Giveback007
May 27 2017 04:03
my problem is too specific, I need eyes that have done it before to look at it
@tommygebru my tic tac toe is unbetable but...
Jor
@joreyesl
May 27 2017 04:04
@Giveback007 what is the problem?
Cynthia Clinton
@Cynth42
May 27 2017 04:04
Im getting two errors: golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!" My test is not passing
Dovydas Stirpeika
@Giveback007
May 27 2017 04:04
@joreyesl the scores for the moves that should have an equal value, do not have equal value
Mukul Agrawal
@mukul09
May 27 2017 04:04
@Cynth42 can u tell the name of the challenge?
Cynthia Clinton
@Cynth42
May 27 2017 04:04
golf code
Jor
@joreyesl
May 27 2017 04:05
@Giveback007 I can take a look
Dovydas Stirpeika
@Giveback007
May 27 2017 04:05
@joreyesl I want to randomize moves that are equal value, to make the game more interesting, but I can't do it when it outputs nonsense
May 27 2017 04:06
@Cynth42 - can you post your code?
Cynthia Clinton
@Cynth42
May 27 2017 04:06
sure

if (strokes == 1){

``return "Hole-in-one!";``

}
else if(strokes <= (par-2)) {
return "Eagle";
}

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

else if(strokes == (par + 2)) {
return "Double Bogey";
}
else {
return "Go Home";
}

}

// Change these values to test
golfScore(5, 4);

Mukul Agrawal
@mukul09
May 27 2017 04:07
@Cynth42 you did not add >= par + 3 condition in your code
OuRyoShin
@DJQTDJ
May 27 2017 04:07
hi everyone,next week i will go to the los.
but I don;t know the price level in los
is it higher?
May 27 2017 04:07
@Cynth42 - you might just be missing the exclamation point on your "Go Home!" ??
tommy
@tommygebru
May 27 2017 04:08
@Cynth42 does this challenge require the if/else structure?
Cynthia Clinton
@Cynth42
May 27 2017 04:08
yes it does
Mukul Agrawal
@mukul09
May 27 2017 04:08
@Cynth42 it should be added at last
``````else if(strokes>=par+3)
return "Go Home!";``````
OuRyoShin
@DJQTDJ
May 27 2017 04:08

hi guys,next week i will go to the los.
but I don;t know the price level in los
is it higher?

by the way what 's the average wage in US

tommy
@tommygebru
May 27 2017 04:08
ok i think it changes to switch statements next :smile:
May 27 2017 04:09
@Cynth42 - I think you just need the `!` ?
Cynthia Clinton
@Cynth42
May 27 2017 04:10
CamperBot
@camperbot
May 27 2017 04:10
cynth42 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
May 27 2017 04:10
@Cynth42 - you're welcome! Good luck with future challenges...
tommy
@tommygebru
May 27 2017 04:10
OuRyoShin
@DJQTDJ
May 27 2017 04:12
@tommygebru thanks
CamperBot
@camperbot
May 27 2017 04:12
djqtdj sends brownie points to @tommygebru :sparkles: :thumbsup: :sparkles:
Alexey Yarushin
@ayarushin
May 27 2017 04:15
hi all :smile:
Dovydas Stirpeika
@Giveback007
May 27 2017 04:16
@joreyesl i just defeated my AI, and I can't figure out why. Start with move b -> i -> c -> a.
OuRyoShin
@DJQTDJ
May 27 2017 04:19
but There are seismic gaps in US between rich and poor
So....
I want to know the least of the internet engineer 's average wage in US
I means the lower to higher
Dovydas Stirpeika
@Giveback007
May 27 2017 04:20
@DJQTDJ i tend to gnaw on my shoes when I'm hungry because of the gap
OuRyoShin
@DJQTDJ
May 27 2017 04:25
This message was deleted
:smile:
HITESH MITTAL
@mittalhitesh1998
May 27 2017 04:42
Do not change code below the line.

// Initialize these three variables
var a = 5;
var b = 10;
var c = "I am a ";

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + "String!";

Markus Ivancsics
@ivancsicsmarkus
May 27 2017 04:43
@mittalhitesh1998 What does the exercise ask you to do?
HITESH MITTAL
@mittalhitesh1998
May 27 2017 04:47
@ivancsicsmarkus a should be defined and have a value of 6
b should be defined and have a value of 15
c should not contain undefined and should have a value of "I am a String!"
Do not change code below the line
only the last part not getting right.
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 04:49
``````var c="I am a";
…
c = c + " String!";``````
Jennifer Davis
@davijm
May 27 2017 04:52
Hello, instructions say: Remove all the backslashes () Then I get an error: Only remove the backslashes \ used to escape quotes
What am I supposed to do?
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 04:54
HITESH MITTAL
@mittalhitesh1998
May 27 2017 04:55
@ivancsicsmarkus thanks it worked!!
CamperBot
@camperbot
May 27 2017 04:55
mittalhitesh1998 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
Jennifer Davis
@davijm
May 27 2017 04:55
@ivancsicsmarkus var myStr = '<a href= "http://www.example.com " target= "_blank ">Link</a>';
Mario A. Carlos
@MarioC3
May 27 2017 04:55
So I just barely finished the algorithms and JSON APIs and AJAX sections.
The basic*
Algorithms
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 04:55
@davijm What is the exercise name?
Jennifer Davis
@davijm
May 27 2017 04:56
@ivancsicsmarkus Quoting Strings with Single Quotes
ArchivalBoat50
@ArchivalBoat50
May 27 2017 04:56
https://codepen.io/ArchivalBoat50/pen/mmggym
Could anyone explain why my clock isn't showing up in my div?
Mario A. Carlos
@MarioC3
May 27 2017 04:56
The basic Algorithms was challenging, but the JSON APIs and AJAX sections didn't really make sense.
Did someone experience the same?
Aizaz Shahid
@aizazshahid
May 27 2017 04:57
@MarioC3 Why don't you try some tutorials on that ?
Mario A. Carlos
@MarioC3
May 27 2017 04:57
I will!!
Aizaz Shahid
@aizazshahid
May 27 2017 04:57
@MarioC3 for basic understanding try out w3schools
Mario A. Carlos
@MarioC3
May 27 2017 04:58
I understand that Freecodecamp doesn't really hold your hand.... but damn... it was kinda heartbreaking, after triumphing over the basic algorithms to come and have your understanding crushed.... hahahha
Aizaz Shahid
@aizazshahid
May 27 2017 04:58
@davijm just remove those backslashes that are written with quotes as `\"`
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 04:58
@davijm You just added some unnecessary spaces:
``var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';``
Aizaz Shahid
@aizazshahid
May 27 2017 04:59
@MarioC3 indeed, you need to learn from external sources.
Mario A. Carlos
@MarioC3
May 27 2017 04:59
Of course!
Aizaz Shahid
@aizazshahid
May 27 2017 04:59
@davijm also you need a backslash sorry slash after `.com/`
Mario A. Carlos
@MarioC3
May 27 2017 04:59
@forwebtech (?)
Aizaz Shahid
@aizazshahid
May 27 2017 04:59
yes ?
Mario A. Carlos
@MarioC3
May 27 2017 05:00
@MarioC3 also you need a backslash sorry slash after `.com/`(?)
Aizaz Shahid
@aizazshahid
May 27 2017 05:00
wrong type !
Jennifer Davis
@davijm
May 27 2017 05:00
@ivancsicsmarkus it worked, thank you!
CamperBot
@camperbot
May 27 2017 05:00
davijm sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 05:00
This message was deleted
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 05:00
@davijm Always remember to check the string for extra spaces!
Aizaz Shahid
@aizazshahid
May 27 2017 05:01
@MarioC3 i think there should be some pre-request tutorials on (HTML, CSS, ...) to start at FCC ?
Jennifer Davis
@davijm
May 27 2017 05:01
@ivancsicsmarkus will do, thanks!
CamperBot
@camperbot
May 27 2017 05:01
davijm sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:warning: davijm already gave ivancsicsmarkus points
Aizaz Shahid
@aizazshahid
May 27 2017 05:03
because that place will be a sharpening tool for those who have already some knowledge in web development.
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 05:05
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:05
https://codepen.io/ArchivalBoat50/pen/mmggym
Could anyone explain why my clock isn't going inside the div? Or to put into words, why isn't my clock appearing?
Jopee
@jopeemahmen
May 27 2017 05:05
Hi Everyone, any hint on the golfcode challenge?
dinosaurjude
@dinosaurjude
May 27 2017 05:05
```
Aizaz Shahid
@aizazshahid
May 27 2017 05:05
thanks but i am just telling @MarioC3 from my experience
CamperBot
@camperbot
May 27 2017 05:05
forwebtech sends brownie points to @marioc3 :sparkles: :thumbsup: :sparkles:
Jopee
@jopeemahmen
May 27 2017 05:05

function golfScore(par, strokes) {
// Only change code below this line

if (par,strokes==1) {
return "Hole-in-one!";
}

else if (par >= -2, strokes) {
return "Eagle";
}

``return "Change Me";``

// Only change code above this line
}

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

Aizaz Shahid
@aizazshahid
May 27 2017 05:05
@ivancsicsmarkus thanks :+1:
CamperBot
@camperbot
May 27 2017 05:05
forwebtech sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 05:06

@jopeemahmen

```
```

More details..

:bulb: To get more commands:
`ctrl + shift + m`

Ty Tia
@TyTia77
May 27 2017 05:06
@ArchivalBoat50 i believe you dont need a body tag
Aizaz Shahid
@aizazshahid
May 27 2017 05:06
@jopeemahmen there are several conditions to check, look at the instructions, they are given there.
@jopeemahmen and also `if` statement don't allow `,` comma.
@jopeemahmen If ... else
Ty Tia
@TyTia77
May 27 2017 05:07
@ArchivalBoat50 call the function in the javascript file. also your function is written to accept a date, but you're not passing any date
dinosaurjude
@dinosaurjude
May 27 2017 05:07
how do i get it to tweet the actual quote and author when opening the tweet?
``````\$(document).ready(function(){
getQuote();
function getQuote(){

var url= "https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?";
\$.getJSON(url, function(data){
\$(".quote").html('"'+data.quoteText+'"');
\$(".author").html("-"+data.quoteAuthor);
});
};

\$("#tweetOut").on("click", function(){
});

\$("#newQuote").on("click", function(){
getQuote();
});
});``````
its for random quote maching
Alex
@alextran1502
May 27 2017 05:09
Hello, does anyone know why this function return [null,null,null,null,null]?
``````function titleCase(str) {
var basicStr = str.toLowerCase().split(' ');
return basicStr.map(function(value){
value.replace(value[0], value[0].toUpperCase());
});
}

titleCase("I'm a little tea pot");``````
Aizaz Shahid
@aizazshahid
May 27 2017 05:10
@alextran1502 well try to console your `value` in your `map` function and check do you getting values ? `console.log(value);`
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:10
@TyTia77 What do you mean by, "written to accept a date but not pass any date?"
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 05:11
@alextran1502 `.map` has to `return` the new value of each value. You are just replacing it.
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:11
@TyTia77 Do I return?
Ty Tia
@TyTia77
May 27 2017 05:11
@ArchivalBoat50 eg function(date <--- this)
you are passing a date object to the function
Alex
@alextran1502
May 27 2017 05:12
@ivancsicsmarkus so I need to return within the function, right?
Ty Tia
@TyTia77
May 27 2017 05:12

you could do something like
var date = new Date();

AMPM(date) etc etc

cos your function depends on the date object it seems
Aizaz Shahid
@aizazshahid
May 27 2017 05:13
@alextran1502 yes ! by default functions return `undefined` until you will not return anything explicitly.
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 05:13
@alextran1502 Yes.
@alextran1502 If you would like to change all the array items to 1. You would just do (inside your map):
``return 1;``
Alex
@alextran1502
May 27 2017 05:14

@ivancsicsmarkus

``````function titleCase(str) {
var basicStr = str.toLowerCase().split(' ');
basicStr.map(function(value){
return value.replace(value[0], value[0].toUpperCase());
});
}

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

with this fix, it still doesn't return anything, or undefined when i console.log(basicStr)

@forwebtech thanks!
CamperBot
@camperbot
May 27 2017 05:15
alextran1502 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 05:16
@alextran1502 where did you call that method ?
Alex
@alextran1502
May 27 2017 05:16
@forwebtech inside in map(function());
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:17
@TyTia77 https://codepen.io/ArchivalBoat50/pen/mmggym
Why is this working, but the last one not?
Aizaz Shahid
@aizazshahid
May 27 2017 05:17
@alextran1502 ok now you also have to return the basicStr after that function
Markus Ivancsics
@ivancsicsmarkus
May 27 2017 05:17
@alextran1502 I don’t know why. I did this:
``````function titleCase(str) {
var basicStr = str.toLowerCase().split(' ');
return basicStr.map(function(value){
var arr = value.split('');
arr[0] = arr[0].toUpperCase();
return arr.join('');
});
}

titleCase("I'm a little tea pot“);``````
Aizaz Shahid
@aizazshahid
May 27 2017 05:18
@ivancsicsmarkus don't join into the callback method you need to make a chain calling.
like ....
``````return str.map( .... {

return value....

}).join(" ");``````
Ty Tia
@TyTia77
May 27 2017 05:18
@ArchivalBoat50 look inside the function it has var date = new Date();
Alex
@alextran1502
May 27 2017 05:19
@ivancsicsmarkus @forwebtech I made another var and assign it to the .map(), then it works!
``````
function titleCase(str) {
var basicStr = str.toLowerCase().split(' ');
var newArray = basicStr.map(function(value){
return value.replace(value[0], value[0].toUpperCase());

});
console.log(newArray);
}

titleCase("I'm a little tea pot");``````
Aizaz Shahid
@aizazshahid
May 27 2017 05:19
@alextran1502 now you have to return that `newArray()` also
Ty Tia
@TyTia77
May 27 2017 05:19
@ArchivalBoat50 and the html body on load stuff is doing absolutely nothing
the function being called in the javascript file
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:20
@TyTia77 Oh I see, thx for you help
CamperBot
@camperbot
May 27 2017 05:20
archivalboat50 sends brownie points to @tytia77 :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 05:20
@alextran1502 because `titleCase()` method should return the modified string with title case.
Alex
@alextran1502
May 27 2017 05:20
@forwebtech I believe `return newArray.join(' ');` will complete the challenge
Aizaz Shahid
@aizazshahid
May 27 2017 05:20
@alextran1502 yes :+1:, i missed that part but you got it !
Alex
@alextran1502
May 27 2017 05:21
@forwebtech @ivancsicsmarkus thanks for your help!
CamperBot
@camperbot
May 27 2017 05:21
alextran1502 sends brownie points to @forwebtech and @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:warning: alextran1502 already gave forwebtech points
Ty Tia
@TyTia77
May 27 2017 05:22

@ArchivalBoat50
AMPM();

function AMPM() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12;
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
document.getElementById('txt').innerHTML = strTime;
}

chuck that in your js file
Jopee
@jopeemahmen
May 27 2017 05:23
@forwebtech thanks, kinda figured it out, but could not finish because I could not return "bogey" which includes a function of golfScore (par==4,strokes==5)
CamperBot
@camperbot
May 27 2017 05:23
jopeemahmen sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Jopee
@jopeemahmen
May 27 2017 05:23

function golfScore(par, strokes) {
// Only change code below this line

if (par==4, strokes==1) {
return "Hole-in-one!";
}

else if (par==4, strokes==2) {
return "Eagle";
}

else if (par==5, strokes==2) {
return "Eagle";

}

else if (par==4, strokes==3) {
return "Birdie";

}

else if (par==4, strokes==4) {
return "Par";

}

else if (par==5,strokes==5) {
return "Par";

}

else if (par==4,strokes==5) {
return "Bogey";

}

else if (par==4,strokes==6) {
return "Double Bogey";

}

else if (par==4, strokes==7) {
return "Go Home!";

}

else if (par==5,strokes==9) {
return "Go Home!";

}

``return "Bogey";``

// Only change code above this line
}

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

Aizaz Shahid
@aizazshahid
May 27 2017 05:24
@jopeemahmen
```
```
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:25
@TyTia77 Hmm, so why couldn't it just be function AMPM(date) instead of having to make date its own object?
Ty Tia
@TyTia77
May 27 2017 05:26
@ArchivalBoat50 sorry i dont understand your question
your function is written to accept a date object to use. but you are not providing any. so it wont do anything.
Aizaz Shahid
@aizazshahid
May 27 2017 05:27
@jopeemahmen what comma did in `if` ? actually i don't know ?
Ty Tia
@TyTia77
May 27 2017 05:27
and also you have many syntax errors
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:29
@TyTia77 No not object, sorry, i meant like:
var date = new Date();
Jopee
@jopeemahmen
May 27 2017 05:31
ArchivalBoat50
@ArchivalBoat50
May 27 2017 05:34
@TyTia77 oh i see
Jopee
@jopeemahmen
May 27 2017 05:35
``````
function golfScore(par, strokes) {
// Only change code below this line

if (par==4, strokes==1) {
return "Hole-in-one!";
}

else if (par==4, strokes==2) {
return "Eagle";
}

else if (par==5, strokes==2) {
return "Eagle";

}

else if (par==4, strokes==3) {
return "Birdie";

}

else if (par==4, strokes==4) {
return "Par";

}

else if (par==5,strokes==5) {
return "Par";

}

else if (par==4,strokes==6) {
return "Double Bogey";

}

else if (par==4, strokes==7) {
return "Go Home!";

}

else if (par==5,strokes==9) {
return "Go Home!";

}

else {
return "Bogey";

}

// Only change code above this line
}

// Change these values to test
golfScore(1,1);``````
@forwebtech thanks for the tip, been figuring that out a long time now haha
CamperBot
@camperbot
May 27 2017 05:36
:warning: jopeemahmen already gave forwebtech points
jopeemahmen sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 05:36
@jopeemahmen how comma `,` works in that statement `if (par==4, strokes==1) {`
abraham anak agung
May 27 2017 05:39
Hi guys, does anybody know why using`eval()` is harmful?
Jopee
@jopeemahmen
May 27 2017 05:41
@forwebtech it separates the conditions (par and strokes)
@jopeemahmen but how the `if` statement, reacts to comma, as && or || operators ??
Elijah White
@elijahwhite97
May 27 2017 05:42
i cri
Aizaz Shahid
@aizazshahid
May 27 2017 05:42
@padunk the other question is raised, why do you want to use eval() ?
Jopee
@jopeemahmen
May 27 2017 05:43
hmm I'll review. Thanks for not spoonfeeding me the answer. Appreciate it. @forwebtech
Aizaz Shahid
@aizazshahid
May 27 2017 05:43
:stuck_out_tongue: actually i also don't know about it
abraham anak agung
May 27 2017 05:43
Thank for the link @forwebtech i'm in calculator project and try to find a method that could add string
CamperBot
@camperbot
May 27 2017 05:43
padunk sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Jopee
@jopeemahmen
May 27 2017 05:44
hahaha really? Let's try to figure this out together @forwebtech
Aizaz Shahid
@aizazshahid
May 27 2017 05:44
when you will understand it, please let me know :)
abraham anak agung
May 27 2017 05:44
found this `eval` but when i try to use it in repl.it it said eval could be harmful
Aizaz Shahid
@aizazshahid
May 27 2017 05:44
CamperBot
@camperbot
May 27 2017 05:44
forwebtech sends brownie points to @jopeemahmen :sparkles: :thumbsup: :sparkles:
Jopee
@jopeemahmen
May 27 2017 05:44
Alright. I'll tag you :)
Aizaz Shahid
@aizazshahid
May 27 2017 05:45
@padunk can you give me the sample string which you want to add, and also mention the place where you want to ?
Jopee
@jopeemahmen
May 27 2017 05:45
@forwebtech what I know is that it seperates the par and the stroke conditions (parameters)
Aizaz Shahid
@aizazshahid
May 27 2017 05:46
ok now i have to do an experiment. :+1:
abraham anak agung
May 27 2017 05:47
@forwebtech it is just a simple calculation
``````var input = '22  + 43';
var result = eval(input);``````
Aizaz Shahid
@aizazshahid
May 27 2017 05:47
@padunk so actually you want to convert string to number ?
abraham anak agung
May 27 2017 05:48
no, i don't want to convert it that is why i find if there is a method to add string so i don't have to convert it to number
but i looks like i have to convert it to number
Aizaz Shahid
@aizazshahid
May 27 2017 05:49

@jopeemahmen

``````var a = 2,
b = 3;

(a === 2, b === 3) ? console.log(true) : console.log(false);       // true

console.log("=============");

(a === 2, b === 4) ? console.log(true) : console.log(false);     // false``````

well, `,` comma in `if` statement acts as an AND operator `&&` :)

@padunk ok, yes you have to convert it manually, but why don't you calculate it when user press equal to `=` ?
abraham anak agung
May 27 2017 05:53
@forwebtech well, i try to make a little display screen that show the result before user press `=`
@ReactorboY
May 27 2017 05:54
what I am doing wrong here ?
``````function confirmEnding(str, target) {
// "Never give up and good luck will find you."
if(str.length > target.length){
if(str.substr(-6) == target)
return  true;
else
return false;
}
else {
if(str.subs(-1) == target){
return true;
}
else
return false;
}

}
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification");``````
abraham anak agung
May 27 2017 05:55
@ReactorboY what is `str.subs`?
Aizaz Shahid
@aizazshahid
May 27 2017 05:55
@ReactorboY suppose the target is there at last, then what is the index of that first character of target is in the str ? if you will figure it with coding then you don't need that several statements.
@ReactorboY
May 27 2017 05:56
``````
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
if(target.length > 1){
if(str.substr(-6) == target)
return  true;
else
return false;
}
else {
if(str.substr(-1) == target){
return true;
}
else
return false;
}

}
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification");``````
@forwebtech
Aizaz Shahid
@aizazshahid
May 27 2017 05:57
@ReactorboY why did you put `-6` in substr ? don't make your function hard coded, try to make it dynamic.
@ReactorboY
May 27 2017 05:58
I am confused how I extract the last word from a string ?
and match it to targe
Aizaz Shahid
@aizazshahid
May 27 2017 05:58
@ReactorboY i think your logic is fine but you have to make it dynamic, get the length of that target and then add that number with minus sign into `substr()`
@ReactorboY
May 27 2017 06:00
``````
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
if(str.substr(-target))
return true;
else
return false;

}
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification");``````
Aizaz Shahid
@aizazshahid
May 27 2017 06:01
@ReactorboY but now you have to match it with your target string, because you are extracting from the `str`.
@ReactorboY
May 27 2017 06:01
@forwebtech I am confused now I don't know what To do :(
Aizaz Shahid
@aizazshahid
May 27 2017 06:01
and also `substr()` accepts number not string
ok tell me, `str.substr(-6)` what will return ? guess it ?
@ReactorboY
May 27 2017 06:03
@forwebtech last word
Aizaz Shahid
@aizazshahid
May 27 2017 06:03
precisely, last 6 words characters, so now you have to get the length of `target`
as i said make it dynamic !
@ReactorboY
May 27 2017 06:06
@forwebtech got it bro
``````function confirmEnding(str, target) {
// "Never give up and good luck will find you."
var string = str.substr(-target.length);
if(string == target)
return true;
else
return false;
}``````
abraham anak agung
May 27 2017 06:07
Aizaz Shahid
@aizazshahid
May 27 2017 06:07
@ReactorboY
May 27 2017 06:07
thnx @forwebtech for explanaton
CamperBot
@camperbot
May 27 2017 06:07
reactorboy sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 06:07
@ReactorboY but why are you making an variable instead put your expression into `if`, :+1:
@ReactorboY
May 27 2017 06:08
less work in `if`
Aizaz Shahid
@aizazshahid
May 27 2017 06:08

``````var input = '22  + 43; console.log("hello World")';
var result = eval(input);

console.log(result);``````

first run it and check the result and then test this one:

``````var input = '22  + 43; console.log("hello World")';
console.log(input);``````
@ReactorboY actually we make variables when we need it twice or needs to change the content of that variable !
Elijah White
@elijahwhite97
May 27 2017 06:09

guys I'm doing the palindrome algorithm and I can't figure out why this won't work

``````function palindrome(str) {
// Good luck!
var newStr = str;
JSON.stringify(newStr).replace( /\W/g , '');
newStr.split(['']).reverse().join('');

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

palindrome("yodel");``````

this is what im thinking:
assign the string to a second variable, `newStr`
remove all non-whitespace characters from `newStr` with `JSON.stringify(...)`
use the 'reverse-string' algorithm from the first challenge
and then check if `str === newStr`

Aizaz Shahid
@aizazshahid
May 27 2017 06:09
@ReactorboY but in that case you have only one occurrences of that code, so it is efficient, to use directly.
Elijah White
@elijahwhite97
May 27 2017 06:09
but it's not working :cry:
it only returns `true` no matter what
abraham anak agung
May 27 2017 06:10
@forwebtech hey, how is result `undefined`?
Aizaz Shahid
@aizazshahid
May 27 2017 06:10
@elijahwhite97 why did you use `JSON.stringify`
@padunk actually i am also wondering but now you have know eval capability :)
Elijah White
@elijahwhite97
May 27 2017 06:11

i meant to say "non-alphanumeric characters"
and so i googled how to remove the non alphanumeric characters.

and JSON.stringify showed up like, 3 times, so i used it

Aizaz Shahid
@aizazshahid
May 27 2017 06:12
@elijahwhite97 did you check your self by consoling it ?
Joshua
@Believenjosh
May 27 2017 06:12

unction convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var convertToF= 9/5 + 32

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

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

Brice Afonso
@Qazare
May 27 2017 06:12
Hello everyone ! I have some difficulties with the Record Collection test in Basic Javascript. The thing is there are arrays that are nested within objects within a big object. I know how to navigate in objects with object.property.property etc, I know how to navigate in arrays[0][1] etc... My problem is I don't understand in this case how I can target the array here to .push() a value into it : ```var collection = { "2548": { "album": "Slippery When Wet", "artist": "Bon Jovi", "tracks": [ "Let It Rock", "You Give Love a Bad Name" ] },```
Elijah White
@elijahwhite97
May 27 2017 06:12
@forwebtech how exactly do you mean. by using console.assert?
Brice Afonso
@Qazare
May 27 2017 06:13
the array being the tracks property
abraham anak agung
May 27 2017 06:13
@forwebtech yes this is weird, hahaha... let me digest this one
Aizaz Shahid
@aizazshahid
May 27 2017 06:13

@elijahwhite97 i think you don't need that function because :

The JSON.stringify() method converts a JavaScript value to a JSON string

abraham anak agung
May 27 2017 06:13
@Believenjosh what is var convertoF? you already have fahrenheit variable declare
Aizaz Shahid
@aizazshahid
May 27 2017 06:13
@elijahwhite97 use that `console.log( JSON.stringify( strName ));` and then see the output into your web browser console.
Joshua
@Believenjosh
May 27 2017 06:14
tbh i was just trying anything to figure out how to solve this
Aizaz Shahid
@aizazshahid
May 27 2017 06:15
@Believenjosh there is already `fahrenheit` variable defined for you, so assign that formula into it, don't create new one.
Brice Afonso
@Qazare
May 27 2017 06:15
I tried something like `collection[id].tracks.push(value);`so that I navigate to a collection id given by the user in the function, then navigate to that id's tracks, then push since tracks is an array... Can someone help me clarify this ?
abraham anak agung
May 27 2017 06:15
@Believenjosh you just need to assign the formula to fahrenheit
Aizaz Shahid
@aizazshahid
May 27 2017 06:16
@Qazare `tracks` is an array ?
Elijah White
@elijahwhite97
May 27 2017 06:16
@forwebtech but i got the right idea, don't i?
Mol Eliza
@TheRealMolEliza
May 27 2017 06:17
@forwebtech Why do we need to stringify stuff we log to the console
Aizaz Shahid
@aizazshahid
May 27 2017 06:17
@elijahwhite97 but that is unnecessary !
Joshua
@Believenjosh
May 27 2017 06:17
CamperBot
@camperbot
May 27 2017 06:17
believenjosh sends brownie points to @padunk and @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 06:17
@TheRealMolEliza are you asking or commenting ?
Brice Afonso
@Qazare
May 27 2017 06:18
@forwebtech yes, well at least that's what I understand. Here's the challenge if you want to look http://beta.freecodecamp.com/en/challenges/basic-javascript/record-collection
Mol Eliza
@TheRealMolEliza
May 27 2017 06:18
Sorry, @forwebtech Why should we use JSON.stringify(variableName) when logging to the console

# ?

It's a question
Aizaz Shahid
@aizazshahid
May 27 2017 06:19
to see the result that `JSON.stringify()` modify converts the code to text
@TheRealMolEliza you can find more details here mdn.io/stringify
Elijah White
@elijahwhite97
May 27 2017 06:20
@forwebtech no no, i believe you. but i mean. my explanation of my code. i can remove `JSON.stringify()`.. but i'm still wondering why removing the non-alphanumeric characters is not working... to check for palindrome
Aizaz Shahid
@aizazshahid
May 27 2017 06:20
@elijahwhite97 because in palindrome those characters are not countable, and also spaces !
Mol Eliza
@TheRealMolEliza
May 27 2017 06:20
``````var strName = 'hello';

console.log(strName) // "hello"
console.log(JSON.stringify(strName)) // "'hello'"``````
Aizaz Shahid
@aizazshahid
May 27 2017 06:21
@TheRealMolEliza well actually the thing is that JSON.stringify have not much effect on strings, try it on arrays, make an array and then check the result.
Jia Situ
@Jialiangsitu
May 27 2017 06:22
On the word blank challenge how do I call out the words from the wordBlanks?
Aizaz Shahid
@aizazshahid
May 27 2017 06:22
@Jialiangsitu did you know parameters of the function?
Markus Kiili
@Masd925
May 27 2017 06:23
@TheRealMolEliza JSON is a syntax for storing objects on a string. If you just log the object, editors can show it differently. If you turn it into a JSON string, all editors show it the same.
Jia Situ
@Jialiangsitu
May 27 2017 06:24
@forwebtech I'm using wordBlanks[0],wordBlanks[1] etc to call out the words but its not working
Elijah White
@elijahwhite97
May 27 2017 06:24
@ah, well i figured it out, finally!
Aizaz Shahid
@aizazshahid
May 27 2017 06:24
@Jialiangsitu wordBlanks is your function name, not parameter, you need to use the parameter names into that pre defined variable.
Elijah White
@elijahwhite97
May 27 2017 06:24
@forwebtech
thanks for pointing that out
CamperBot
@camperbot
May 27 2017 06:24
elijahwhite97 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 06:25
@elijahwhite97 :+1:
Mol Eliza
@TheRealMolEliza
May 27 2017 06:25
@Masd925 Maybe better to use arguments for .stringify() to format it, otherwise, use .toString()?
Joshua
@Believenjosh
May 27 2017 06:25

function convertToF(celsius) {
var fahrenheit= 9/5 + 32;
// Only change code below this line
var convertToF;

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

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

Where did I gowrong
Jia Situ
@Jialiangsitu
May 27 2017 06:26
@forwebtech so i would have to do something like myNoun = "dog"; instead of myNoun = wordBlanks[0];?
Aizaz Shahid
@aizazshahid
May 27 2017 06:26
``// Only change code below this line``
Jia Situ
@Jialiangsitu
May 27 2017 06:27
@Believenjosh you forgot to muliply the 9/5
Nasridean
@Nasridean
May 27 2017 06:27
Hello, everyone! I'm stuck on "make objects properties private" challenge. Could you tell me what's wrong with this code?
``````
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();``````
Aizaz Shahid
@aizazshahid
May 27 2017 06:27
@Jialiangsitu well actually you passed the values as arguments, see the function call where already values are passed to your function that goes into your parameters you just have to use the parameter names.
Markus Kiili
@Masd925
May 27 2017 06:28
@TheRealMolEliza Usually you can just log the object. With stringify, you have some options yes.
Aizaz Shahid
@aizazshahid
May 27 2017 06:29
@Nasridean `setGear` should to initialize / assign the value to `gear` not increment.
Mol Eliza
@TheRealMolEliza
May 27 2017 06:29
Thank you @Masd925 I have more to learn still
Thank you @forwebtech as well
CamperBot
@camperbot
May 27 2017 06:29
therealmoleliza sends brownie points to @masd925 and @forwebtech :sparkles: :thumbsup: :sparkles:
:star2: 4148 | @masd925 |http://www.freecodecamp.com/masd925
Jia Situ
@Jialiangsitu
May 27 2017 06:29
@forwebtech Thanks!
CamperBot
@camperbot
May 27 2017 06:29
jialiangsitu sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Jia Situ
@Jialiangsitu
May 27 2017 06:29
@forwebtech I can't believe it was that simple haha
Aizaz Shahid
@aizazshahid
May 27 2017 06:29
:+1:
Nasridean
@Nasridean
May 27 2017 06:31
@forwebtech Yes, it worked. Thank you!
CamperBot
@camperbot
May 27 2017 06:31
nasridean sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 06:31
@TheRealMolEliza one good use of JSON.stringify() method, when you need to send your objects over the network then they will becomes useful.
@Nasridean :+1:
Brice Afonso
@Qazare
May 27 2017 06:35
does someone has a clear explanation for a case where you want to push data to an array which is nested in an object within an object ?
Ryan Kim
@ILoveImages
May 27 2017 06:36
(value === false || value === null || value === 0 || value === "" || value === undefined || value === NaN)

function isFalsy(value) {
/if (value === false || value === null || value === 0 || value === "" || value === undefined || value === NaN) {
return false;
}else{
return true;
}
/
return (value !== false && value !== null && value !== 0 && value !== "" && value !== undefined && value !== NaN);

}
function bouncer(arr) {
// Don't show a false ID to this bouncer.
arr = arr.filter(isFalsy);
return arr;
}

bouncer([7, "ate", "", false, 9]);
bouncer([false, null, 0, NaN, undefined, ""]);
bouncer([1, null, NaN, 2, undefined]);

Mol Eliza
@TheRealMolEliza
May 27 2017 06:36
@forwebtech Another good use is formatting the objects you stringify:
``````\$.getJSON(url, function(data) {
\$('body').append(
`<pre>
\${JSON.stringify(data, null, '\t')}
</pre>`
);
})``````
Ryan Kim
@ILoveImages
May 27 2017 06:36
can you find the problem in my code(Falsy Bouncer)

function isFalsy(value) {
/if (value === false || value === null || value === 0 || value === "" || value === undefined || value === NaN) {
return false;
}else{
return true;
}
/
return (value !== false && value !== null && value !== 0 && value !== "" && value !== undefined && value !== NaN);

}
function bouncer(arr) {
// Don't show a false ID to this bouncer.
arr = arr.filter(isFalsy);
return arr;
}

bouncer([7, "ate", "", false, 9]);
bouncer([false, null, 0, NaN, undefined, ""]);
bouncer([1, null, NaN, 2, undefined]);

Robert Ridley
@robertridley1988
May 27 2017 06:37

Hi everyone. I've been working on the calculator challenge from the advanced front end projects. It's basically finished. Would you mind testing it out? If anyone has any thoughts (good or bad), bug spots, or any suggestions for how my code could be optimized/improved, I would love to hear back. Thanks!!

Mol Eliza
@TheRealMolEliza
May 27 2017 06:37
@robertridley1988 Wow, that looks amazing :)
Kelechi Chinaka
@ke1echi
May 27 2017 06:42
what methods can be used to sum elements in an arr
Aizaz Shahid
@aizazshahid
May 27 2017 06:43
@TheRealMolEliza and there is method in JSON is `JSON.parse( ... )` as geJSON
jmariomejiap
@jmariomejiap
May 27 2017 06:43

hello guys. I need some help with my code. Im working on "smallest common multiple" intermediate algorithm.

``````// noprotect
function smallestCommons(arr) {
var firstNum = arr[0];
var secondNum = arr[1];
var rangeVerify = [];

// assign smaller number to firstNum if needed.
if (firstNum > secondNum) {
firstNum = arr[1];
secondNum = arr[0];
}

// generate range in between two given arguments, for verification.
for (var i = firstNum; i <= secondNum; i++) {
rangeVerify.push(i);
}

var searching = true;
var scm = 0;

while (searching) {
scm++;
console.log(scm);

for (var x = 0; x <= rangeVerify.length; x++) {
if (scm % rangeVerify[x] !== 0) {
break;
}
else if (x === rangeVerify.length -1) {
searching = false;
}
}
}
return scm;
}

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

it works when I run it on node. but somehow it doesnt when I need to submit my solution. any ideas?

Aizaz Shahid
@aizazshahid
May 27 2017 06:43
@kelechichinaka you can use `.reduce()`
@Qazare syntax explanation ?
Robert Ridley
@robertridley1988
May 27 2017 06:44
@TheRealMolEliza Thanks! :)
CamperBot
@camperbot
May 27 2017 06:44
robertridley1988 sends brownie points to @therealmoleliza :sparkles: :thumbsup: :sparkles:
GeorgeII
@GeorgeII
May 27 2017 06:45
@robertridley1988 well done. The only thing I noticed is deleting the first number after I entered the sign. I mean it'll be better if I can see the whole statement on display
Aizaz Shahid
@aizazshahid
May 27 2017 06:45
@robertridley1988 what if it show previous calculations which are in process.
Mol Eliza
@TheRealMolEliza
May 27 2017 06:46
Robert Ridley
@robertridley1988
May 27 2017 06:46
@GeorgeII and @forwebtech thanks for your suggestions:)
CamperBot
@camperbot
May 27 2017 06:46
robertridley1988 sends brownie points to @georgeii and @forwebtech :sparkles: :thumbsup: :sparkles:
Brice Afonso
@Qazare
May 27 2017 06:49
@forwebtech yes I don't understand how the syntax works to target an array within an object, as I posted earlier I tried this but doesn't work `collection[id].tracks.push(value);`
Aizaz Shahid
@aizazshahid
May 27 2017 06:50
@Qazare are you talking about that ?
``````var obj = {
myArray: [1, 2, 4]
};

obj.myArray.push(5);

console.log(obj.myArray);  // Array [ 1, 2, 4, 5 ]``````
isfredlin
@isfredlin
May 27 2017 06:51
hello guys ,i need your help with my code.i am working on No.216 "Profile Lookup"

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

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

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

Aizaz Shahid
@aizazshahid
May 27 2017 06:53
@Qazare is the `id` is string ?? in `collection[id]`
Brice Afonso
@Qazare
May 27 2017 06:53
@forwebtech yes but I need to target the array nested in an object which corresponds to what is entered in the function http://beta.freecodecamp.com/en/challenges/basic-javascript/record-collection
@forwebtech no it's a parameter in the function updateRecords(id, prop, value)
GeorgeII
@GeorgeII
May 27 2017 06:56
Guys, need your help! It worked a week ago but when I opened it yesterday this wasn't working. The code hasn't been changed for a week
``````var locat = '', city = '', temrature = '', weather = '';

\$.getJSON("http://ip-api.com/json/", function(data) {
\$.each(data, function(key, val) {
locat += key + val;
});
\$(".location").html(table_body);
});``````
Aizaz Shahid
@aizazshahid
May 27 2017 06:56
@Qazare let me check in the challenge !
@GeorgeII make sure the link is working or not?
@GeorgeII and did you write `\$(document).ready....` ?
jmariomejiap
@jmariomejiap
May 27 2017 06:59

hello guys. I need some help with my code. Im working on "smallest common multiple" intermediate algorithm.

``````// noprotect
function smallestCommons(arr) {
var firstNum = arr[0];
var secondNum = arr[1];
var rangeVerify = [];

// assign smaller number to firstNum if needed.
if (firstNum > secondNum) {
firstNum = arr[1];
secondNum = arr[0];
}

// generate range in between two given arguments, for verification.
for (var i = firstNum; i <= secondNum; i++) {
rangeVerify.push(i);
}

var searching = true;
var scm = 0;

while (searching) {
scm++;
console.log(scm);

for (var x = 0; x <= rangeVerify.length; x++) {
if (scm % rangeVerify[x] !== 0) {
break;
}
else if (x === rangeVerify.length -1) {
searching = false;
}
}
}
return scm;
}

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

it works when I run it on node. but somehow it doesnt when I need to submit my solution. any ideas?

GeorgeII
@GeorgeII
May 27 2017 06:59
@forwebtech I can enter it in my browser. And also it's CodePen so I think I don't have to use `\$(document).ready...`. Also I haven't changed this code. It just stop working
Aizaz Shahid
@aizazshahid
May 27 2017 07:00

@GeorgeII well the correct syntax is :

``````\$(document).ready(function(){
});``````

i wondered you know the syntax

@jmariomejiap show me some sample results which are working on node ?
jmariomejiap
@jmariomejiap
May 27 2017 07:05
@forwebtech is there a way to post a printscreen here?
Aizaz Shahid
@aizazshahid
May 27 2017 07:07
@jmariomejiap use snipping tool (for Windows) to get the screen shot and then copy and paste it here
jmariomejiap
@jmariomejiap
May 27 2017 07:08
@forwebtech oh... i see, I use linux. let me see what i can find
GeorgeII
@GeorgeII
May 27 2017 07:09
@forwebtech Nothing has changed
Aizaz Shahid
@aizazshahid
May 27 2017 07:10
@GeorgeII paste the code ?
jmariomejiap
@jmariomejiap
May 27 2017 07:10
Aizaz Shahid
@aizazshahid
May 27 2017 07:10
@jmariomejiap take another test and tell me the number
GeorgeII
@GeorgeII
May 27 2017 07:10
@forwebtech yep
Aizaz Shahid
@aizazshahid
May 27 2017 07:11
@jmariomejiap test that `smallestCommons([23, 18])` should return `6056820`
jmariomejiap
@jmariomejiap
May 27 2017 07:11
@forwebtech I have tried with [1,5] [5,1] [1,13]
ok, right away
marciamart
@marciamart
May 27 2017 07:13
``````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; i++){
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]]);``````
Does anyone know what is wrong in this code? The error says: Cannot read property 'lenght' of undefined.
Request-Off-Work
@Request-Off-Work
May 27 2017 07:13

how do I make this an array?

``````    function timeDropDowns() {
return [
'I haven\'t been scheduled yet',
'12:30am', '1am', '1:30am', '2am',
'2:30am', '3am', '3:30am', '4am',
'4:30am', '5am', '5:30am', '6am',
'6:30am', '7am', '7:30am', '8am',
'8:30am', '9am', '9:30am', '10am',
'10:30am', '11am', '11:30am',
'12 Noon',
'12:30pm', '1pm', '1:30pm', '2pm',
'2:30pm', '3pm', '3:30pm', '4pm',
'4:30pm', '5pm', '5:30pm', '6pm',
'6:30pm', '7pm', '7:30pm', '8pm',
'8:30pm', '9pm', '9:30pm', '10pm',
'10:30pm', '11pm', '11:30pm',
'12 Midnight'
];
}``````

var something = timeDropDowns();
typeof(something) // object (not array)

jmariomejiap
@jmariomejiap
May 27 2017 07:14
@forwebtech with [23,18] it goes for long ... 2135480
Aizaz Shahid
@aizazshahid
May 27 2017 07:14
@Qazare are you there ?
@jmariomejiap well your code has problem with bigger values
@jmariomejiap instead it should return `6056820` for `[23,18]`
GeorgeII
@GeorgeII
May 27 2017 07:15
@marciamart I'm not sure but maybe you should try to change i++ in second loop to j++?
Aizaz Shahid
@aizazshahid
May 27 2017 07:15
@Request-Off-Work use `Array.from( timeDropDowns() );`
Request-Off-Work
@Request-Off-Work
May 27 2017 07:16
thank you!
jmariomejiap
@jmariomejiap
May 27 2017 07:16
@forwebtech i think i stopped it too soon. im going to rerun it.
marciamart
@marciamart
May 27 2017 07:16
@GeorgeII Exactly! That is a silly mistake! Thank you so much! :smile:
CamperBot
@camperbot
May 27 2017 07:16
marciamart sends brownie points to @georgeii :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 07:17
@marciamart you are incrementing the `i` also into your nested loop ! your j will always 0 if you will not increment it
jmariomejiap
@jmariomejiap
May 27 2017 07:21
@forwebtech Aizaz, it worked (slowly but found it) check it out.
Aizaz Shahid
@aizazshahid
May 27 2017 07:22
@jmariomejiap so that is the same code which you tried on FCC ?
well reset the page, paste your code and then check ?
jmariomejiap
@jmariomejiap
May 27 2017 07:23
@forwebtech yes, i havent changed anything. copy paste. it kind of freezes up my crappy laptop. ... i know it takes a while to iterate all the way up to that number.
Aizaz Shahid
@aizazshahid
May 27 2017 07:25
then you have the logic problem,
as you have Linux and it is very light weight and FCC don't like longer loops so may be that's the case
jmariomejiap
@jmariomejiap
May 27 2017 07:26
@forwebtech before I wrote it using a while loop... i first tried using a recursion instead... (i thought it was a good idea) but it turned out to give a call stack limit error. so I use a setTimeOut() which fixed the call stack issue but it was terribly slower. so I read about while loops vs recursions.
Aizaz Shahid
@aizazshahid
May 27 2017 07:27
@jmariomejiap well i passed that challenge with `for` loops
Masaki
@masaki1223
May 27 2017 07:28
``````this.show= function(){
noStroke();

fill(255);
ellipse(this.x, this.y, this.r*2, this.r*2);
document.getElementById('bird');

}``````
I want to replace ellipse with image called bird. How can I do it?
jmariomejiap
@jmariomejiap
May 27 2017 07:28
@forwebtech mmmm, I guess I could tried using another computer with windows . and see what happens. but, do you see a logic problem... Math is not my strength, this challenges have been very challenging to me.
Aizaz Shahid
@aizazshahid
May 27 2017 07:29
well i didn't read it yet :)
jmariomejiap
@jmariomejiap
May 27 2017 07:30
@forwebtech lol, sure, but if and when you get a chance please give me some advice. either way thanks a lot for helping me. I really appreciate it.
CamperBot
@camperbot
May 27 2017 07:30
jmariomejiap sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 07:30
@jmariomejiap :+1:
Brice Afonso
@Qazare
May 27 2017 07:33
@forwebtech yes I'm here sorry !
Aizaz Shahid
@aizazshahid
May 27 2017 07:34
@Qazare well if you notice, there is another variable created for you which has the copy of that collections try to modify that string instead collections.
@Qazare which is `collectionCopy`
Phuc Hoang
@spideyinf
May 27 2017 07:36
``````function bouncer(arr) {
// Don't show a false ID to this bouncer.
function isFalsy(obj) {
return obj !== false && obj !== null && obj !== 0 && obj !== "" && obj !== undefined && !isNaN(obj);
}
return arr.filter(isFalsy);
}

bouncer([7, "ate", "", false, 9]);``````
Brice Afonso
@Qazare
May 27 2017 07:36
@forwebtech I don't understand what parse and stringify does, I haven't seen that yet so I don't understand what this variable is for
Phuc Hoang
@spideyinf
May 27 2017 07:36
It still taking "ate" out of the array, what did I do wrong?
Aizaz Shahid
@aizazshahid
May 27 2017 07:37
@Qazare `JSON.stringify()` converts the object into JSON string like text and parse convert JSON string to objects
Phuc Hoang
@spideyinf
May 27 2017 07:37
`obj !== ""` is it correct?
This one compares all the string as well, maybe
Aizaz Shahid
@aizazshahid
May 27 2017 07:39
@spideyinf you should not use && operator, how one value can match all of them ?
This message was deleted
Phuc Hoang
@spideyinf
May 27 2017 07:40
Because isFalsy should contain all of this conditions
My problem is the function still filters out strings
Aizaz Shahid
@aizazshahid
May 27 2017 07:43
my mistake, try to use that `!Number.isNaN(obj)`
Nasridean
@Nasridean
May 27 2017 07:45
Can you tell me, please, why this code doesn't factorialize `num`.
``````
function factorialize(num) {
for (var i = 1; i < num; i++) {
var factor = 1;
factor *= i;
return factor;
}
}

factorialize(5);``````
Jia Situ
@Jialiangsitu
May 27 2017 07:45
How do you set value for the input in switch statement that isn't a number?
ur0sh
@ur0sh
May 27 2017 07:47
``````
function palindrome(str) {
var change = str.replace(/\W+/g, "").toLowerCase();
if (change % 2 === 0){
return false;
}

}

palindrome("miki");``````
Can somebody help me with a hint if that is OK? Since all palindromes are even if you count the length this would be a logical first step to sort out al NONeven. length words right?
Phuc Hoang
@spideyinf
May 27 2017 07:48
I think it is equal to `!isNaN(obj)` @forwebtech
Aizaz Shahid
@aizazshahid
May 27 2017 07:49
precisely not !
Phuc Hoang
@spideyinf
May 27 2017 07:50
@ur0sh change is not a number and you should not use % in this case
Shashwat Tiwari
@the-shashwat
May 27 2017 07:50

function palindrome(str) {
// Good luck!
var req="";
req=str.toLowerCase();

for(var i=0;i<str.length;i++)
{
req="";
var c=str.charAt(i);
var code=c.charCodeAt(0);

``````  if(code<=122 && code>=97)
{
req+=c;
}
}
var rev="";
for(var j=0;j<req.length;j++)
{
rev=req[j]+rev;
}
if(rev==req)
return true;``````

else
return false;

}

palindrome("eye");

why does it not work
ur0sh
@ur0sh
May 27 2017 07:51
oh, OK change a string … right.
Phuc Hoang
@spideyinf
May 27 2017 07:51
Compare the initial `str` with its `str.split("").reverse().join("")`
ur0sh
@ur0sh
May 27 2017 07:52
``````function palindrome(str) {
var change = str.replace(/\W+/g, "").toLowerCase();
if (change.length % 2 === 0){
return false;
}
else{
return true;
}

}

palindrome("eye”);``````
I am so prud I figured this1 out.
It works! :D
Phuc Hoang
@spideyinf
May 27 2017 07:52
@ur0sh Great!
You got it, man!
ur0sh
@ur0sh
May 27 2017 07:53
… no shall I continue. Thanks for the hint @spideyinf
CamperBot
@camperbot
May 27 2017 07:53
ur0sh sends brownie points to @spideyinf :sparkles: :thumbsup: :sparkles:
Shashwat Tiwari
@the-shashwat
May 27 2017 07:53
@ur0sh great !
Phuc Hoang
@spideyinf
May 27 2017 07:53
I still need help for my Falsy challenge
Aizaz Shahid
@aizazshahid
May 27 2017 07:54
did you try that ? @spideyinf
Phuc Hoang
@spideyinf
May 27 2017 07:55
Yes but it did not work, either @forwebtech
Nasridean
@Nasridean
May 27 2017 07:58
Why doesn't this code factorialize `num`?
``````function factorialize(num) {
for (var i = 1; i <= num; i++) {
var factor = 1;
factor *= i;
return factor;
}
}

factorialize(5);``````
Thaslim Shajahan
@Thachuthas
May 27 2017 07:58
i need help in Escape Sequences in Strings
Phuc Hoang
@spideyinf
May 27 2017 07:59
It is totally correct now @Nasridean
`i <= num`
Nasridean
@Nasridean
May 27 2017 08:01
@spideyinf but it doesn't work anyway.
pierroberto
@pierroberto
May 27 2017 08:03
@Nasridean did you try to put var factor before for?
Phuc Hoang
@spideyinf
May 27 2017 08:04
Oh I see, factor will be reseted in your loop @pierroberto
Fix this
Nasridean
@Nasridean
May 27 2017 08:05

@pierroberto I tried

``````
function factorialize(num) {
var factor = 1;
for (var i = 1; i <= num; i++) {
factor *= i;
return factor;
}
}

factorialize(3);``````

for any `num` value it shows 1

pierroberto
@pierroberto
May 27 2017 08:07
@Nasridean try also to move return factor right after the for loop
Phuc Hoang
@spideyinf
May 27 2017 08:07
``````
function bouncer(arr) {
// Don't show a false ID to this bouncer.
function isFalsy(obj) {
return obj !== false && obj !== null && obj !== 0 && obj !== "" && obj !== undefined && !isNaN(obj);
}
return arr.filter(isFalsy);
}

bouncer([7, "ate", "", false, 9]);
//--> [7,9], "ate" got rejected << I need help``````
Aizaz Shahid
@aizazshahid
May 27 2017 08:08
@spideyinf challenge name ?
Phuc Hoang
@spideyinf
May 27 2017 08:09
Falsy Bouncer man
Aizaz Shahid
@aizazshahid
May 27 2017 08:10
ok can you guess @spideyinf the generic type of those excluded characters or data ?
Nasridean
@Nasridean
May 27 2017 08:10
@pierroberto Yes, it worked now. Thank you very much!
CamperBot
@camperbot
May 27 2017 08:10
nasridean sends brownie points to @pierroberto :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 27 2017 08:10
@spideyinf you only have to pass the literal values !
Phuc Hoang
@spideyinf
May 27 2017 08:10
Yes, I knew it
Did obj !== "' remove all the strings
Aizaz Shahid
@aizazshahid
May 27 2017 08:11
they all are objects so if you mach with object then you only need !== 'object'
pierroberto
@pierroberto
May 27 2017 08:11
@Nasridean you're welcome :)
Aizaz Shahid
@aizazshahid
May 27 2017 08:12
@spideyinf check the type of the value , if its object then just stops it otherwise pass it.
Phuc Hoang
@spideyinf
May 27 2017 08:14
I will try, thanks for your suggestion @forwebtech