17th
Jun 2017
Jorge Luis Vazquez
@zentech
Jun 17 2017 00:00 UTC

ok apparently I got it right this time. but I wonder if someone has a better approach ---> var count = 0;

function cc(card) {
// Only change code below this line
if(card <= 6) {
count += 1;
}
if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count -= 1;
}

if(count > 0) {
return count + " Bet";
}
return count + " Hold";
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

koder3
@koder3
Jun 17 2017 00:00 UTC
doesnt work @XLpacman805
Manish Giri
@Manish-Giri
Jun 17 2017 00:01 UTC
@zentech you could use a switch instead.
Nothing else to optimize.
Jorge Luis Vazquez
@zentech
Jun 17 2017 00:01 UTC
@Manish-Giri thanks... yeah that's what I thought
CamperBot
@camperbot
Jun 17 2017 00:01 UTC
zentech sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6010 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 17 2017 00:01 UTC
:+1:
koder3
@koder3
Jun 17 2017 00:02 UTC
@Manish-Giri can you help me?
Manish Giri
@Manish-Giri
Jun 17 2017 00:03 UTC
@koder3 which challenge?
koder3
@koder3
Jun 17 2017 00:03 UTC
function pairElement(str) {

var d = str.split("");

var e = [];
for (var i = 0; i < d.length; i++) {
e.push(d.slice(i, i + 1));
}
return e[2] === ["C"]

}
pairElement("ATCGA");
why does this return me false i entered the exact same thing as e[2] and i got false. how do i make it true
Manish Giri
@Manish-Giri
Jun 17 2017 00:04 UTC
@koder3 which challenge?
koder3
@koder3
Jun 17 2017 00:04 UTC
DNA pairing
Manish Giri
@Manish-Giri
Jun 17 2017 00:05 UTC
you need to return an array right?
Take each character, get its pair, and return the results as a 2d array.
BrandonTeso
@BrandonTeso
Jun 17 2017 00:06 UTC
How do I complete Stand in Line?
koder3
@koder3
Jun 17 2017 00:06 UTC
i know, i have a doubt relating something else
@Manish-Giri
i want it to return true as i entered the same thing that is in e[2]. but it returns false
return e[2] gives me ["C"]
Frank McCroy
@fmccroy
Jun 17 2017 00:07 UTC
@koder3 Possibly put in a few console.log ’s to see what is going on, and verify things are happening how you think they should be.
koder3
@koder3
Jun 17 2017 00:08 UTC
but return e[2] === ["C"] gives me false
how do i make it true
Nefton
@neftonjin
Jun 17 2017 00:08 UTC
hi . how can i make that print screen with the code and post it here ?
Manish Giri
@Manish-Giri
Jun 17 2017 00:08 UTC
@koder3 you're comparing two arrays
don't think you can compare them like that
koder3
@koder3
Jun 17 2017 00:08 UTC
but the arrays are the same
how do i compare it
Manish Giri
@Manish-Giri
Jun 17 2017 00:09 UTC
use a library like underscore
Frank McCroy
@fmccroy
Jun 17 2017 00:09 UTC
e2 === “C” would work better, wouldn’t it?
koder3
@koder3
Jun 17 2017 00:10 UTC
it returns false @fmccroy
Manish Giri
@Manish-Giri
Jun 17 2017 00:10 UTC
without the [ ]
Frank McCroy
@fmccroy
Jun 17 2017 00:10 UTC
Even without the [ ] it returns false?
koder3
@koder3
Jun 17 2017 00:10 UTC
return e[2] === "C" returns false
Manish Giri
@Manish-Giri
Jun 17 2017 00:10 UTC
because one is an array
and one is string
e is a 2d array
[["A"], ["T"], ["C"], ["G"], ["A"]]
koder3
@koder3
Jun 17 2017 00:11 UTC
return e[2] === e[2] gives true however
Frank McCroy
@fmccroy
Jun 17 2017 00:11 UTC
So using the strict === is messing him up? == would give the answer @koder3 wants?
Manish Giri
@Manish-Giri
Jun 17 2017 00:12 UTC
probably
koder3
@koder3
Jun 17 2017 00:12 UTC
@fmccroy that gave true for return e[2] == "C"
@fmccroy thanks
CamperBot
@camperbot
Jun 17 2017 00:12 UTC
koder3 sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
koder3
@koder3
Jun 17 2017 00:12 UTC
i think ill use that
whats difference between == and ===
i know === is strict equality
Frank McCroy
@fmccroy
Jun 17 2017 00:13 UTC
Cool. It worked because == does not check for types, while === does compare types.
koder3
@koder3
Jun 17 2017 00:13 UTC
oh
alright
Frank McCroy
@fmccroy
Jun 17 2017 00:13 UTC
Comparing a string to an array made it fail, due to different types.
Manish Giri
@Manish-Giri
Jun 17 2017 00:14 UTC
I wouldn't use == over === though
koder3
@koder3
Jun 17 2017 00:14 UTC
but then i compared it to an array at start
Manish Giri
@Manish-Giri
Jun 17 2017 00:14 UTC
but that's just me
koder3
@koder3
Jun 17 2017 00:14 UTC
why is it false
i compared it to what it exactly is
Manish Giri
@Manish-Giri
Jun 17 2017 00:15 UTC
you compared the value
not the types
also
koder3
@koder3
Jun 17 2017 00:17 UTC
brb
Manish Giri
@Manish-Giri
Jun 17 2017 00:18 UTC
var test = ["A"];
var test1 = test;

console.log(test === test1); //true

var test2 = ["A"];
console.log(test === test2); //false
arrays are passed as references
Frank McCroy
@fmccroy
Jun 17 2017 00:20 UTC
There are a lot of details to remember! But you are referring to they have different addresses in memory, so we can just compare them like other types of variables?
err.. *can't
Nefton
@neftonjin
Jun 17 2017 00:21 UTC
hi guys can someone help my with the Stand in line challange ?
This is my code

function nextInLine(arr, item) {
arr.push(1);

return    arr.shift() ;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr,10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
pahosler
@pahosler
Jun 17 2017 00:22 UTC
@moigithub your answer looks incorrect, and it doesn't delay for the time entered, the method call is supposed to be callAfter.sum(5000,8,9) not sum.callAfter(5000,8,9)
Frank McCroy
@fmccroy
Jun 17 2017 00:22 UTC
@neftonjin Why are you pushing 1 instead of item?
Manish Giri
@Manish-Giri
Jun 17 2017 00:23 UTC
@fmccroy it's kinda like in the first case you are creating just one array object, and storing the reference to that object in the test variable, then you create another reference to the same object. And since that object has one fixed location in memory, those 2 references are the same locations..
in the second case, you have 2 distinct objects at 2 different locations, so comparing their addresses returns false
Nefton
@neftonjin
Jun 17 2017 00:25 UTC
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
this are the instructions
Frank McCroy
@fmccroy
Jun 17 2017 00:25 UTC
I understand it when reminded, but will probably forget again when I need to use it.
@neftonjin You need to arr.push(item) since the test code is feeding into the item variable when your function is called.
Nefton
@neftonjin
Jun 17 2017 00:28 UTC
Thank you :D
Frank McCroy
@fmccroy
Jun 17 2017 00:28 UTC
Hmm.. The challenge is called nextInLine? I may be thinking of standInLine.. lemme go look
Jorge Luis Vazquez
@zentech
Jun 17 2017 00:28 UTC
is this something that can be done? I have an html page and I would like to execute the code entered by the user on a textarea. The code is javascript. in my page I would like to get the textarea and send it to the console, but I haven't figure out a way to do it. any help appreciated <script>
function jstest() {
var text = document.getElementById("textArea").value;
console.log(text);
}
</script>
<body>
<form >
<textarea rows="4" cols="50" id="textArea">
</textarea><br>
<input type="submit" value="Submit" onclick="jstest()">
</form>
Nick Danvers
@Ravenor222
Jun 17 2017 00:28 UTC
Hey guys, im just about to start the mad libs javascript assignment
However I'm having some trouble understanding the question
Ravi Kishore Thella
@ravikishorethella
Jun 17 2017 00:30 UTC
@Ravenor222 you need to form a sentence using the given words
Nick Danvers
@Ravenor222
Jun 17 2017 00:30 UTC
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence
Frank McCroy
@fmccroy
Jun 17 2017 00:31 UTC
You will make a new string that has hardcoded stuff like “hello” and add variables to it in between.
Nick Danvers
@Ravenor222
Jun 17 2017 00:31 UTC
So I must write a string defined as result
Frank McCroy
@fmccroy
Jun 17 2017 00:32 UTC
It will end up as one long string of stuff added together
Ravi Kishore Thella
@ravikishorethella
Jun 17 2017 00:32 UTC
@Ravenor222 result = you need to work on this part;
Nick Danvers
@Ravenor222
Jun 17 2017 00:33 UTC
@ravikishorethella I have result=""; in the area that denotes I shouldn't edit code,
does that matter?
Ravi Kishore Thella
@ravikishorethella
Jun 17 2017 00:34 UTC
@Ravenor222 you can edit, with the given myNoun, myVerb etc, you need to form a meaningful sentence and the result should be stored in the result
Nick Danvers
@Ravenor222
Jun 17 2017 00:40 UTC
Thanks for the help so far, I guess this is stumping me more than it should
Frank McCroy
@fmccroy
Jun 17 2017 00:41 UTC
newString = “hi” + var1 + “my name is “ + var2 etc.
return newString;
Nick Danvers
@Ravenor222
Jun 17 2017 00:44 UTC
var 1 being the provided variables like "myNoun"
Frank McCroy
@fmccroy
Jun 17 2017 00:44 UTC
Yep!
Nick Danvers
@Ravenor222
Jun 17 2017 00:44 UTC
newString="hi" + myNoun + " my name is " + myVerb ; for example
I'm just having trouble getting anything to run on the console
Frank McCroy
@fmccroy
Jun 17 2017 00:46 UTC
I’m not sure what you mean by run on the console? I plug the code into what code camp provides and go from there
nsonhouse
@nsonhouse
Jun 17 2017 00:53 UTC
Is any one able to help with sequelize?
James
@jnick001
Jun 17 2017 00:54 UTC
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 firstName + ", " + contacts[i].prop;
} else if (contacts[i].firstName !== firstName){
return "No such contact";
} else {
return "No such property";
}
}
// Only change code above this line
}

Any idea why this will only return undefined for the contacts[i].prop section?

it works if I hardcode an item in my array, like contacts[i].likes but not using the prop var

Manish Giri
@Manish-Giri
Jun 17 2017 00:55 UTC
@jnick001 contacts[i][prop] to begin with
James
@jnick001
Jun 17 2017 00:57 UTC
I see. that did show the array value. Why would that work when you have to put the . when not using the prop var?
for example, I was using the console to test different results. I would type contacts[0].likes and it would show the contents of the list.
Eunice Park
@eunicode
Jun 17 2017 01:00 UTC

I have a question about Generate Random Whole Numbers within a Range https://www.freecodecamp.com/challenges/generate-random-whole-numbers-within-a-range

This is the solution

function randomRange(myMin, myMax) {
return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin;
}

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

But I when I try to test this by myself, I keep getting 14 as the highest number that can be generated, not 15.
This is my reasoning process, assuming Math.random() generates 0.9:
Math.floor(Math.random() (15 - 5 + 1)) + 5
Math.floor(Math.random()
11) + 5
Math.floor(0.9 * 11) + 5
Math.floor(9.9) + 5
9 + 5 = 14

What's the error in my reasoning process?

Manish Giri
@Manish-Giri
Jun 17 2017 01:02 UTC
@jnick001 likes is a direct property on the object
prop is just a variable which holds the property name
Alex
@alexandrupintilei
Jun 17 2017 01:03 UTC
Hi
someone here who can give me a hint,to a problem?
Frank McCroy
@fmccroy
Jun 17 2017 01:05 UTC
Alex
@alexandrupintilei
Jun 17 2017 01:06 UTC

function rot13(str) { // LBH QVQ VG!
var x = str.charCode ;
var y = String.fromCharCode(x);
return y;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Write a function which takes a ROT13 encoded string as input and returns a decoded string.
Frank McCroy
@fmccroy
Jun 17 2017 01:08 UTC
@alexandrupintilei It looks like you are trying to convert a whole string to character codes, and back into a string. You need to break the string into individual characters first, and then shift them 13 units, and convert back to characters again
fdemaa
@fdemaa
Jun 17 2017 01:09 UTC
whats wrong with my code ?
var Bike = function() {

// Only change code below this line.
var gear = 0;

this.setGear=function(change){
gear= gear+change;
};

this.getGear=function(){
return gear;
};
};

var myCar = new Car();

var myBike = new Bike();
Alex
@alexandrupintilei
Jun 17 2017 01:09 UTC
@fmccroy thank you
CamperBot
@camperbot
Jun 17 2017 01:09 UTC
alexandrupintilei sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Jun 17 2017 01:11 UTC
@fdemaa gear should be set to change
not incremented with
fdemaa
@fdemaa
Jun 17 2017 01:11 UTC
thanks manish,
Joseph Packham
@JosephPack
Jun 17 2017 01:16 UTC
a should be assigned to b with =
I'm not sure how to do this
Moisés Man
@moigithub
Jun 17 2017 01:17 UTC

can anyone solve this proplem !!
Write an implementation for a function 'callAfter' that enables any function to be called after some specified duration with certain parameters, with the following mentioned syntax:
Example: Lets say you have a function called 'sum' like so:
function sum(a, b) { console.log('Sum is: ', a + b); }
Now you should be able to execute:
sum.callAfter(5000, 8, 9);

u wrote that above.. @pahosler

@moigithub your answer looks incorrect, and it doesn't delay for the time entered, the method call is supposed to be callAfter.sum(5000,8,9)notsum.callAfter(5000,8,9)

if u console.log the values passed u will see delay is 5000, and arguments is [5000, 8, 9]
soo setTimeout function gets the correct delay value, and sum gets called with 8 and 9

Function.prototype.callAfter=function(delay){
console.log("delay is ",delay, "argumetns is ",arguments);  /////////////// <<<<<<<<<<
setTimeout( ()=>this.apply(null,[...arguments].slice(1)), delay); //fixed
}

ok i see the problem is need a wrapper funciton inside setTimeout

Curtis
@CurtisJCamp
Jun 17 2017 01:28 UTC

hey everybody i have no idea what I'm doing wrong to not pass this challenge 
// Setup
function phoneticLookup(val) {
var result = "";

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

};

// Only change code above this line
return lookup[val];
}

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


Challenge "Using Objects for Lookups
Brandon Thomas
@hazeion
Jun 17 2017 01:33 UTC
you are missing a comma after "Adams" for one.
Curtis
@CurtisJCamp
Jun 17 2017 01:34 UTC
oh my goodness that was it thank you very much @hazeion
CamperBot
@camperbot
Jun 17 2017 01:34 UTC
curtisjcamp sends brownie points to @hazeion :sparkles: :thumbsup: :sparkles:
Moisés Man
@moigithub
Jun 17 2017 01:34 UTC
@CurtisJCamp to format code.. backticks MUST be on its OWN line
Brandon Thomas
@hazeion
Jun 17 2017 01:35 UTC
Funny thing.. I am on the exact exercise
Nathaniel Suchy (catgirl)
@irlcatgirl
Jun 17 2017 01:41 UTC
I gotta admit that I found that Javascript escape sequences to be frustrating
I figured out though :)
fdemaa
@fdemaa
Jun 17 2017 01:44 UTC
Can anyone help me to understand Make Object Properties Private ? i pass the exercise, but i dont understand it anyway lol
Brian
@BrianCodes33
Jun 17 2017 01:44 UTC
can someone help me out w/ this npm error when i run npm start
Jun 17 2017 01:45 UTC
@BrianCodes33 - I don't know if I can, if you post your error maybe something will ring a bell with me, it's been a while since I played with that.
@fdemaa - can you post your code and explain what part you don't understand?
Brian
@BrianCodes33
Jun 17 2017 01:46 UTC
tsc -p src/

src/app/components/user.component.ts(16,5): error TS1005: ',' expected.

npm ERR! Darwin 16.5.0
npm ERR! argv "/Users/brianborin/.nvm/versions/node/v7.2.1/bin/node" "/Users/brianborin/.nvm/versions/node/v7.2.1/bin/npm" "run" "build"
npm ERR! node v7.2.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 build: tsc -p src/
npm ERR! Exit status 2
fdemaa
@fdemaa
Jun 17 2017 01:47 UTC
@CurtisJCamp you have to use result and lookup and val, i dont know how to explain it without giving the answer
pahosler
@pahosler
Jun 17 2017 01:48 UTC
@moigithub momentary dyslexia on my part as well, I swapped things around :O probably why I was/am having more trouble than I should have... this has me trying to learn prototyping though :D
fdemaa
@fdemaa
Jun 17 2017 01:48 UTC

i have this , i dont understand what is the use of making the var private and the methods publics ?

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();
Jun 17 2017 01:53 UTC
@fdemaa - thiss is a very basic example of an object and methods (and properties). The idea is that you only "expose" the variables through methods so that you have full control over what values are set in the properties at any time. If anyone using your class in their code had free access to the variables, they could put values in there that could cause your object to not behave as it is supposed to. As I said, this simple example only shows that you cannot directly access the properties without using the methods.
@BrianCodes33 - this looks like a compilation error or syntax error in the user.component.ts file. Is that your own file? Check line 16, column 5 to see if it looks like it should have a comma?
Brian
@BrianCodes33
Jun 17 2017 01:56 UTC
thanks @khaduch still learning how to understand npm errors
CamperBot
@camperbot
Jun 17 2017 01:56 UTC
briancodes33 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Jun 17 2017 01:57 UTC
@BrianCodes33 - I cannot say for certain that I gave your the right information, but that's what it appears to be to me. I haven't used npm very much...
Brian
@BrianCodes33
Jun 17 2017 02:00 UTC
yea i just fixed that line was missing some syntax thx
interesting how the server doesn’t run with a syntax error
NBTALOS
@NBTALOS
Jun 17 2017 02:04 UTC
can a code be wrong but still pass the bonfire challanges ?
Jun 17 2017 02:06 UTC
@NBTALOS - yes, it can be written to just pass the tests, but if the tests change then the code could be incorrect.
@NBTALOS - do you have a specific question about something?
fdemaa
@fdemaa
Jun 17 2017 02:09 UTC
CamperBot
@camperbot
Jun 17 2017 02:09 UTC
fdemaa sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Jun 17 2017 02:09 UTC
@BrianCodes33 - yeah, a syntax error pretty much stops things dead in its tracks.
NBTALOS
@NBTALOS
Jun 17 2017 02:13 UTC
@khaduch thanks , no i was just unsure about my code because it passed the test but still looked like a bit off to me.
CamperBot
@camperbot
Jun 17 2017 02:13 UTC
nbtalos sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Kevin
@kevinwr
Jun 17 2017 02:19 UTC

hey, all.

So I just finished the challenge "find the longest word in a string," and not quite sure about a section of the code. Here is my code:


function findLongestWord(str) {
var array = str.split(' ');

var array2 = [];

for (i = 0; i < array.length; i++) {
array2[i] = array[i].length;
}

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

return array2[0];
}

findLongestWord("The quick brown fox jumped over the lazy dog");

This code passed, but I had to use code I found on w3Schools, which is the array2.sort(function(a,b) { return b-a; });

What I'm having trouble with us the a and b that are in function in the sort method. Obviously it's taking each element that is stored in array2 and comparing them and sorting them in descending order, but not sure how each element becomes a or b.

Also, I'm curious if anyone else could think of a better way to complete this instead of what I have above?
Manish Giri
@Manish-Giri
Jun 17 2017 02:26 UTC
function findLongestWord(str) {
return str.split(" ").map(word => word.length).sort((a,b) => b-a)[0];
}
essentially same logic, just shorter.
Kevin
@kevinwr
Jun 17 2017 02:30 UTC
ahhh map...I know they brought that up earlier. I never really understood that. What does map do?
Manish Giri
@Manish-Giri
Jun 17 2017 02:31 UTC
it iterates over an array and returns a new one based on the logic you put in map.
Kevin
@kevinwr
Jun 17 2017 02:33 UTC
what does "words" do? Is that a variable? and what is the 0 at the end? Trying to understand everything after .split(" "), lol
Manish Giri
@Manish-Giri
Jun 17 2017 02:35 UTC

what does "words" do? Is that a variable?

yep, words becomes every word in the array of strings one by one

changed it to word if it helps

what is the 0 at the end

same thing as what you have - return array2[0];

Jun 17 2017 02:35 UTC
@NBTALOS - if you want to post it, we can have a look and see if you have anything that looks strange. I have seen cases where people have implemented code that strictly is written to pass the tests without applying the concept that is being taught - for example, instead of testing an object for a property and returning a value, there is a direct test of the incoming property name, and then returning the value that is expected in the test. As I said, any change in the test data would make the code break.
Kevin
@kevinwr
Jun 17 2017 02:36 UTC
god I feel like an idiot. JS is kicking my ass. Not sure how I can ever do any of the lower languages if I can't even do JS well
Manish Giri
@Manish-Giri
Jun 17 2017 02:38 UTC
unless you mean something like Assembly language
Brian
@BrianCodes33
Jun 17 2017 02:38 UTC
@kevinwr just break it down piece by piece console log everything
Manish Giri
@Manish-Giri
Jun 17 2017 02:38 UTC
it's mostly the same everywhere
glitz20
@glitz20
Jun 17 2017 02:41 UTC
can anyone help me to find out why my algorithm is not working?https://www.freecodecamp.com/challenges/sorted-union
Kevin
@kevinwr
Jun 17 2017 02:41 UTC
@BrianCodes33 I'll give that a shot. One of my issues is figuring out what the hell is going on in each little bit of code (how the computer is "reading" the code).
@Manish-Giri thank you for the help.
CamperBot
@camperbot
Jun 17 2017 02:41 UTC
kevinwr sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6013 | @manish-giri |http://www.freecodecamp.com/manish-giri
Cam
@cam-barts
Jun 17 2017 02:41 UTC
@sabin20 that just sent me to the same challenge. can you send me your code?
glitz20
@glitz20
Jun 17 2017 02:42 UTC

function uniteUnique(arr) {
var landak=[];
landak.push(arr[0][0]);
for(var i=0;i<arr.length;i++){
for(var j=1;j<arr[i].length;j++){
if(arr[i][j]!==landak){
landak.push(arr[i][j]);
}

}

}

return landak;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

Cam
@cam-barts
Jun 17 2017 02:44 UTC
if(arr[i][j]!==landak){
If the element that is next in the iteration is equal to the ARRAY landak
glitz20
@glitz20
Jun 17 2017 02:46 UTC
@TheKingOfShade so, how should I write code stating elements in the ARRAY landak?
Cam
@cam-barts
Jun 17 2017 02:47 UTC
Yea, you should write a test that checks if the next iteration checks each element of landak, instead of landak itself
ohh bad english, checks the element against each element of landak @sabin20
Does that make sense?
glitz20
@glitz20
Jun 17 2017 02:50 UTC

function uniteUnique(arr) {
var landak=[];
landak.push(arr[0][0]);
for(var i=0;i<arr.length;i++){
for(var j=1;j<arr[i].length;j++){
for(var k=0;k<landak.length;k++){
if(arr[i][j]!==landak[k]){
landak.push(arr[i][j]);
}
}

}

}

return landak;
}

Kelechi Chinaka
@ke1echi
Jun 17 2017 02:53 UTC
function bmi(weight, height) {
const checker = weight / height * height;
return (checker <= 18.5) ? "Underweight" : (checker <= 25.0) ? "Normal" : (checker <= 30.0) ?  "Overweight" : "Obese";
}
bmi(80, 1.80)
Expected: 'Normal', instead got: 'Obese'
what am i doing wrong
glitz20
@glitz20
Jun 17 2017 02:55 UTC
Cam
@cam-barts
Jun 17 2017 02:55 UTC
Well now the logic says that for each element that you check against each element of the landak array, and if it is not equal to that single element, push it onto the array. @sabin20
glitz20
@glitz20
Jun 17 2017 02:58 UTC
Jun 17 2017 03:00 UTC
@kevinwr - another really neat and useful learning tool is http://pythontutor.com/javascript.html. You can plug your code in there and it will run it step by step, giving you visual indications of changing variables and data, how accesses are being made, etc. Once you get used to how it works, it is really great!
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:03 UTC
Hi everyone, I am trying to figure out this task
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

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

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

would everyone give me some kind of hint to understand the rationale behind?
Cam
@cam-barts
Jun 17 2017 03:09 UTC
@sabin20 I would try to incorporate a boolean in there. Something like "if the value already exists for this iteration, return true" and then later "if value is false, push iteration onto array"
glitz20
@glitz20
Jun 17 2017 03:11 UTC
CamperBot
@camperbot
Jun 17 2017 03:11 UTC
sabin20 sends brownie points to @thekingofshade :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Jun 17 2017 03:11 UTC
@AndreusSH you need to keep multiplying product with every number from the innermost for loop..
that way product will have the product of all elements in the sub arrays.
@AndreusSH for (var i=0;i<9;i++) { - also, why i < 9?
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:12 UTC
@Manish-Giri ggggggggggm :smiling_imp: > 6000 :fire:
Manish Giri
@Manish-Giri
Jun 17 2017 03:12 UTC
:smiling_imp:
ty ggggggm @Lumexralph
CamperBot
@camperbot
Jun 17 2017 03:12 UTC
manish-giri sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1944 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:13 UTC
@Manish-Giri good morning, take a look at this, what's the result 8 / 2 * 2 ?
Manish Giri
@Manish-Giri
Jun 17 2017 03:13 UTC
@Lumexralph 8?
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:14 UTC
@Manish-Giri why? disobeyed order of precedence
or am I missing something ?
Manish Giri
@Manish-Giri
Jun 17 2017 03:14 UTC
division and multiplication have same precedence
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:14 UTC
2 @Lumexralph
Manish Giri
@Manish-Giri
Jun 17 2017 03:14 UTC
and on same prec levels, it goes left to right
@Lumexralph
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:14 UTC
@Manish-Giri really ? :worried:
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:14 UTC
that actually was a typo @Manish-Giri thanks for your help
CamperBot
@camperbot
Jun 17 2017 03:14 UTC
andreussh sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6014 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 17 2017 03:14 UTC
yup
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:14 UTC
multiplication b4 division
Coy Sanders
@coymeetsworld
Jun 17 2017 03:14 UTC
yeah thats 8
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:14 UTC
Manish Giri
@Manish-Giri
Jun 17 2017 03:15 UTC
multiplication b4 division
Coy Sanders
@coymeetsworld
Jun 17 2017 03:15 UTC
multiplication and division happen at same time
Manish Giri
@Manish-Giri
Jun 17 2017 03:15 UTC
how come?
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:15 UTC
yea
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:15 UTC
@coymeetsworld on MDN * before \
Coy Sanders
@coymeetsworld
Jun 17 2017 03:15 UTC
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:15 UTC
operator precedence
Manish Giri
@Manish-Giri
Jun 17 2017 03:15 UTC
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:15 UTC
Manish Giri
@Manish-Giri
Jun 17 2017 03:15 UTC
it's all 14
Coy Sanders
@coymeetsworld
Jun 17 2017 03:15 UTC
No its just like real math
$node > let x = 8 *2 / 2; undefined > x 8 Manish Giri @Manish-Giri Jun 17 2017 03:15 UTC so same precedence *, / and % have 14 so L-R Ogundele Olumide @Lumexralph Jun 17 2017 03:16 UTC @coymeetsworld @Manish-Giri ah! Coy Sanders @coymeetsworld Jun 17 2017 03:16 UTC yeah its in the same group maybe thats a little misleading having them in columns Manish Giri @Manish-Giri Jun 17 2017 03:16 UTC yup Coy Sanders @coymeetsworld Jun 17 2017 03:16 UTC probably better to have rows Ogundele Olumide @Lumexralph Jun 17 2017 03:16 UTC @Manish-Giri @coymeetsworld totally missed that, i was misled @Manish-Giri @coymeetsworld thanks CamperBot @camperbot Jun 17 2017 03:17 UTC lumexralph sends brownie points to @manish-giri and @coymeetsworld :sparkles: :thumbsup: :sparkles: :star2: 2806 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld :star2: 6015 | @manish-giri |http://www.freecodecamp.com/manish-giri Manish Giri @Manish-Giri Jun 17 2017 03:17 UTC wonder how it's written in w3schools :thought_balloon: Coy Sanders @coymeetsworld Jun 17 2017 03:17 UTC np its right on w3schools Ogundele Olumide @Lumexralph Jun 17 2017 03:18 UTC but mehn..... how did I miss that Coy Sanders @coymeetsworld Jun 17 2017 03:18 UTC "As in traditional school mathematics, the multiplication is done first. Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-)." @Lumexralph I remember on social media there would be questions like that Kelechi Chinaka @ke1echi Jun 17 2017 03:18 UTC oh it they are both 14 so its left to right associativity @Lumexralph Coy Sanders @coymeetsworld Jun 17 2017 03:19 UTC and you check the comments and people would go to war on who was right lol Ogundele Olumide @Lumexralph Jun 17 2017 03:19 UTC @coymeetsworld yeah... i'm aware..............all this while I have given * more precedence over /, thanks to how mdn placed it CamperBot @camperbot Jun 17 2017 03:19 UTC lumexralph sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles: :warning: lumexralph already gave coymeetsworld points Kelechi Chinaka @ke1echi Jun 17 2017 03:19 UTC :smile: @Manish-Giri @coymeetsworld Ogundele Olumide @Lumexralph Jun 17 2017 03:20 UTC and you check the comments and people would go to war on who was right lol :laughing: :joy: Coy Sanders @coymeetsworld Jun 17 2017 03:20 UTC it was sad william @theironcock Jun 17 2017 03:20 UTC how do i do the thing where the language panels on the chat Coy Sanders @coymeetsworld Jun 17 2017 03:21 UTC Ogundele Olumide @Lumexralph Jun 17 2017 03:21 UTC @coymeetsworld people often favour argument over discussion just to satisfy their ego, right or wrong Manish Giri @Manish-Giri Jun 17 2017 03:22 UTC @coymeetsworld how's CTCI going? I stopped for a bit, reviewing DS before resuming Coy Sanders @coymeetsworld Jun 17 2017 03:22 UTC yeah they do, but also since its not in person they have no shame so they don't back down @Manish-Giri also stopped for a bit haha, I need to get back on it but I was working on a side project I wanted to finish Ogundele Olumide @Lumexralph Jun 17 2017 03:23 UTC @Manish-Giri what's that? Coy Sanders @coymeetsworld Jun 17 2017 03:23 UTC Cracking the Coding Interview Manish Giri @Manish-Giri Jun 17 2017 03:23 UTC what with D3, Redux, Node/Exp/Mongo and my thesis going on at the same time, I wonder when I'll finish CTCI Coy Sanders @coymeetsworld Jun 17 2017 03:23 UTC its a book that has a lot of common "whiteboard" problems you would get Manish Giri @Manish-Giri Jun 17 2017 03:23 UTC :disappointed: Ogundele Olumide @Lumexralph Jun 17 2017 03:23 UTC @coymeetsworld on FCC? Coy Sanders @coymeetsworld Jun 17 2017 03:23 UTC prioritize thesis I would say @Lumexralph no its a book has a few chapters going over interview process, but majority of the book is refresher on algorithms and datastructures with example problems/solutions like right now I'm on the chapter reviewing Linked Lists and problems that would require solving w/ a linked list Ogundele Olumide @Lumexralph Jun 17 2017 03:25 UTC @coymeetsworld cool, should look it up Aizaz Shahid @aizazshahid Jun 17 2017 03:26 UTC @coymeetsworld is it about job interviews ? Coy Sanders @coymeetsworld Jun 17 2017 03:26 UTC yes its not bad, just for the questions/answers alone its good Manish Giri @Manish-Giri Jun 17 2017 03:26 UTC I had an interview once where they asked how would you write a queue using 2 LLs had no idea at the time but you'd just insert to the front of one LL and remove from the end of the other Coy Sanders @coymeetsworld Jun 17 2017 03:27 UTC @forwebtech yes its to help you on the technical interviews Kelechi Chinaka @ke1echi Jun 17 2017 03:27 UTC link pls @coymeetsworld Coy Sanders @coymeetsworld Jun 17 2017 03:27 UTC the questions and content are examples of what top companies have asked in the past Manish Giri @Manish-Giri Jun 17 2017 03:27 UTC scroll up Coy Sanders @coymeetsworld Jun 17 2017 03:28 UTC :point_up: Aizaz Shahid @aizazshahid Jun 17 2017 03:28 UTC @coymeetsworld right ! Augusto @hackedWifi Jun 17 2017 03:28 UTC I am really stuck with the exact change algorithm. I dont know how to start Andrea Mammoliti @AndreusSH Jun 17 2017 03:30 UTC I think I got this function multiplyAll(arr) { var product = 1; // Only change code below this line for (var i=0;i<arr.length;i++); for(var j=0;j<arr[i].length;j++); product *= arr [i][j]; // Only change code above this line return product; } // Modify values below to test your code multiplyAll([[1,2],[3,4],[5,6,7]]); Aizaz Shahid @aizazshahid Jun 17 2017 03:30 UTC Coy Sanders @coymeetsworld Jun 17 2017 03:30 UTC @AndreusSH close I have that bookmarked @forwebtech but I haven't checked it out Aizaz Shahid @aizazshahid Jun 17 2017 03:31 UTC @AndreusSH don't put space between them arr [i][j] Andrea Mammoliti @AndreusSH Jun 17 2017 03:31 UTC @coymeetsworld it seems like the property length is not defined Coy Sanders @coymeetsworld Jun 17 2017 03:31 UTC nope, its the brackets next to the array as mentioned by @forwebtech Manish Giri @Manish-Giri Jun 17 2017 03:31 UTC it's not very helpful imo Coy Sanders @coymeetsworld Jun 17 2017 03:31 UTC oh and another thing(s) something wrong w/ both for loops Manish Giri @Manish-Giri Jun 17 2017 03:31 UTC it has some useful topics but not great solutions jdnelson55 @jdnelson55 Jun 17 2017 03:32 UTC function multiplyAll(arr) { var product = 1; // Only change code below this line for (var i = 0; i < arr.length; i++) { for (var j=0; j < arr[i].length; j++) { product *= arr[i][j]; } } return product ; } // Modify values below to test your code multiplyAll([[1,2],[3,4],[5,6,7]]);   My question on that is where are the nested arrays defined to js? . Andrea Mammoliti @AndreusSH Jun 17 2017 03:32 UTC @coymeetsworld @forwebtech thanks for the brackets CamperBot @camperbot Jun 17 2017 03:32 UTC andreussh sends brownie points to @coymeetsworld and @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 708 | @forwebtech |http://www.freecodecamp.com/forwebtech :star2: 2807 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld Andrea Mammoliti @AndreusSH Jun 17 2017 03:32 UTC @coymeetsworld checking the loops! Coy Sanders @coymeetsworld Jun 17 2017 03:32 UTC @jdnelson55 what do you mean? Aizaz Shahid @aizazshahid Jun 17 2017 03:32 UTC @AndreusSH :+1: jdnelson55 @jdnelson55 Jun 17 2017 03:34 UTC it seems like the nested arrays would need to be defined Aizaz Shahid @aizazshahid Jun 17 2017 03:35 UTC @coymeetsworld instead preparing for interviews, i think we should focus on the excellence of our skill ? Coy Sanders @coymeetsworld Jun 17 2017 03:35 UTC @jdnelson55 no the nested arrays are part of the arr parameter Kelechi Chinaka @ke1echi Jun 17 2017 03:35 UTC true talk @forwebtech Coy Sanders @coymeetsworld Jun 17 2017 03:35 UTC you expect arr to be a 2D array Bryan Reese @breese8009 Jun 17 2017 03:35 UTC cant seem to get the closure to work.... anyone?? function addTogether(a,b) { let validNum= function(arg){ if(typeof arg !=='number'){ return false; } return true; }; // if no 2nd arg if(validNum(arguments[0])===false || validNum(arguments[1])===false){ return undefined; } if(arguments.length===1){ a=arguments[0]; return function(arg){ return arg+a; }; } else return a+b; } addTogether(2,3); Coy Sanders @coymeetsworld Jun 17 2017 03:35 UTC @forwebtech both are important Aizaz Shahid @aizazshahid Jun 17 2017 03:36 UTC @coymeetsworld in how many companies did you work ? Coy Sanders @coymeetsworld Jun 17 2017 03:36 UTC unfortunately unless you are a famous programmer you probably need to go through some sort of whiteboard interview or know things. excluding all the spin-offs and mergers and crap, 3 Manish Giri @Manish-Giri Jun 17 2017 03:36 UTC @coymeetsworld Amazon is buying Whole Foods Bryan Bartley @pun-isher Jun 17 2017 03:36 UTC Hey-- can anyone help me with the Palindrome algorithm challenge? I am not sure why palindrome("0_0 (: /-\ :) 0-0") should return true Coy Sanders @coymeetsworld Jun 17 2017 03:37 UTC yep, 13B Manish Giri @Manish-Giri Jun 17 2017 03:37 UTC wonder what kind of merger that would be$13B
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37 UTC
seems like even if Amazon demolished all the stores and setup warehouses they would still make out lol
Manish Giri
@Manish-Giri
Jun 17 2017 03:37 UTC
lol
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37 UTC
or that was someones thought on the matter at least
jdnelson55
@jdnelson55
Jun 17 2017 03:37 UTC
thats a bag of apples at whole foods...13b
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37 UTC
@jdnelson55 they don't sell apples at whole foods
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:37 UTC
@coymeetsworld what is whiteboard interview ? requires to code in handwriting ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37 UTC
they sell organic granny smiths
:)
Manish Giri
@Manish-Giri
Jun 17 2017 03:38 UTC
anyway, definitely better than Verizon - Yahoo
Jun 17 2017 03:38 UTC
Hey all, I'm working on the Random Quote Machine and had a question that I'm not quite sure about.
jdnelson55
@jdnelson55
Jun 17 2017 03:38 UTC
Coy Sanders
@coymeetsworld
Jun 17 2017 03:38 UTC
@forwebtech essentially solving a problem with pen and paper
jdnelson55
@jdnelson55
Jun 17 2017 03:38 UTC
even better after fukishima
Coy Sanders
@coymeetsworld
Jun 17 2017 03:38 UTC
or whiteboard /marker, chalkboard/chalk, the medium doesn't really matter except that its not typically on a computer
Bryan Bartley
@pun-isher
Jun 17 2017 03:39 UTC
@decaren maybe we can help eachother out
Manish Giri
@Manish-Giri
Jun 17 2017 03:39 UTC
some of my friends actually bought huge whiteboards to practice with
:disappointed:
@coymeetsworld
Bryan Bartley
@pun-isher
Jun 17 2017 03:39 UTC
@decaren i assume you have already done the Palindrome algorithm challenge?
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:39 UTC
@coymeetsworld but what about that person who can do mostly all challenges on his/her own ? is he/she requires to read those books about interviews ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:39 UTC
@Manish-Giri I just do it at work :D
when no one is around
what challenges?
Jun 17 2017 03:40 UTC
ok @pun-isher I can't figure out if I'm supposed to use a Quote API from somewhere or if I am supposed to create a JSON object in the code itself.
Manish Giri
@Manish-Giri
Jun 17 2017 03:40 UTC
lol
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:40 UTC
@coymeetsworld any problem regarding problem solving.
Jun 17 2017 03:40 UTC
yes I have done the palindrome algorithm
Coy Sanders
@coymeetsworld
Jun 17 2017 03:40 UTC
well if you can solve any problem then I don't think you need any book really :)
Manish Giri
@Manish-Giri
Jun 17 2017 03:41 UTC
@coymeetsworld so something I was curious about
Bryan Bartley
@pun-isher
Jun 17 2017 03:42 UTC
@decaren Okay-- based on the challenge- i think the best option is to find an API
Coy Sanders
@coymeetsworld
Jun 17 2017 03:42 UTC
@decaren you can create your own JSON object for the quote project
Bryan Bartley
@pun-isher
Jun 17 2017 03:42 UTC
@decaren the challenge is more in regards to page functionality, than building a quote machine iteself
Manish Giri
@Manish-Giri
Jun 17 2017 03:42 UTC

in a queue, does it matter which end is which?
Like I've always used the left end to insert & right end to delete.

But looks like only the opposite way is true?

@coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:42 UTC
or an array
you don't need to use an API just because its lumped with other projects that do require an API
Manish Giri
@Manish-Giri
Jun 17 2017 03:43 UTC
I remember talking with Claudio over this
Coy Sanders
@coymeetsworld
Jun 17 2017 03:43 UTC
up to you if you want to do it that way
Manish Giri
@Manish-Giri
Jun 17 2017 03:43 UTC
he mentioned it's always insert at right, delete at left
Coy Sanders
@coymeetsworld
Jun 17 2017 03:43 UTC
queue is first-in-first-out
Manish Giri
@Manish-Giri
Jun 17 2017 03:43 UTC
as long as you follow FIFO
shouldn't matter
Coy Sanders
@coymeetsworld
Jun 17 2017 03:43 UTC
as long as your enqueue and dequeue methods are adding/removing in correct place it shouldn't matter
no I don't see why
Manish Giri
@Manish-Giri
Jun 17 2017 03:44 UTC
hm
cool
ty @coymeetsworld
CamperBot
@camperbot
Jun 17 2017 03:44 UTC
manish-giri sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2808 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:44 UTC
if i queue up 1,2,3,4,5, if i dequeue 5 times it should come out 1,2,3,4,5
don't see any performance/memory improvement adding on one side over the other
Jun 17 2017 03:44 UTC
thanks @coymeetsworld and @pun-isher
CamperBot
@camperbot
Jun 17 2017 03:44 UTC
decaren sends brownie points to @coymeetsworld and @pun-isher :sparkles: :thumbsup: :sparkles:
:star2: 2809 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:45 UTC
only thing I would say is do what everyone else would, just so that its more readable
this is assuming you're using linked lists too and all that right @Manish-Giri? not an array?
Manish Giri
@Manish-Giri
Jun 17 2017 03:46 UTC
yeah LL
@coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:47 UTC
ok yeah, as long as you have pointers to the head and tail or whatever then however you want to add it
Manish Giri
@Manish-Giri
Jun 17 2017 03:47 UTC
yeah
that DS course had a video on how to implement dynamic arrays manually
Coy Sanders
@coymeetsworld
Jun 17 2017 03:47 UTC
Manish Giri
@Manish-Giri
Jun 17 2017 03:47 UTC
spent more than an hour trying to figure out wtf he was doing
...
Coy Sanders
@coymeetsworld
Jun 17 2017 03:48 UTC
what language?
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:49 UTC
@coymeetsworld how do you rate FCC challenges difficulty ?
Manish Giri
@Manish-Giri
Jun 17 2017 03:49 UTC
Java
Coy Sanders
@coymeetsworld
Jun 17 2017 03:49 UTC
@forwebtech they can be challenging
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:51 UTC
right !
i found that FCC challenges are also good for experienced programmers.
Coy Sanders
@coymeetsworld
Jun 17 2017 03:53 UTC
yeah they werent trivial, some I wrote could be done better too
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:53 UTC
@coymeetsworld well may be i am wrong, but more thing is that, does that person solves on his own or not ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:54 UTC
you should yeah, or do like pair programming if both of you are at the same level and haven't done the problem before
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:54 UTC
solve a problem on your own code, have gives you great happiness :)
Jun 17 2017 03:54 UTC
I've noticed that looking at the solutions afterwards, I usually solve them the "basic" way, but some of the intermediate and advanced solutions helped me in later challenges.
Coy Sanders
@coymeetsworld
Jun 17 2017 03:54 UTC
yeah its good to look at some solutions later, but usually better when you have more exp
because the more elegant answers youre not going to know right away
Jun 17 2017 03:56 UTC
that's for sure. I feel great when I finish one then look at how much extra code it took me compared to the others.
Coy Sanders
@coymeetsworld
Jun 17 2017 03:56 UTC
but you improve on it later
for find longest word in a string my function at first had 6 lines of code, excluding new lines and lines with just a closing bracket
I got it down to 3 and then eventually now I have it at 1
Jun 17 2017 03:57 UTC
Yes and if nothing else, I've gotten better a reading documentation.
Manish Giri
@Manish-Giri
Jun 17 2017 03:57 UTC
I just redid that today itself
1 line
map, sort
Coy Sanders
@coymeetsworld
Jun 17 2017 03:57 UTC
hmm i just have split and sort
Jun 17 2017 03:57 UTC
Holy crap.
Manish Giri
@Manish-Giri
Jun 17 2017 03:58 UTC
function findLongestWord(str) {
return str.split(" ").map(word => word.length).sort((a,b) => b-a)[0];
}
Coy Sanders
@coymeetsworld
Jun 17 2017 03:58 UTC
return str.split(' ').sort((a,b) => b.length - a.length)[0].length;
Manish Giri
@Manish-Giri
Jun 17 2017 03:58 UTC
oh well
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:59 UTC
Manish Giri
@Manish-Giri
Jun 17 2017 03:59 UTC
ooh
hold up
Jun 17 2017 03:59 UTC
I have six right now. I don't even know what => does
Coy Sanders
@coymeetsworld
Jun 17 2017 03:59 UTC
its a fat arrow, its es6 syntax
its not covered in FCC (yet, its in beta)
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:59 UTC
@coymeetsworld i did that as:
return Math.max(... str.split(" ").map( val => val.length ) );
Coy Sanders
@coymeetsworld
Jun 17 2017 03:59 UTC
yeah I like that a little better @forwebtech
sort method is not as intuitive as math.max imo
Kevin
@kevinwr
Jun 17 2017 04:09 UTC

Hey, all.

I don't want the answer to my following question, but rather, I just want some help thinking about how to solve it, and possibly some tips.

Right now, I'm trying to solve a challenge, and the challenge is to take a string, pass it into a function, and return the string with each letter of each word capitalized

Bryan Reese
@breese8009
Jun 17 2017 04:11 UTC
anyone good w closures
Jun 17 2017 04:11 UTC
What's the question @kevinwr
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:11 UTC
a quick quiz, What is String(something) ? (a) Primitive string (b) String object
Bryan Reese
@breese8009
Jun 17 2017 04:11 UTC
still trying to get help but everyones avoiding helping cause its hard i guess?
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:12 UTC
@breese8009 what's the question?
Kevin
@kevinwr
Jun 17 2017 04:12 UTC
@decaren how do I go about solving the challenge?
Bryan Reese
@breese8009
Jun 17 2017 04:12 UTC
@Lumexralph my closure isnt working on this arguments optional challenge
function addTogether(a,b) {
// check for valid nums function
var args=[];
args.push(arguments[0],arguments[1]);

let validNum=(arg)=>{
return typeof arg === 'number' ? true : false;
};

let check= args.filter((x)=> validNum(x) );

if(check.length!==2){
return undefined;
}
else if(args.length===1){
return function(f){
if(validNum(f)===true){
return f+args[0];
}
return undefined;
};
}  return a+b;
}
addTogether(2,3);
Jun 17 2017 04:13 UTC
@kevinwr using the .toUpperCase method.
Kevin
@kevinwr
Jun 17 2017 04:15 UTC
@decaren I applied that to my string, but it capitalizes each and every word in the string. I only need the first word. They also provide a tip to use split(). Not sure if that's the right way to go about it.
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:15 UTC
hai

function sequentialSizes(val) {
// Only change code below this line
switch(val) {
case 1:
case 2:
case 3:
result = "Low";
break;
case 4:
case 5:
case 6:
result = "Mid";
break;
case 7:
case 8:
case 9:
result = "High";
break;
}

// Only change code above this line
}

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

what is the wrong my code
Kevin
@kevinwr
Jun 17 2017 04:16 UTC
@decaren is it possible to apply regular expressions in the toUpperCase method?
@Karthigesudilani use 
Jun 17 2017 04:16 UTC
Kevin
@kevinwr
Jun 17 2017 04:17 UTC
*code gets copied here*
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:18 UTC
plzz help me
Manish Giri
@Manish-Giri
Jun 17 2017 04:18 UTC
@kevinwr I thought they meant to capitalize every word, first letter?
Bryan Reese
@breese8009
Jun 17 2017 04:19 UTC
@Lumexralph its hard hu?
Kevin
@kevinwr
Jun 17 2017 04:20 UTC
@Manish-Giri yeah, every first letter. I've been racking my brain trying to solve it. I did try splitting it to an array, and using bracket notation to get the first latter of each element, but that was throwing errors all over.
Manish Giri
@Manish-Giri
Jun 17 2017 04:20 UTC
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:21 UTC
@breese8009 sorry was away, would inspect now
Kevin
@kevinwr
Jun 17 2017 04:21 UTC
and I wasn't sure if I could apply toUpperCase method within the array and while using bracket notation
I don't have any code right now. I deleted it all @Manish-Giri
Bryan Reese
@breese8009
Jun 17 2017 04:21 UTC
@Lumexralph all good ,an
man*
i suck w closues
need to work on it
Kevin
@kevinwr
Jun 17 2017 04:22 UTC
@Manish-Giri oh wait...I was doing something like this:

function titleCase(str) {
return str.split(" ").map(word => word[0].toUppercase());
}

titleCase("I'm a little tea pot");
Coy Sanders
@coymeetsworld
Jun 17 2017 04:22 UTC
yeah I wasn't sure what the issue was @breese8009, what is the challenge name?
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:22 UTC
Kevin
@kevinwr
Jun 17 2017 04:22 UTC
it wasn't finished...I was just messing around trying to get crap to work. lol
Manish Giri
@Manish-Giri
Jun 17 2017 04:22 UTC
@kevinwr try not to use map at this stage
Coy Sanders
@coymeetsworld
Jun 17 2017 04:22 UTC
nvm
Bryan Reese
@breese8009
Jun 17 2017 04:22 UTC
@coymeetsworld arguments optional
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:22 UTC
how do this
Manish Giri
@Manish-Giri
Jun 17 2017 04:22 UTC
use a regular for loop
will be easier to debug
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:23 UTC
Kevin
@kevinwr
Jun 17 2017 04:23 UTC
JS is going to be the death of me @Manish-Giri
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:23 UTC
how do this
Manish Giri
@Manish-Giri
Jun 17 2017 04:23 UTC
@kevinwr also that code will give you back only an array of the first letters
not the rest of each word
Bryan Reese
@breese8009
Jun 17 2017 04:23 UTC
no JS is life :heart:
Coy Sanders
@coymeetsworld
Jun 17 2017 04:23 UTC
think the first thing to note is you're not always going to get 2 arguments @breese8009
Bryan Reese
@breese8009
Jun 17 2017 04:23 UTC
@coymeetsworld i handled that tho..
Coy Sanders
@coymeetsworld
Jun 17 2017 04:24 UTC
args.push(arguments[0],arguments[1]); ?
Kevin
@kevinwr
Jun 17 2017 04:24 UTC
@breese8009 It's fun....but I feel like an absolute idiot. For some reason, I feel like I'm just not understanding it like I should be.
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:24 UTC
@breese8009 think @coymeetsworld has a point
Bryan Reese
@breese8009
Jun 17 2017 04:24 UTC
@coymeetsworld but never more then 2
Manish Giri
@Manish-Giri
Jun 17 2017 04:24 UTC
@kevinwr it's okay
it takes practice
Coy Sanders
@coymeetsworld
Jun 17 2017 04:24 UTC
could be 1, then what's arguments[1]?
Manish Giri
@Manish-Giri
Jun 17 2017 04:24 UTC
I'm banging my head with d3 too
Coy Sanders
@coymeetsworld
Jun 17 2017 04:25 UTC
@Manish-Giri I got my chart to render, but its still not right yet
Manish Giri
@Manish-Giri
Jun 17 2017 04:25 UTC
:worried:
Coy Sanders
@coymeetsworld
Jun 17 2017 04:25 UTC
trying to do a stacked bar chart
Manish Giri
@Manish-Giri
Jun 17 2017 04:25 UTC
feels the pain
Bryan Reese
@breese8009
Jun 17 2017 04:25 UTC
else if(args.length===1){
return function(f){
if(validNum(f)===true){
return f+args[0];
}
return undefined;
};
??
no?
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:25 UTC
@breese8009 why don't you just check the length of the arguments array-like object
Kevin
@kevinwr
Jun 17 2017 04:25 UTC
@Manish-Giri I'm hoping things start to click for both of us soon.
Coy Sanders
@coymeetsworld
Jun 17 2017 04:25 UTC
both args have to numbers right?
Manish Giri
@Manish-Giri
Jun 17 2017 04:25 UTC
@kevinwr amen to that
Bryan Reese
@breese8009
Jun 17 2017 04:26 UTC
@Lumexralph arguments.length?
Coy Sanders
@coymeetsworld
Jun 17 2017 04:26 UTC
that looks better, but think you need to check args[0] too
Bryan Reese
@breese8009
Jun 17 2017 04:27 UTC
but if there only 1 arg in there args[0] will still be something
right?
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:27 UTC
@breese8009 yes
Coy Sanders
@coymeetsworld
Jun 17 2017 04:27 UTC
yeah
well I mean you're checking if f is a number
but not args[0]
Bryan Reese
@breese8009
Jun 17 2017 04:27 UTC
and then if thats the case im thinking i need to return closure function
Coy Sanders
@coymeetsworld
Jun 17 2017 04:27 UTC
both need to be numbers
unless you're doing that somewhere else
Bryan Reese
@breese8009
Jun 17 2017 04:28 UTC
yea in validNum and check
i see what u guys are sayin now i think...hang on...brb...
Coy Sanders
@coymeetsworld
Jun 17 2017 04:31 UTC
yeah reading up on it too @breese8009
Vicky Lai
@vickylai
Jun 17 2017 04:34 UTC
function pairwise(arr, arg) {
console.log(arr);
var remainders = arr.map((arg, curr) => arg-arr[curr]);
console.log(remainders);
return arg;
}

console.log(pairwise([1,4,2,3,0,5], 7));
This gives me a remainders array of zeroes. Why?
Coy Sanders
@coymeetsworld
Jun 17 2017 04:34 UTC
and looking at my answer, one thing you should also look at is currying @breese8009
map should only have one param I believe @vickylaiio
arg would be each item in the array, i don't think curr is anything
Vicky Lai
@vickylai
Jun 17 2017 04:36 UTC
@coymeetsworld
var remainders = arr.map((curr) => arg-curr);
Yep. You're right, I got mixed up. Thanks!
CamperBot
@camperbot
Jun 17 2017 04:36 UTC
vickylaiio sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2810 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 04:37 UTC
np
I need to revisit that challenge my soln is not great
Vicky Lai
@vickylai
Jun 17 2017 04:43 UTC
Sigh. I hate it when I solve the mini-problem I was working on and then forget where I was going with the solution overall :/ Especially when my notes don't help.
Kamal
@kpbro
Jun 17 2017 04:44 UTC
function destroyer(arr) {
// Remove all the values
var args = []; //array of other arguments
for(var i=1;i<arguments.length;i++){ args.push(arguments[i]); }
//--------------------------------------------------------------------
for(var k=0;k<args.length;k++){
arr = arr.filter(function(x){ //iterate through main arr and filter out the elements-
return x != args[k];      // given in arguments which are stored in -
});                         // args array one by one.

}
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
this code is working perfectly. but is there any other way of doing this thing?
Coy Sanders
@coymeetsworld
Jun 17 2017 04:44 UTC
you don't need that first for loop @kpbro
could just remove the array from the arguments array, and iterate through it that way
Kamal
@kpbro
Jun 17 2017 04:45 UTC
@coymeetsworld i created it to get other arguments in a seperate array
Coy Sanders
@coymeetsworld
Jun 17 2017 04:45 UTC
yeah thats fine but you could just shift off the array
Bryan Reese
@breese8009
Jun 17 2017 04:45 UTC
@coymeetsworld mannn fuck that challenge lol
Coy Sanders
@coymeetsworld
Jun 17 2017 04:45 UTC
then the arguments array would just be the numbers you need to remove
@breese8009 lol it is a more adv topic
i don't fully understand it either tbh
Kamal
@kpbro
Jun 17 2017 04:46 UTC
@coymeetsworld yup..
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:46 UTC
@coymeetsworld so many of my solutions in the early stages are awful :smile:
Kamal
@kpbro
Jun 17 2017 04:46 UTC
i created separate array so that i can easily iterate through it @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 04:47 UTC
@breese8009 but basically what it seems like to me is if the addTogether function has one param, you're returning a function (currying?). if it has 2 you're adding together
Bryan Reese
@breese8009
Jun 17 2017 04:47 UTC
yo yo, if anyone can fix this code to work...i give u a cookie
function addTogether(a,b) {
// check for valid nums function
var args=[];
args.push(arguments[0],arguments[1]);

let validNum=(arg)=>{
return typeof arg === 'number' ? true : false;
};

let check= args.filter((x)=> validNum(x) );

if(args.length===2){
if(validNum(args[0])===true && validNum(args[1])===true){
return a+b;
}
return undefined;
}

else if(args.length===1){

return function(arg){
if(validNum(args[0])===true){
return arg+args[0];
}
else{
return undefined;
}
};
}
}
addTogether(2,3);
Coy Sanders
@coymeetsworld
Jun 17 2017 04:47 UTC
in both situations you check if your parameters are numbers and if they're not then you return undefined
@Lumexralph mine as well
Bryan Reese
@breese8009
Jun 17 2017 04:47 UTC
@coymeetsworld thats what i am doing w my code i feel but its not :(
Coy Sanders
@coymeetsworld
Jun 17 2017 04:48 UTC
using es6 helped
you still got this args.push(arguments[0],arguments[1]);
you're not always going to have 2 arguments
i.e. addTogether(2)(3)
Bryan Reese
@breese8009
Jun 17 2017 04:48 UTC
@coymeetsworld but i take care of it
dont i?
if its 1 arg then i have a return
if its both args
i have a return
Coy Sanders
@coymeetsworld
Jun 17 2017 04:48 UTC
eh i guess w/ the filter
Bryan Reese
@breese8009
Jun 17 2017 04:49 UTC
not the filter, i can get rid that now
w the code i have
decided to just use the function i made to check if there numbers
no need for that filter
Coy Sanders
@coymeetsworld
Jun 17 2017 04:50 UTC
@breese8009 so the problem I think is when youre pushing 2 values to args, args is always going to be length 2
regardless if one of the arguments is undefined
Bryan Reese
@breese8009
Jun 17 2017 04:50 UTC
lol im done w it for now...but if someone wants to solve what i have with out completely re constructing it...feel free to post answer
@coymeetsworld ahhh ha!
now its a problem
i see
Coy Sanders
@coymeetsworld
Jun 17 2017 04:51 UTC
$node > let x = 5; undefined > let y; undefined > let arr = []; undefined > arr.push(x,y); 2 > arr [ 5, undefined ] > arr.length; 2 > Bryan Reese @breese8009 Jun 17 2017 04:51 UTC ok so now how can i catch both args ? ur right ur right lol Coy Sanders @coymeetsworld Jun 17 2017 04:51 UTC so don't push anything, just check how many args are there Bryan Reese @breese8009 Jun 17 2017 04:51 UTC use this.... var args = Array.from(arguments); Coy Sanders @coymeetsworld Jun 17 2017 04:51 UTC if theres 1 you're going to be returning a function, if 2 you're going to add the values together Bryan Reese @breese8009 Jun 17 2017 04:51 UTC ?? Coy Sanders @coymeetsworld Jun 17 2017 04:51 UTC I have Array.prototype.slice.call(arguments); Aizaz Shahid @aizazshahid Jun 17 2017 04:51 UTC var test = "my sentence"; console.log([...test]); // Array [ "m", "y", " ", "s", "e", "n", "t", ... ] wondering how to get like test.split(" ") array using spread ? Coy Sanders @coymeetsworld Jun 17 2017 04:51 UTC not sure if Array.from will work but try Bryan Reese @breese8009 Jun 17 2017 04:52 UTC @coymeetsworld dude i think u earned the cookie brb @coymeetsworld HAHAHAHA TY CamperBot @camperbot Jun 17 2017 04:52 UTC breese8009 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles: :star2: 2811 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld Coy Sanders @coymeetsworld Jun 17 2017 04:52 UTC helped? Bryan Reese @breese8009 Jun 17 2017 04:52 UTC this whole time u been sayin that..im an idiot yea now i just need to take care of one thing which is ezpz Coy Sanders @coymeetsworld Jun 17 2017 04:53 UTC not whole time :), I didn't know right away had to look at what I was doing rlgerman25 @rlgerman25 Jun 17 2017 04:53 UTC Hi, guys. Can anyone help me with the Wikipedia viewer challenge? Bryan Reese @breese8009 Jun 17 2017 04:53 UTC @Lumexralph ty too sir! CamperBot @camperbot Jun 17 2017 04:53 UTC breese8009 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles: :star2: 1945 | @lumexralph |http://www.freecodecamp.com/lumexralph Bryan Reese @breese8009 Jun 17 2017 04:53 UTC @coymeetsworld That was fun Coy Sanders @coymeetsworld Jun 17 2017 04:53 UTC what part @rlgerman25 ? figuring out api wasn't fun @breese8009 its always fun! Bryan Reese @breese8009 Jun 17 2017 04:54 UTC with out htat issue id of solved it in less then 5 minutes rlgerman25 @rlgerman25 Jun 17 2017 04:54 UTC I dont know how to link the google engine to the page. Coy Sanders @coymeetsworld Jun 17 2017 04:54 UTC if you're wondering wtf why is this important @breese8009, this looks promising http://engineering.cerner.com/blog/closures-and-currying-in-javascript/ rlgerman25 @rlgerman25 Jun 17 2017 04:54 UTC so far I have only the html and CSS parts done @coymeetsworld Coy Sanders @coymeetsworld Jun 17 2017 04:54 UTC at least for practical use google engine @rlgerman25 ? rlgerman25 @rlgerman25 Jun 17 2017 04:55 UTC sorry, Wikipedia Coy Sanders @coymeetsworld Jun 17 2017 04:56 UTC I would look at the documentation Kevin @kevinwr Jun 17 2017 04:56 UTC @Manish-Giri AHHHHH This isn't working: function titleCase(str) { var array = str.split(" "); for (i = 0; i < array.length; i++) { array[i][0].toUpperCase; } var capStr = array.join(" ") return capStr; } titleCase("I'm a little tea pot"); i imagine because .toUpperCase isn't available to arrays, but not sure how to capitalize anything in an array Coy Sanders @coymeetsworld Jun 17 2017 04:56 UTC its on the challenge page, they also provide a link where you can test api calls Aizaz Shahid @aizazshahid Jun 17 2017 04:58 UTC @kevinwr .toUpperCase() is a method you missed () Manish Giri @Manish-Giri Jun 17 2017 04:58 UTC @kevinwr array[i][0].toUpperCase; 1 - this is a function, so () 2 - you need to save the return value Ogundele Olumide @Lumexralph Jun 17 2017 04:58 UTC @Manish-Giri got a way around it Manish Giri @Manish-Giri Jun 17 2017 04:58 UTC once you do 2, you should - 1. join the capitalized first letter with the rest of the word 2. put it back in it's position in the array @kevinwr @Lumexralph :scream: how? Ogundele Olumide @Lumexralph Jun 17 2017 04:59 UTC @Manish-Giri and you won't believe it....just 2 characters I used in the Replace Avengers War Manish Giri @Manish-Giri Jun 17 2017 04:59 UTC wow Hemakshi Sachdev @hemakshis Jun 17 2017 05:00 UTC Hey Guys! I am finally done with my Random Quote Machine Challenge... I would really love to hear your views/feedback... please do visit it :grinning: @cmccormack @SkyC0der thanks a lot guys!! for helping me so much :) https://codepen.io/hemakshis/full/GEjbGb/ CamperBot @camperbot Jun 17 2017 05:00 UTC hemakshis sends brownie points to @cmccormack and @skyc0der :sparkles: :thumbsup: :sparkles: :star2: 1748 | @skyc0der |http://www.freecodecamp.com/skyc0der :cookie: 930 | @cmccormack |http://www.freecodecamp.com/cmccormack Ogundele Olumide @Lumexralph Jun 17 2017 05:00 UTC @Manish-Giri template literals and String.raw method Kevin @kevinwr Jun 17 2017 05:00 UTC @Manish-Giri should I save the returned capitalized characters in another array, then join the arrays? Manish Giri @Manish-Giri Jun 17 2017 05:01 UTC @kevinwr no you can modify the same array over which you're looping it saves space Ogundele Olumide @Lumexralph Jun 17 2017 05:01 UTC @Manish-Giri const replaceSlash = (str) => str.replace(/\\/g, "/"); //create a raw string so no characters are escaped //using template literals let rawString = String.rawC:\Users\Lenovo admin\Desktop\Projects\module.js; replaceSlash(rawString); Manish Giri @Manish-Giri Jun 17 2017 05:02 UTC @Lumexralph niice well done :clap: Coy Sanders @coymeetsworld Jun 17 2017 05:02 UTC what's that? Manish Giri @Manish-Giri Jun 17 2017 05:02 UTC just read up on String.raw i didn't even know it exists Ogundele Olumide @Lumexralph Jun 17 2017 05:02 UTC @Manish-Giri Avengers War complete, victory! Manish Giri @Manish-Giri Jun 17 2017 05:03 UTC @coymeetsworld C:\Users\Lenovo admin\Desktop\Projects\module.js you can't attempt to replace the \ in this string input directly it fails so .raw @Lumexralph :congratulations: Ogundele Olumide @Lumexralph Jun 17 2017 05:04 UTC @coymeetsworld i was playing around with modules and using the ES 6 built-in method, on importing my module I had to use the require function which will take a string (the file path), I can't be replacing backslash \ all the time with / manually, so created a function, discussed with @Manish-Giri on the challenge till it just got solved Kevin @kevinwr Jun 17 2017 05:06 UTC @Manish-Giri not quite sure what you mean. the .toUpperCase() doesn't work on an array element from what I'm discoverying. Manish Giri @Manish-Giri Jun 17 2017 05:06 UTC @kevinwr right, it works on a string, but aren't you doing that? @kevinwr array[i][0].toUpperCase - here, array[i] should give you the word in the current iteration, and [0] should give you the first letter Aizaz Shahid @aizazshahid Jun 17 2017 05:07 UTC const callback = word => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); return str.split(" ").map( callback ).join(" "); thinking, the replace is better here ? Ogundele Olumide @Lumexralph Jun 17 2017 05:07 UTC @Manish-Giri can we ever get to the edge of this thick programming wilderness? Manish Giri @Manish-Giri Jun 17 2017 05:07 UTC never :smiling_imp: @Lumexralph Ogundele Olumide @Lumexralph Jun 17 2017 05:08 UTC are we damned ? Manish Giri @Manish-Giri Jun 17 2017 05:08 UTC so damned :disappointed: Kevin @kevinwr Jun 17 2017 05:08 UTC @Manish-Giri no clue? All I know is that I took the string, that was passed through to a function, then took that variable (str) and applied the .split() method to put each word into an array. I'm not sure if each element is a string now, or what. Ogundele Olumide @Lumexralph Jun 17 2017 05:08 UTC damn! :disappointed: Coy Sanders @coymeetsworld Jun 17 2017 05:08 UTC @Lumexralph ah I see Manish Giri @Manish-Giri Jun 17 2017 05:09 UTC @kevinwr hold up Kevin @kevinwr Jun 17 2017 05:09 UTC @forwebtech eek. a lot of stuff in there I haven't even learned yet. lol Manish Giri @Manish-Giri Jun 17 2017 05:09 UTC @kevinwr it's okay, let's just focus on your code for now.. Ogundele Olumide @Lumexralph Jun 17 2017 05:10 UTC @coymeetsworld it looked like an easy stuff at first till \ started it's magic Revanth Dasari @Evan171 Jun 17 2017 05:10 UTC How is the counting cards problem be done? Manish Giri @Manish-Giri Jun 17 2017 05:10 UTC go through this this has your code so far, with a console log statement try to understand the output on the right then we'll proceed Ogundele Olumide @Lumexralph Jun 17 2017 05:10 UTC @Evan171 some use switch statement, while some use if statement Manish Giri @Manish-Giri Jun 17 2017 05:10 UTC @kevinwr ignore the undefined for now. shameelrauf @shameelrauf Jun 17 2017 05:11 UTC hi i need help in Assignment with a Returned Value Manish Giri @Manish-Giri Jun 17 2017 05:11 UTC @Lumexralph I think in Python(or Java), you can do it directly.. perhaps. Ogundele Olumide @Lumexralph Jun 17 2017 05:12 UTC @Evan171 check the values and increment or decrement count based on that, then you use a conditional statement to check if count is positive ( > 0) or negative then you return count + string (" Hold or Bet") @shameelrauf ask your question @Manish-Giri really? that's life made easy Manish Giri @Manish-Giri Jun 17 2017 05:13 UTC @Lumexralph I don't know for sure, it appeared that way in the SO answers.. Bryan Reese @breese8009 Jun 17 2017 05:13 UTC here was my final solution... function addTogether(a,b) { let args= Array.prototype.slice.call(arguments); let test=args.filter((x)=> typeof x !== 'number'); let validNum=(arg)=>{ return typeof arg === 'number' ? true : false; }; if(test.length!==0) return undefined; else if(args.length===2){ return a+b; } else if(args.length===1){ return function(arg){ if(validNum(args[0])===true && validNum(arg)===true){ return arg+args[0]; } else{ return undefined; } }; } } addTogether(2,3); shameelrauf @shameelrauf Jun 17 2017 05:13 UTC im stuck with the below code var processed = 2; function processArg(num) { var sum =0; var ourSum = sum(5, 12); } processed = processArg(7); Ogundele Olumide @Lumexralph Jun 17 2017 05:13 UTC @Manish-Giri but are they not same characters in all string in all programming languages? Aizaz Shahid @aizazshahid Jun 17 2017 05:13 UTC @kevinwr actually i didn't mean to give you that i want some others to look at that, wondering for better approach. Manish Giri @Manish-Giri Jun 17 2017 05:14 UTC @Lumexralph I think so yeah, maybe it's just how the characters are processed by different engines/compilers? Ogundele Olumide @Lumexralph Jun 17 2017 05:14 UTC @Manish-Giri I think so too, maybe JS interpreter Aizaz Shahid @aizazshahid Jun 17 2017 05:14 UTC @shameelrauf sum(5 , 12 ) ?? where you define that funciton shameelrauf @shameelrauf Jun 17 2017 05:14 UTC it sys Assume we have pre-defined a function sum which adds two numbers together, then: Ogundele Olumide @Lumexralph Jun 17 2017 05:14 UTC @shameelrauf what should be the output? and you need to return a value from your function too shameelrauf @shameelrauf Jun 17 2017 05:15 UTC Assume we have pre-defined a function sum which adds two numbers together, then: ourSum = sum(5, 12); will call sum function, which returns a value of 17 and assigns it to ourSum variable. Kevin @kevinwr Jun 17 2017 05:16 UTC @Manish-Giri Not understanding why you just get the first letter capitalized since you're using a loop to capitalize only the first letter of each element. Because at the beginning you have ["I'm", "a", "little", "tea", "pot"], then when you run the loop through, it should become ["I'm", "A", "Little", "Tea", "Pot"] Coy Sanders @coymeetsworld Jun 17 2017 05:16 UTC does that work @breese8009 ? Ogundele Olumide @Lumexralph Jun 17 2017 05:16 UTC @shameelrauf your function will take 2 arguments i.e it'll have 2 parameters say a and b and what your function will do is return a + b; which is the sum Manish Giri @Manish-Giri Jun 17 2017 05:16 UTC @kevinwr that's not my code, that was the code you wrote Aizaz Shahid @aizazshahid Jun 17 2017 05:16 UTC @shameelrauf yes your approach is good but you have to make that function first :) Manish Giri @Manish-Giri Jun 17 2017 05:17 UTC :point_up: June 17, 2017 12:56 AM@kevinwr Coy Sanders @coymeetsworld Jun 17 2017 05:17 UTC oh wait, I see Manish Giri @Manish-Giri Jun 17 2017 05:17 UTC but to answer your question array[i][0] - what will this give you? @kevinwr shameelrauf @shameelrauf Jun 17 2017 05:17 UTC @forwebtech let me try Manish Giri @Manish-Giri Jun 17 2017 05:18 UTC @kevinwr let's say array[i] is "little" Bryan Reese @breese8009 Jun 17 2017 05:18 UTC @coymeetsworld yea Kevin @kevinwr Jun 17 2017 05:19 UTC @Manish-Giri it selects the element with index i, and then selects the first character in the element Manish Giri @Manish-Giri Jun 17 2017 05:19 UTC @kevinwr yes, and you're doing .upperCase() on that, so it capitalizes just that first letter mayoorika @mayoorika Jun 17 2017 05:19 UTC guys i need help....how to Use the + operator to build myStr // Example var myStr = "This is the start. " + "This is the end."; // Only change code below this line var myStr; Ogundele Olumide @Lumexralph Jun 17 2017 05:20 UTC @mayoorika you mean += operator ? Kevin @kevinwr Jun 17 2017 05:20 UTC right. So it should turn out to be ["I'm", "A", "Little", "Tea", "Pot"] Manish Giri @Manish-Giri Jun 17 2017 05:21 UTC @kevinwr why? Kevin @kevinwr Jun 17 2017 05:21 UTC because you're only selecting the first character Manish Giri @Manish-Giri Jun 17 2017 05:21 UTC .upperCase() will return you a value, but it won't modify the existing string in place you need to do that yourself Ogundele Olumide @Lumexralph Jun 17 2017 05:21 UTC @mayoorika what's the instruction? Manish Giri @Manish-Giri Jun 17 2017 05:21 UTC so in your code for (i = 0; i < array.length; i++) { array[i][0].toUpperCase; } mayoorika @mayoorika Jun 17 2017 05:21 UTC no only use + @Lumexralph Kevin @kevinwr Jun 17 2017 05:22 UTC So what is it doing when it goes through the loop? What gets spit ouch eat iteration? Ogundele Olumide @Lumexralph Jun 17 2017 05:22 UTC @mayoorika you already have what you want to do in your code Manish Giri @Manish-Giri Jun 17 2017 05:22 UTC array[i][0].toUpperCase(); - to JS this line is like, okay I capitalized the first letter but since you didn't tell me what do with it, I'll just throw it away @kevinwr Kevin @kevinwr Jun 17 2017 05:23 UTC I just figured it modified the existing array by running it through the loop Manish Giri @Manish-Giri Jun 17 2017 05:23 UTC nope it won't Kevin @kevinwr Jun 17 2017 05:23 UTC So does running it through the loop create a new array? Manish Giri @Manish-Giri Jun 17 2017 05:23 UTC nope, it won't. That's what I said here - once you do 2, you should - 1. join the capitalized first letter with the rest of the word 2. put it back in it's position in the array Kevin @kevinwr Jun 17 2017 05:24 UTC or when I run it, it's just spitting out a capitalized first letter? mayoorika @mayoorika Jun 17 2017 05:24 UTC yes but i can not going to next step /use the + operator to build myStr/ @Lumexralph Manish Giri @Manish-Giri Jun 17 2017 05:24 UTC as of now yes just spitting out nothing more you need to tell it what more to do Ogundele Olumide @Lumexralph Jun 17 2017 05:24 UTC @mayoorika what should be your output? Kevin @kevinwr Jun 17 2017 05:24 UTC ok. hmmmmm Aizaz Shahid @aizazshahid Jun 17 2017 05:25 UTC @kevinwr strings are immutable in JS you can't change the part of them directly you need to remake a new string and then you need to store your new one, either in pervious array or make a new one. there are some builtin methods that can do that for you. mayoorika @mayoorika Jun 17 2017 05:25 UTC Build myStr from the strings "This is the start. " and "This is the end." using the + operator. @Lumexralph Kevin @kevinwr Jun 17 2017 05:26 UTC @forwebtech why am I not getting this!? :( Manish Giri @Manish-Giri Jun 17 2017 05:26 UTC @kevinwr HINT - you should use string concatenation that was one of the challenges in the exercises Ogundele Olumide @Lumexralph Jun 17 2017 05:27 UTC @mayoorika so what is the FCC test expecting ? I'm asking because their test checks the output @mayoorika or if you have a link mayoorika @mayoorika Jun 17 2017 05:28 UTC Kevin @kevinwr Jun 17 2017 05:28 UTC It's so confusing because I don't know when to use one thing over something else. I also don't seem to know how loops, methods, functions, or anything else works. It's like everything I've done thus far has taught me nothing. Manish Giri @Manish-Giri Jun 17 2017 05:28 UTC @kevinwr check out the JS lessons on codeacademy might be helpful Kevin @kevinwr Jun 17 2017 05:31 UTC I don't know if I should go back and redo all my javascript challenges or not, or what I should be doing. Aizaz Shahid @aizazshahid Jun 17 2017 05:32 UTC @kevinwr var str = "test"; str[0] = "b"; // wrong way: can't change the part of string str = "B" + str.substr(1); // correct way Ogundele Olumide @Lumexralph Jun 17 2017 05:32 UTC @mayoorika var myStr = "This is the start. " + "This is the end."; you did it earlier and it's correct, remove the additional var myStr; you have below Kevin @kevinwr Jun 17 2017 05:33 UTC @forwebtech how am I expected to know how to do this if they haven't even taught us .substr? Aizaz Shahid @aizazshahid Jun 17 2017 05:33 UTC @kevinwr but they gave you the link in many challenges Kevin @kevinwr Jun 17 2017 05:34 UTC not to that Lhats0 @stahloliver Jun 17 2017 05:34 UTC Hi guys, anyone to help with Twitter API? Trying to complete the Random quote generator challenge Aizaz Shahid @aizazshahid Jun 17 2017 05:34 UTC @kevinwr ok see mdn.io/substr @kevinwr if they don't tell you then it doesn't mean you can't search it. so try to learn some builtin functions. Paul Christian L. Catoera @poncatoera Jun 17 2017 05:36 UTC can anybody give a hint on how to approach the title case a sentence task> ? mayoorika @mayoorika Jun 17 2017 05:36 UTC @Lumexralph already i did it but i can not next step Manish Giri @Manish-Giri Jun 17 2017 05:36 UTC @poncatoera there are many hints being discussed here if you scroll up mayoorika @mayoorika Jun 17 2017 05:36 UTC @Lumexralph my output this var myStr = "This is the start. " + "This is the end."; you did it earlier and it's correct, remove the additional var myStr; you have below Aizaz Shahid @aizazshahid Jun 17 2017 05:37 UTC @poncatoera split your string into words array before that first lowercase it and then try to use loop / iterator that will go to each word, then in that you can make a new string with many ways. Ogundele Olumide @Lumexralph Jun 17 2017 05:38 UTC @mayoorika can you show the whole code again? mayoorika @mayoorika Jun 17 2017 05:39 UTC @Lumexralph yeah here.. // Example var myStr = "This is the start. " + "This is the end."; // Only change code below this line Paul Christian L. Catoera @poncatoera Jun 17 2017 05:41 UTC @forwebtech why is it needed to lowercase the strings? Ogundele Olumide @Lumexralph Jun 17 2017 05:41 UTC @mayoorika // Example var ourStr = "I come first. " + "I come second."; // Only change code below this line var myStr; don't know if FCC checks it all, use this initial code given and put your solution below as commented Aizaz Shahid @aizazshahid Jun 17 2017 05:41 UTC @poncatoera because it may be possible like, teXt ? in that case, it should changed as Text Paul Christian L. Catoera @poncatoera Jun 17 2017 05:42 UTC @forwebtech what method should i use to capitalize the first letter in the word? i tried a replace but it doesnt work mayoorika @mayoorika Jun 17 2017 05:42 UTC @Lumexralph this is my output myStr = "This is the start. This is the end."; Aizaz Shahid @aizazshahid Jun 17 2017 05:43 UTC @poncatoera replace also can be used, you did it wrongly i think. but you can use substr() to make a new one. And .charAt(). Ogundele Olumide @Lumexralph Jun 17 2017 05:43 UTC @mayoorika you're missing out the var keyword before the myStr Varun kumar @varunkmr19 Jun 17 2017 05:43 UTC Need help in Word Blanks challenge Manish Giri @Manish-Giri Jun 17 2017 05:43 UTC Aizaz Shahid @aizazshahid Jun 17 2017 05:44 UTC @poncatoera mdn.io/substr and mdn.io/charAt Manish Giri @Manish-Giri Jun 17 2017 05:44 UTC @Lumexralph are you on codewars? Ogundele Olumide @Lumexralph Jun 17 2017 05:44 UTC @mayoorika // Example var ourStr = "I come first. " + "I come second."; // Only change code below this line var myStr = "This is the start. " + "This is the end."; @Manish-Giri I'm but been a prodigal son Manish Giri @Manish-Giri Jun 17 2017 05:45 UTC lol Paul Christian L. Catoera @poncatoera Jun 17 2017 05:45 UTC array[i].replace(array[i].charAt(0), array[i].charAt(0).toUpperCase()) Ogundele Olumide @Lumexralph Jun 17 2017 05:45 UTC sometimes I don't like their hidden tests mayoorika @mayoorika Jun 17 2017 05:46 UTC no i put var keyword but this is only output @Lumexralph Ogundele Olumide @Lumexralph Jun 17 2017 05:47 UTC some are just minor bugs and they won't say, I had to use JSON.stringify for one of my solutions at some point, I got angry and wandered off @Manish-Giri Manish Giri @Manish-Giri Jun 17 2017 05:47 UTC lol I'm trying to understand how it works like what divisions/groupings are there, etc Aizaz Shahid @aizazshahid Jun 17 2017 05:48 UTC @poncatoera seems right but assign it also, because it returns a new string. Varun kumar @varunkmr19 Jun 17 2017 05:48 UTC what should be the output of Word Blanks Challenge? Paul Christian L. Catoera @poncatoera Jun 17 2017 05:48 UTC ohh okay thanksill try @forwebtech ty CamperBot @camperbot Jun 17 2017 05:48 UTC poncatoera sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 709 | @forwebtech |http://www.freecodecamp.com/forwebtech Aizaz Shahid @aizazshahid Jun 17 2017 05:49 UTC @poncatoera :+1: Ogundele Olumide @Lumexralph Jun 17 2017 05:49 UTC @mayoorika that's the answer above Aizaz Shahid @aizazshahid Jun 17 2017 05:49 UTC @varunkmr19 a proper sentence, which used all the parameters but remember to separate them with space. Ogundele Olumide @Lumexralph Jun 17 2017 05:49 UTC @Manish-Giri you mean me? Manish Giri @Manish-Giri Jun 17 2017 05:50 UTC @Lumexralph yea Ogundele Olumide @Lumexralph Jun 17 2017 05:51 UTC @Manish-Giri just solving problems , they are ranked according to difficulties and you get to see other people's solutions after you've solved it, that's the little I know about it Manish Giri @Manish-Giri Jun 17 2017 05:52 UTC @Lumexralph all I could understand is there's this "kata" thing Aizaz Shahid @aizazshahid Jun 17 2017 05:52 UTC still doing some challenges of codeWars. Manish Giri @Manish-Giri Jun 17 2017 05:52 UTC it brings up a long list of problems but other than that there's no grouping like other websites have sub sections - algorithms, implementation, dynamic programming, etc @Lumexralph brb Ogundele Olumide @Lumexralph Jun 17 2017 05:54 UTC @Manish-Giri nah..... just picks problems for you at random, i don't know really maybe you study the site more? okay mayoorika @mayoorika Jun 17 2017 05:55 UTC @Lumexralph i done thq so much Ogundele Olumide @Lumexralph Jun 17 2017 05:56 UTC @mayoorika you're welcome madankumar sm @madanamigo Jun 17 2017 06:01 UTC Aizaz Shahid @aizazshahid Jun 17 2017 06:01 UTC @Lumexralph did you notice, FCC removes the parameters from url that is a really good thing. madankumar sm @madanamigo Jun 17 2017 06:01 UTC help me fix this one Aizaz Shahid @aizazshahid Jun 17 2017 06:01 UTC @madanamigo code ? madankumar sm @madanamigo Jun 17 2017 06:02 UTC function nextInLine(arr, item) { // Your code here item = testArr.push(6); testArr.shift(1); 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([2], 1)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); Ogundele Olumide @Lumexralph Jun 17 2017 06:02 UTC @forwebtech not until you brought my awreness to it Aizaz Shahid @aizazshahid Jun 17 2017 06:02 UTC :) Nikolas Pinon @NikolasP98 Jun 17 2017 06:02 UTC guys! I'm in the profile lookup challenge Ogundele Olumide @Lumexralph Jun 17 2017 06:02 UTC that's cool Nikolas Pinon @NikolasP98 Jun 17 2017 06:02 UTC I need help Aizaz Shahid @aizazshahid Jun 17 2017 06:03 UTC @madanamigo if you are accessing global array then what use of arr ? use parameters instead global ones. a Ogundele Olumide @Lumexralph Jun 17 2017 06:03 UTC @madanamigo push item into arr, use shift then return the removed element @NikolasP98 what have you tried? Aizaz Shahid @aizazshahid Jun 17 2017 06:03 UTC @madanamigo also shift() don't take arguments. mdn.io/shift Nikolas Pinon @NikolasP98 Jun 17 2017 06:04 UTC //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"] } ]; //MY CODE STARTS HERE function lookUpProfile(firstName, prop){ // Only change code below this line //for (var i = 0; i < contacts.length; i++) var i = 0; var j = contacts.length - 1; while (i < contacts.length){ if (contacts[i].firstName === firstName) { return contacts[i][prop]; } else if (contacts[i].firstName !== firstName) { i++; } } if (contacts[j].firstName !== firstName){ return "No such contact"; } else if (contacts[j].prop !== prop) { return "No such property"; } // Only change code above this line } // Change these values to test your function lookUpProfile("Kristian", "lastName"); I need to verify the existence of the proposed property ('prop') and if it doesn't exist, "No such property" should be returned I don't know how to access a property name I also want to change the whole logic behind: var j = contacts.length - 1 Aizaz Shahid @aizazshahid Jun 17 2017 06:07 UTC @NikolasP98 use for loop instead and also you don't need so much conditional statements. Nikolas Pinon @NikolasP98 Jun 17 2017 06:08 UTC what can I accomplish with loop how do I apply it to this excersize Aizaz Shahid @aizazshahid Jun 17 2017 06:08 UTC @NikolasP98 that will iterate through all the contacts @NikolasP98 for( var i=0; i< contacts.length; i++ ) { ... } @NikolasP98 if you are using parameter to look for the property then you need to use [] bracket notation. @NikolasP98 because contacts[i].prop will becomes contacts[i]."some value" and that will throw an exception, so to avoid it we use [] brackets, that accepts strings. . dot operator will only good where you have direct access to the object. Nikolas Pinon @NikolasP98 Jun 17 2017 06:11 UTC so if I want to check of the property "Kittens" exists, then I'd state contacts[i][Kittens] mackyking @mackyking Jun 17 2017 06:11 UTC Help... Help... I need help guys... Nikolas Pinon @NikolasP98 Jun 17 2017 06:11 UTC wuddup Aizaz Shahid @aizazshahid Jun 17 2017 06:11 UTC @NikolasP98 no, it should be contacts[i]["Kittens"] because you are directly accessing the property, and if you put contacts[i][Kittens] then Kittens act like a variable . Nikolas Pinon @NikolasP98 Jun 17 2017 06:11 UTC great Ogundele Olumide @Lumexralph Jun 17 2017 06:12 UTC @NikolasP98 contacts[i].hasOwnProperty("kittens") Nikolas Pinon @NikolasP98 Jun 17 2017 06:12 UTC @forwebtech @Lumexralph thanks CamperBot @camperbot Jun 17 2017 06:12 UTC nikolasp98 sends brownie points to @forwebtech and @lumexralph :sparkles: :thumbsup: :sparkles: :cookie: 710 | @forwebtech |http://www.freecodecamp.com/forwebtech :star2: 1946 | @lumexralph |http://www.freecodecamp.com/lumexralph mackyking @mackyking Jun 17 2017 06:13 UTC @Lumexralph I need help Ogundele Olumide @Lumexralph Jun 17 2017 06:14 UTC @mackyking I can try, ask mackyking @mackyking Jun 17 2017 06:15 UTC That's the challenge i cant solve... Markus Ivancsics @ivancsicsmarkus Jun 17 2017 06:16 UTC @mackyking You just have to switch for the variable val. @mackyking If it is one the answer is "alpha". Aizaz Shahid @aizazshahid Jun 17 2017 06:17 UTC @Lumexralph what approach is good ? const toTruncate = len => str.slice(0, len).concat("..."); return (str.length > num) ? (num > 3) ? toTruncate(num-3) : toTruncate(num) : str; or const toTruncate = len => str.slice(0, len).concat("..."); if(str.length > num) { return (num > 3) ? toTruncate(num-3) : toTruncate(num); } else { return str; } Markus Ivancsics @ivancsicsmarkus Jun 17 2017 06:17 UTC @mackyking So change the variable answer to "alpha"! madankumar sm @madanamigo Jun 17 2017 06:18 UTC guys i m not getting @forwebtech @Lumexralph Aizaz Shahid @aizazshahid Jun 17 2017 06:18 UTC @madanamigo code ? Markus Ivancsics @ivancsicsmarkus Jun 17 2017 06:18 UTC @forwebtech I think the second is more readable. NSS534 @NSS534 Jun 17 2017 06:18 UTC PLease help me with this..................... function convertToF(celsius) { var fahrenheit; // Only change code below this line celsius= fahrenheit*9/5+32; // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(30); Ogundele Olumide @Lumexralph Jun 17 2017 06:19 UTC @forwebtech i personally like the second, for my own readability, and you can do away with the else stuff since you're returning a value Aizaz Shahid @aizazshahid Jun 17 2017 06:19 UTC @NSS534 that formula is for fahrenheit not for celsius, you need to change the given celsius to fahrenheit. @Lumexralph point :+1: Ogundele Olumide @Lumexralph Jun 17 2017 06:20 UTC @madanamigo what issue is that? @NSS534 it should be interchanged, fahrenheit and celsius NSS534 @NSS534 Jun 17 2017 06:21 UTC @forwebtech Thank tou CamperBot @camperbot Jun 17 2017 06:21 UTC nss534 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 711 | @forwebtech |http://www.freecodecamp.com/forwebtech mackyking @mackyking Jun 17 2017 06:21 UTC @ivancsicsmarkus Can we talk in private? Aizaz Shahid @aizazshahid Jun 17 2017 06:21 UTC @NSS534 :+1: mackyking @mackyking Jun 17 2017 06:22 UTC @ivancsicsmarkus Can you give the complete syntax or code structure? madankumar sm @madanamigo Jun 17 2017 06:23 UTC function nextInLine(arr, item) { // Your code here testArr.push(6); item = testArr.shift(); return item; // Change this line } // Test Setup var testArr = [1,2,3,4,5]; // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr, 6)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); @forwebtech Aizaz Shahid @aizazshahid Jun 17 2017 06:23 UTC @madanamigo do you know what are parameters ? mackyking @mackyking Jun 17 2017 06:23 UTC @Lumexralph Can you help me? Ogundele Olumide @Lumexralph Jun 17 2017 06:24 UTC @mackyking what are the instructions? Markus Ivancsics @ivancsicsmarkus Jun 17 2017 06:24 UTC @mackyking switch (val) { case 1: answer = "alpha"; break; ... Aizaz Shahid @aizazshahid Jun 17 2017 06:25 UTC @madanamigo you are passing the reference of your array as argument, which will go to your parameter arr now you have to use that reference (arr) to access the global array in your function, Ogundele Olumide @Lumexralph Jun 17 2017 06:25 UTC @mackyking do you understand how switch statement works? mackyking @mackyking Jun 17 2017 06:29 UTC @ivancsicsmarkus Thanks CamperBot @camperbot Jun 17 2017 06:29 UTC mackyking sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles: :cookie: 622 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus mackyking @mackyking Jun 17 2017 06:30 UTC @Lumexralph Thanks too... CamperBot @camperbot Jun 17 2017 06:30 UTC mackyking sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles: :star2: 1947 | @lumexralph |http://www.freecodecamp.com/lumexralph mackyking @mackyking Jun 17 2017 06:38 UTC By the way guys... What is the use of many brownies point here? Ayush Mahajan @ay2306 Jun 17 2017 06:39 UTC what does this mean? anyone? madankumar sm @madanamigo Jun 17 2017 06:42 UTC tq @forwebtech . i got it .. CamperBot @camperbot Jun 17 2017 06:42 UTC madanamigo sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 712 | @forwebtech |http://www.freecodecamp.com/forwebtech Akash Kandpal @harrypotter0 Jun 17 2017 06:42 UTC @Lumexralph Which editor should I use for html,css and js in ubuntu 16.04 ? Aizaz Shahid @aizazshahid Jun 17 2017 06:44 UTC @mackyking nothing, they are just numbers that can be gained by doing challenges and helping others. jdnelson55 @jdnelson55 Jun 17 2017 06:49 UTC brackets @harrypotter0 brackets is my favorite Ogundele Olumide @Lumexralph Jun 17 2017 06:51 UTC @harrypotter0 i use sublimetext, should try out visual Studio code too... @harrypotter0 there're so many it's about what you want Lauwed @Lauwed Jun 17 2017 06:53 UTC  // Setup function abTest(a, b) { // Only change code below this line if(a < 0) { a -= b; } if(b < 0) { b -= a; } // Only change code above this line return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); } // Change values below to test your code abTest(2,-2);  Ogundele Olumide @Lumexralph Jun 17 2017 06:53 UTC @Manish-Giri did you enjoy it :smile: Lauwed @Lauwed Jun 17 2017 06:53 UTC Oops How can I return an undefined? Please :---D Ogundele Olumide @Lumexralph Jun 17 2017 06:54 UTC @Lauwed return a < b; should give you a boolean Lauwed @Lauwed Jun 17 2017 06:54 UTC Wow okay I get the comments wrong! Thanks and sorry! :----D Ogundele Olumide @Lumexralph Jun 17 2017 06:55 UTC @Lauwed use condition statement to check if a < 0 or b < 0 then you return undefined Lauwed @Lauwed Jun 17 2017 06:55 UTC Ow no in fact I can't touch te return.. Manish Giri @Manish-Giri Jun 17 2017 06:55 UTC @Lumexralph eh it was okay not a very difficult one Lauwed @Lauwed Jun 17 2017 06:55 UTC Ah yes like that! Thank you @Lumexralph CamperBot @camperbot Jun 17 2017 06:55 UTC lauwed sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles: :star2: 1948 | @lumexralph |http://www.freecodecamp.com/lumexralph Manish Giri @Manish-Giri Jun 17 2017 06:55 UTC function arr2bin(arr){ // show me the code return arr.filter(char => typeof char === "number").reduce((a,b) => a+b, 0).toString(2); } Ogundele Olumide @Lumexralph Jun 17 2017 06:55 UTC @Manish-Giri I'm on shift today :disappointed: Manish Giri @Manish-Giri Jun 17 2017 06:56 UTC haha enjoy! Akash Kandpal @harrypotter0 Jun 17 2017 06:56 UTC @Manish-Giri @Lumexralph Can we integrate html, css ,and different files and make a working project on local host ? If so how ? Ogundele Olumide @Lumexralph Jun 17 2017 06:56 UTC @Manish-Giri my colleagues enjoying their weekend..... must we even work Manish Giri @Manish-Giri Jun 17 2017 06:56 UTC I know :sob: so sad heidisdad2 @heidisdad2 Jun 17 2017 06:57 UTC having a little trouble guys. I think it is with my for loop been working on this one for an hour or 2 Ogundele Olumide @Lumexralph Jun 17 2017 06:57 UTC @harrypotter0 your text editor and browser should do Akash Kandpal @harrypotter0 Jun 17 2017 06:58 UTC I have functions in js and scipts too how will they integrate with code in html and css ? NSS534 @NSS534 Jun 17 2017 06:58 UTC Only remove the backslashes \ used to escape quotes. var myStr =\ 'This string has \"double quotes\" in it.And \"probably\" lots of them.\'; Ogundele Olumide @Lumexralph Jun 17 2017 06:58 UTC @harrypotter0 just link your css and js files to your html and use your browser to view the html file heidisdad2 @heidisdad2 Jun 17 2017 06:59 UTC function titleCase(str) { //make whole string lowercase var lowerCase = str.toLowerCase(); //split sting into array by word var lowerSplit = lowerCase.split(" "); //reference i for each string inside the variable //change each words first letter to capital for(i=0; i<str.length; i++){ var arr =[]; arr= lowerSplit; return arr[i].toUpperCase(); } } titleCase("I'm a little tea pot"); Aizaz Shahid @aizazshahid Jun 17 2017 06:59 UTC is that solution is complex ? mutation  const unique = index => [...new Set( arr[index].toLowerCase() )], regex = new RegExp([${arr[1].toLowerCase()}], 'gi');

return unique(0).join("").match(regex).length === unique(1).length;
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:59 UTC
@harrypotter0 you target the DOM element from the css and js scripts
Jun 17 2017 07:00 UTC
the i keeps referenceing 0
no matter what, it references 0
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:00 UTC
@heidisdad2 why don't you short it :
  var lowerSplit = str.toLowerCase().split(" ");
Ayush Mahajan
@ay2306
Jun 17 2017 07:00 UTC
I am having problem with twitch api. I am not even understand it.. what should I do?
Dave Guymon
@daveguymon
Jun 17 2017 07:00 UTC
Help please . . . I am trying to sort the array and return the lowest index where the num parameter could be inserted. My code isn't working for the array and num in the function call here.
function getIndexToIns(arr, num) {
// Find my place in this sorted array.

arr.sort();

for (var i = 0; i < arr.length; i++) {
if (num <= arr[i]) {
return arr.indexOf(arr[i]);
}

}

}

getIndexToIns([5, 3, 20, 3], 5);
Jun 17 2017 07:01 UTC
@forwebtech not sure why i didn't do that...great idea. but that isn't where my problem is i dont think.
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:01 UTC
@heidisdad2 and also you need to run your loop on the splitted array length not on str length.
@heidisdad2 just giving you tip :) i know that's not the problem.
Jun 17 2017 07:02 UTC
@forwebtech ohhhh that makes sense..thank you man.
CamperBot
@camperbot
Jun 17 2017 07:02 UTC
heidisdad2 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Akash Kandpal
@harrypotter0
Jun 17 2017 07:02 UTC
@Lumexralph Ok I will do it . thanks for your time.
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:02 UTC
@heidisdad2 and also why are you creating new array at every time in your loop:
var arr =[];
@heidisdad2 and also return statement stops the function immediately by returning the statement.
@daveguymon you need to insert that num to your array and then just returns its index number, you don't need a loop for that. and also remember to sort it after inserting.
NSS534
@NSS534
Jun 17 2017 07:09 UTC
how can i have encoded text with the proper escape sequences and no spacing.
var myStr="\FirstLine\nSecondLine\rThirdLine\";
Jun 17 2017 07:09 UTC
@forwebtech wow im really not that good at this, thanks for the tips, im gonna get better
CamperBot
@camperbot
Jun 17 2017 07:09 UTC
heidisdad2 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
NSS534
@NSS534
Jun 17 2017 07:09 UTC
how can i have encoded text with the proper escape sequences and no spacing.
var myStr="\FirstLine\nSecondLine\rThirdLine\";
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:10 UTC
@NSS534 FirstLine\n\\SecondLine\\\rThirdLine you just need that remove the slashes from start and end.
Jun 17 2017 07:14 UTC
@forwebtech i created the array because i wasn't getting my for loop back in array form. thought i had to put it in array form .
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:15 UTC
@heidisdad2 actually you don't need a new array you can assign a new string to the existing once.
word[i] = new word having first letter uppercase
Jun 17 2017 07:25 UTC
hmm
back to the drawing board i guess
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:27 UTC
@heidisdad2 you have lowerSplit to get the words, use it as above said.
NSS534
@NSS534
Jun 17 2017 07:30 UTC

how to replace J with H
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H";

Aizaz Shahid
@aizazshahid
Jun 17 2017 07:30 UTC
@NSS534 you can't change the part of String, you need to reassign it with new value.
@NSS534 there are some builtin methods that you can use like replace or substr mdn.io/replace mdn.io/substr but that challenge is not needed those methods, so just directly assign the new value by self.
Tiago Malheiro
@Azzrah
Jun 17 2017 07:42 UTC
how can I make this if statement work for all contacts, and not just 0?
´´´
function lookUpProfile(firstName, prop){
// Only change code below this line
if (firstName == contacts[0].firstName && contacts[0].hasOwnProperty(prop)){
return contacts[0][prop];
}
// Only change code above this line
}
´´´
NSS534
@NSS534
Jun 17 2017 07:43 UTC

How to do this????????????????
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Tiago Malheiro
@Azzrah
Jun 17 2017 07:43 UTC
the code didn't paste correctly, I think I did something wrong with the 
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:45 UTC
@NSS534 you need to use the parameters to make a new sentence but remember to separate them with space and also you can put any text to make it proper, use result for your sentence.
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 07:50 UTC
In chunky monkey, i am getting correct output for cases like these:
chunkArrayInGroups(["a", "b", "c", "d"], 2) should return [["a", "b"], ["c", "d"]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) should return [[0, 1, 2], [3, 4, 5]].
but for case like this:
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]]
i am only getting [[0,1,2,3]] as output
Any hints guys??
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:53 UTC
@Azzrah how you will search all the contacts as you are just searching in the first contact ?
@aakashbhusal7 paste the code as formatted.
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 07:54 UTC
@forwebtech how to format it
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:55 UTC

put code between backticks

Aakash Bhusal
@aakashbhusal7
Jun 17 2017 07:55 UTC
function chunkArrayInGroups(arr, size) {
var arr1=[];
var arr2=[];
var a=0;
for(var i=1;i<=arr.length;i++){
if(i% size !==0){
continue;
}
arr1= arr.slice(a,i);
a=a+size;
arr2.push(arr1);
arr1=[];
}
return arr2;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:55 UTC
@Azzrah and your code is not formatted because you used the frontticks not backticks
@aakashbhusal7 why do you run your loop from 1 ?
@aakashbhusal7 and don't you think ? only one array is required.
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 08:00 UTC
@forwebtech yes one array is required.
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:02 UTC
@aakashbhusal7 you need to do those steps into your loops, suppose we get [1, 2, 3, 4, 5, 6], 3 so our loop should do that:
> first Iteration:
arr.slice(0,  3);

> second iteration
arr.slice(3, 6);
now you have to increment your i as per condition, not i++
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 08:08 UTC
@forwebtech :+1: thanks
solved it this way
function chunkArrayInGroups(arr, size) {
var arr1=[];
var arr2=[];
for(var i=0;i<arr.length;i+=size){
arr1=arr.slice(i,size+i);
arr2.push(arr1);
}
return arr2;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
CamperBot
@camperbot
Jun 17 2017 08:08 UTC
aakashbhusal7 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:08 UTC
@aakashbhusal7
arr1.push( arr.slice(i,size+i) );
you don't need the other array.
bisherwalankit
@bisherwalankit
Jun 17 2017 08:19 UTC
Correct the assignment to myStr to achieve the desired effect

// Setup
var myStr = "Jello World";

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

can anybody tell what to do?
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:20 UTC
@bisherwalankit you can't change the part of the string, but you can reassign it with new value.
bisherwalankit
@bisherwalankit
Jun 17 2017 08:21 UTC
how to reaasign with new value?
Tiago Malheiro
@Azzrah
Jun 17 2017 08:22 UTC
just myStr again i think
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:22 UTC
@bisherwalankit just put the value with = but don't use []
Tiago Malheiro
@Azzrah
Jun 17 2017 08:22 UTC
var myStr**
bisherwalankit
@bisherwalankit
Jun 17 2017 08:24 UTC
@forwebtech Thanks buddy
CamperBot
@camperbot
Jun 17 2017 08:24 UTC
bisherwalankit sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:24 UTC
@bisherwalankit :+1:
Jen
@jenniredfield
Jun 17 2017 08:34 UTC
hiya anyone did the truncate a string challenge

'''

function truncateString(str, num) {
// Clear out that junk in your trunk
var trun;
var strNum = str.length;

if (strNum > num) {
num -= 3;
trun = str.slice(0, num);
trun = trun + "...";

} else if (strNum <= 3) {

trun = str.slice(0, str.length - num);
trun = trun + "...";

}

return trun;
}

truncateString("A-", 1);

'''

CamperBot
@camperbot
Jun 17 2017 08:34 UTC
:bulb: to format code use backticks!  more info
Jen
@jenniredfield
Jun 17 2017 08:34 UTC

function truncateString(str, num) {
// Clear out that junk in your trunk
var trun;
var strNum = str.length;

if (strNum > num) {
num -= 3;
trun = str.slice(0, num);
trun = trun + "...";

} else if (strNum <= 3) {

trun = str.slice(0, str.length - num);
trun = trun + "...";
}

return trun;
}

truncateString("A-", 1);
Vicky Lai
@vickylai
Jun 17 2017 08:38 UTC
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:38 UTC
Hello, need help. I am on Roman Numeral Converter. Below is my code. It is working but my method is not right. Look at console.log statements. I incremented x to make it number. It does that without actually adding 1. But want to know what is the better way.

function convertToRoman(num) {
var x = 0;
numR = "";
num = num.toString();
romanStr = "IVXLCDM";

function C2R(val, dig) {
if (val === "") {
return "";
}

switch(val) {
case(0):
return "";
case(1):
return dig;
case(2):
return dig + dig;
case(3):
return dig + dig + dig;
case(4):
return dig + romanStr[romanStr.indexOf(dig) + 1];
case(5):
return romanStr[romanStr.indexOf(dig) + 1];
case(6):
return romanStr[romanStr.indexOf(dig) + 1] + dig;
case(7):
return romanStr[romanStr.indexOf(dig) + 1] + dig + dig;
case(8):
return romanStr[romanStr.indexOf(dig) + 1] + dig + dig + dig;
case(9):
return dig + romanStr[romanStr.indexOf(dig) + 2];
}

}

for (i=0; i<num.length; i++) {
switch(i) {
case 0:
x = num[num.length-1];
console.log("yyyyyyy " +x);
x = x++;
console.log("xxxxxxx " +x);
numR = C2R(x, "I");
break;
case 1:
x = num[num.length-2];
x = x++;
numR = C2R(x, "X") + numR;
break;
case 2:
x = num[num.length-3];
x = x++;
numR = C2R(x, "C") + numR;
break;
case 3:
x = num[num.length-4];
x = x++;
numR = C2R(x, "M") + numR;
break;
}
}

return numR;
}

convertToRoman(50);
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:39 UTC
@VinayVijayJoshi did you pass with that ?
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:40 UTC
doh! i am mixing things here. x++ is not the right syntax, still my code is working. :worried:
yes
Jen
@jenniredfield
Jun 17 2017 08:41 UTC
@vickylaiio hmm am I going the right diretion
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:41 UTC
@VinayVijayJoshi x++ is a right syntax, you are incrementing your x to 1
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:41 UTC
@forwebtech yes, and I am not sure why
Jen
@jenniredfield
Jun 17 2017 08:41 UTC
Been on that challenge for sometime
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:41 UTC
its equal to x = x+1
Vicky Lai
@vickylai
Jun 17 2017 08:41 UTC
@jenniredfield You'll have to get more specific than that if you want a helpful answer :)
cryptonoobbg
@cryptonoobbg
Jun 17 2017 08:41 UTC
var myStr="FirstLine\nSecondLine\rThirdLine"; // What's the problem here?
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:41 UTC
ok, then back to my previous question. why x did not get incremented
@forwebtech ok, then back to my previous question. why x did not get incremented
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:42 UTC
@VinayVijayJoshi did you console it after incrementing ?
cryptonoobbg
@cryptonoobbg
Jun 17 2017 08:42 UTC
'''
CamperBot
@camperbot
Jun 17 2017 08:42 UTC
:bulb: to format code use backticks!  more info
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:42 UTC
yes, it is in code. It is the same..
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:42 UTC
@cryptonoobbg you also need a backslash before and after SecondLine
Michael Baxter
@baxt01
Jun 17 2017 08:42 UTC
to increment by 1 dont do x = x+1 this is wrong
the correct formatt is x+=1 or x++
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:43 UTC
@baxt01 what's wrong witht that ?
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:43 UTC
@forwebtech
      case 0:
x = num[num.length-1];
console.log("yyyyyyy " +x);
x = x++;
console.log("xxxxxxx " +x);
numR = C2R(x, "I");
break;
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:43 UTC
@baxt01 actually that is more efficient but the syntax is right !
Michael Baxter
@baxt01
Jun 17 2017 08:44 UTC
if you say so
alpox
@alpox
Jun 17 2017 08:44 UTC
@forwebtech @baxt01 x = x + 1 works as well as the others - and none of them is more efficient than the others
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:44 UTC
x = x + 1;
x += 1;
x++;
all are correct syntax
TANVIR AHMED KHAN
@khancom
Jun 17 2017 08:44 UTC
hello everyone
alpox
@alpox
Jun 17 2017 08:44 UTC
@forwebtech More "efficient" would be ++x
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:45 UTC
@alpox post increment and pre increment matters where we storing but its depends.
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:45 UTC
@forwebtech I converted num to string at top, but then I was getting undefined error, so I did x++. It converted x to number but did not increment it.
alpox
@alpox
Jun 17 2017 08:45 UTC
@forwebtech Yes sure, but if you just want an increment without direct expression context, ++x is more performant
TANVIR AHMED KHAN
@khancom
Jun 17 2017 08:45 UTC
im stuck at javascript polindromes problem. do i need replace() method along with two other methods given to check
Jen
@jenniredfield
Jun 17 2017 08:45 UTC
@vickylaiio its ok, Think part of it works, think I just need to go back to it in a bit
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:45 UTC
Hi I'm having trouble with the 'Truncate a string' challenge in Basic Algorithm scripting. I must be missing something because I don't understand this error: 'truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket"'. Why doesn't this string need a '...' ending?
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:46 UTC
@khancom yes to remove the non alphanumerics and space.
Jen
@jenniredfield
Jun 17 2017 08:46 UTC
@rawiki do you know what, think I'm stuck on the same thing
@rawiki my code seems to work for some posibilites but not those .length ones
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:47 UTC
@VinayVijayJoshi here it is check https://repl.it/IpfW/0 you don't need too much coding.
Michael Baxter
@baxt01
Jun 17 2017 08:47 UTC
hold on let me pull up a copy of that leasson
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:48 UTC
@jenniredfield yea it might be a bug because this first .length one and the second .length +2 are suppose to return the same result.
Michael Baxter
@baxt01
Jun 17 2017 08:49 UTC
1st thing if you think your code is right and it's not working refresh your browser and try again
its a deffo bug
alpox
@alpox
Jun 17 2017 08:49 UTC
@forwebtech Correction: actually x = x + 1 and x += 1 should theoretically be more performant than x++ :-/ didn't think right ^^
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:50 UTC
@forwebtech very nice. But I still want to bang my head and come up with solutions and then ask from you pros. I get the right way from your inputs and in the former I learn a lot...
Michael Baxter
@baxt01
Jun 17 2017 08:50 UTC
is the leasson your stuck on called "Check for Palindromes"
Jen
@jenniredfield
Jun 17 2017 08:50 UTC
@rawiki so maybe add another else if str.lenght = num .. return str
Omair Shahid
@Omair133
Jun 17 2017 08:51 UTC
This code is returning the correct output, but not being accepted as a solution.
function titleCase(str) {
var array=[];
str=str.toLowerCase();
array=str.split(' ');
var ans="";
for(var i=0;i<array.length;i++)
{
ans=ans+(array[i].charAt(0)).toUpperCase()+array[i].substring(1)+" ";
}
return ans.substring(0,ans.length-1)+".";

}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Michael Baxter
@baxt01
Jun 17 2017 08:51 UTC
@rawiki which leasson name are you on please
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:53 UTC
@baxt01 'Truncate a string' under Basic Algorithm scripting
Michael Baxter
@baxt01
Jun 17 2017 08:54 UTC
ok thought it was an earlyer one i am just looking at your problem now see if i can help and complette it for me to lol
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:54 UTC
@baxt01 Thanks
CamperBot
@camperbot
Jun 17 2017 08:54 UTC
rawiki sends brownie points to @baxt01 :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:55 UTC
@Omair133 why are you putting . dot ?
you just need to return the exact same string but with Title casing.
Omair Shahid
@Omair133
Jun 17 2017 08:57 UTC
Ohk..Done. Thank you.
Kevin Holmes
@codersc
Jun 17 2017 08:57 UTC
@Omair133 i think the problem is function is adding a period which in some cases is not correct
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:59 UTC
@jenniredfield Unless I'm overlooking something the problem is probably in their testing script. The first .length test should return "A-tisket a-tasket A green and yellow bas..." and the second "A-tisket a-tasket A green and yellow baske..."

@jenniredfield actually I just hacked it to make it pass by adding following.

if (num === "A-tisket a-tasket A green and yellow basket".length + 2)

Rawikitua Isherwood
@rawiki
Jun 17 2017 09:07 UTC
Unless there are any objections I'm opening a Github issue.
Manish Giri
@Manish-Giri
Jun 17 2017 09:07 UTC
@rawiki there's no problem in their testing script.
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:10 UTC
@Manish-Giri you need to sleep :smirk:
Rawikitua Isherwood
@rawiki
Jun 17 2017 09:11 UTC
@Manish-Giri what am I overlooking in this question that's causing it to fail?
Manish Giri
@Manish-Giri
Jun 17 2017 09:11 UTC
you truncate if the length of the string is longer than the given argument
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.
in that case, the two are equal, so no truncate, no ....
Rawikitua Isherwood
@rawiki
Jun 17 2017 09:11 UTC
ok I just didn't read the question properly
Manish Giri
@Manish-Giri
Jun 17 2017 09:12 UTC
@Lumexralph I'm trying to :sob:
Rawikitua Isherwood
@rawiki
Jun 17 2017 09:12 UTC
@Manish-Giri cheers
Manish Giri
@Manish-Giri
Jun 17 2017 09:12 UTC
this d3 is taking longer than expected
@rawiki :+1:
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:13 UTC
@Manish-Giri you're reminding me of demons i', yet to face
Manish Giri
@Manish-Giri
Jun 17 2017 09:13 UTC
lol
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:15 UTC
quiet office, just my breakfast and I @Manish-Giri
Manish Giri
@Manish-Giri
Jun 17 2017 09:15 UTC
@Lumexralph lucky you
how's the weather out there
TANVIR AHMED KHAN
@khancom
Jun 17 2017 09:15 UTC
polindromes problem: do i need split, reverse methods?
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:16 UTC
@Manish-Giri Nigeria weather