These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Jun 2017
john94
@lpy1994
Jun 04 2017 00:00
@jodylecompte yeah, almost forgot about this
thx again buddy
@jodylecompte did you go to boot camp when learning being a web developer?
Jody LeCompte
@jodylecompte
Jun 04 2017 00:03
No, I've been developing for a very long time. I went to college for a few years and then worked my way into a PHP dev job but when I lost that back in November of last year I joined FCC to learn javascript and expand my skill set
john94
@lpy1994
Jun 04 2017 00:05
I drop out of college last fall and move out, solely focus on learning web development but kind of lost direction rn.
Jody LeCompte
@jodylecompte
Jun 04 2017 00:06
Its difficult to figure out what you want to do
I sometimes wonder if I want to run full speed from web dev and go sit in a closet and write hardware drivers
john94
@lpy1994
Jun 04 2017 00:08
I know I want to be in the tech industry but specifically where and what ? no idea yet
Xarri Jorge
@xarrijorge
Jun 04 2017 00:08

any reasons why my code won't work?
```function fearNotLetter(str) {
var newArr = str.split("").map(function(x){ return x.charCodeAt(x);});
for(var i=0; i<newArr.length; i++){
if((newArr[i]+1) !== newArr[i+1]){
return String.fromCharCode((newArr[i] + 1));
}
}
return undefined;
}

fearNotLetter("abce");```

john94
@lpy1994
Jun 04 2017 00:10
@kodinglife find out the missing letter?
Xarri Jorge
@xarrijorge
Jun 04 2017 00:11
@lpy1994 yes, I am finding the missing letter, it is the undefined that is bugging
john94
@lpy1994
Jun 04 2017 00:11
@kodinglife I copy and paste on xcode editer and it works
AJ Brommy
@AJ-Brommy
Jun 04 2017 00:11
@Merinac Sorry bud
john94
@lpy1994
Jun 04 2017 00:11
@kodinglife I mean vscode
Xarri Jorge
@xarrijorge
Jun 04 2017 00:12
@lpy1994 it works for you?
Raymond
@Raymondshen
Jun 04 2017 00:13
Hey guys I have a question about the wordblanks for javascript quite confused on where to start approaching this situation.
john94
@lpy1994
Jun 04 2017 00:13
@kodinglife maybe only in this text ?
Sebastián Rodríguez
@sebastianrs95
Jun 04 2017 00:13
hello, in the Everything Be True algorithm (intermediate scripting), what does it mean if it is "truthy"?
john94
@lpy1994
Jun 04 2017 00:13
tet
test
Raymond
@Raymondshen
Jun 04 2017 00:13

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
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("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
Xarri Jorge
@xarrijorge
Jun 04 2017 00:14
@sebastianrs95 if it validates to true
Sebastián Rodríguez
@sebastianrs95
Jun 04 2017 00:14
oh ok, thank you :)
john94
@lpy1994
Jun 04 2017 00:16
@kodinglife what I did on this challenge is that, I find the range and then compare it to the given condition
@kodinglife maybe not the smartest way but it works for me
Xarri Jorge
@xarrijorge
Jun 04 2017 00:16
@lpy1994 on the missing letter?
@lpy1994 Here is my code: https://goo.gl/jZ9PX7
Jody LeCompte
@jodylecompte
Jun 04 2017 00:17
dev really needs to figure out why that picture comes up with challenge links are shared
john94
@lpy1994
Jun 04 2017 00:17
@kodinglife that if statement is kind of confusing
@kodinglife if the given condition is not missing any letter but it still produces one
Raymond
@Raymondshen
Jun 04 2017 00:19
does anybody know how to solve this problem quite confused and stuck on it :\
Xarri Jorge
@xarrijorge
Jun 04 2017 00:19
@lpy1994 so it does calculations on the current number and the number next to it and if the two don't match then there is a letter missing so add one to the current number and return the character from that code
john94
@lpy1994
Jun 04 2017 00:21
@kodinglife try change abce to abcde and see what happen
Jody LeCompte
@jodylecompte
Jun 04 2017 00:21
@Raymondshen The idea is to build a sentence
Raymond
@Raymondshen
Jun 04 2017 00:22
@jodylecompte yeah, but the thing is I'm not sure where to approach this problem.
Jody LeCompte
@jodylecompte
Jun 04 2017 00:22
So for example if you pass in wordBlanks("dog", "big", "ran", "quickly"); then you would get out a sentence along the lines of "The big dog ran quickly"
Joseph
@Big-jo
Jun 04 2017 00:22
how do i check if an object has a property
Raymond
@Raymondshen
Jun 04 2017 00:23
@jodylecompte oh okay so I would do like result = myAdjective + myNoun + myVerb + myAdverb; ?
Joseph
@Big-jo
Jun 04 2017 00:23
how do i check if an object has a particular property
Jody LeCompte
@jodylecompte
Jun 04 2017 00:23
That's the start, but you'll also need to add in spaces and the other words so the sentence makes sense
Xarri Jorge
@xarrijorge
Jun 04 2017 00:23
@lpy1994 you hint solved it. the error was in the for loop. I was counting to the end of the array which is one more than the index of the last element. when I add "d" to the mix, it returned "f" so i knew to subtract 1 from the length. thanks.
CamperBot
@camperbot
Jun 04 2017 00:23
kodinglife sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @lpy1994 |http://www.freecodecamp.com/lpy1994
Jody LeCompte
@jodylecompte
Jun 04 2017 00:23
@Big-jo You use the function .hasOwnProperty @Big-jo
Raymond
@Raymondshen
Jun 04 2017 00:23
@jodylecompte I see, so what about the other wordblanks where they ask for cat little hit slowly?
Xarri Jorge
@xarrijorge
Jun 04 2017 00:24
@lpy1994 check out finished code here: https://goo.gl/jZ9PX7
Jody LeCompte
@jodylecompte
Jun 04 2017 00:24
That's the challenge, is to make the sentence make sense even if the input is changed
Joseph
@Big-jo
Jun 04 2017 00:24
@jodylecompte thanks
CamperBot
@camperbot
Jun 04 2017 00:24
big-jo sends brownie points to @jodylecompte :sparkles: :thumbsup: :sparkles:
:star2: 1041 | @jodylecompte |http://www.freecodecamp.com/jodylecompte
Jody LeCompte
@jodylecompte
Jun 04 2017 00:24
So your big dog may turn into a small cat that is sleeping loudl instead of running quicly
but the sentence will still make sense
Raymond
@Raymondshen
Jun 04 2017 00:25
@jodylecompte ahhh I see I'll try it right now! i appreciate your help i'll update you after trying again.
Joseph
@Big-jo
Jun 04 2017 00:25

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


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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
huston i have a problem, i dont understand what to do
john94
@lpy1994
Jun 04 2017 00:25
@kodinglife I dont see any changes
but I think you got it
Xarri Jorge
@xarrijorge
Jun 04 2017 00:26
@lpy1994 look at the for loop i<newArr.length; -1 is added now
Raymond
@Raymondshen
Jun 04 2017 00:26
@jodylecompte got it!, Thanks man! you really helped me!
CamperBot
@camperbot
Jun 04 2017 00:26
raymondshen sends brownie points to @jodylecompte :sparkles: :thumbsup: :sparkles:
:star2: 1042 | @jodylecompte |http://www.freecodecamp.com/jodylecompte
Jody LeCompte
@jodylecompte
Jun 04 2017 00:26
In Javascript, everything is an object, and by being an object, it inherits functions from its prototype such as Array or String. All objects inherit from the Object prototype where they get the method HasOwnProperty
john94
@lpy1994
Jun 04 2017 00:26
the link you send was the old ones but its fine, you got it
@kodinglife
Jody LeCompte
@jodylecompte
Jun 04 2017 00:27
so if you call objectName.hasOwnProperty() with the name of the property you are trying to access, it returns true or false depending on if it is there
Joseph
@Big-jo
Jun 04 2017 00:27
@jodylecompte thanks
CamperBot
@camperbot
Jun 04 2017 00:27
big-jo sends brownie points to @jodylecompte :sparkles: :thumbsup: :sparkles:
:warning: big-jo already gave jodylecompte points
hydracus
@hydracus
Jun 04 2017 00:33

Hey guys, I am currently doing the challenge Stand In Line in Javascript. Can someone advise why the following will not work. "TypeError: queue.shift is not a function"

function nextInLine(arr, item) {
var queue = arr.push(item);
queue = queue.shift(); //
return queue;
}

Where as this will work?
function nextInLine(arr, item) {
var queue = arr.push(item);
queue = arr.shift();
return queue;
}

Moisés Man
@moigithub
Jun 04 2017 00:34
most functions/methods DO something and return a RESULT back..
soo what push returns ?? @hydracus
u can check on the documentation mdn.io/array.push
Xarri Jorge
@xarrijorge
Jun 04 2017 00:35
@hydracus is queue an array?
@hydracus this can be done without creating new variables. just push item to array and return arr.shift();
alican karalar
@alicankaralar
Jun 04 2017 00:39
still stuck
rly going nuts
Xarri Jorge
@xarrijorge
Jun 04 2017 00:40
@alicankaralar what is the problem?
hydracus
@hydracus
Jun 04 2017 00:40
thanks @moigithub I'll read it through. Thanks @kodinglife, In the challenge, arr would be an array, so i assumed var queue = arr.push(item); queue would turn into an array
CamperBot
@camperbot
Jun 04 2017 00:40
hydracus sends brownie points to @moigithub and @kodinglife :sparkles: :thumbsup: :sparkles:
:cookie: 494 | @kodinglife |http://www.freecodecamp.com/kodinglife
:star2: 3314 | @moigithub |http://www.freecodecamp.com/moigithub
Jody LeCompte
@jodylecompte
Jun 04 2017 00:40
@kodinglife In computer science, a queue is a bit more complicated than an array
but you can use an array as a queue logistically (push new value to the end, pull values from the front)
the code is also inside the link
Jody LeCompte
@jodylecompte
Jun 04 2017 00:41
But a queue as you study it in data structures will be a series of objects (essentially a linked list) where each node holds its value and a reference to the next node
alican karalar
@alicankaralar
Jun 04 2017 00:42
the problem is i can’t access the array that is at the outer scope, so that i can mutate it.
Jody LeCompte
@jodylecompte
Jun 04 2017 00:43
@alicankaralar Stuck on what?
alican karalar
@alicankaralar
Jun 04 2017 00:43
at a node challenge
Jody LeCompte
@jodylecompte
Jun 04 2017 00:44
ooo that sounds interesting
Jody LeCompte
@jodylecompte
Jun 04 2017 00:44
async is hard to get a grasp on at first
alican karalar
@alicankaralar
Jun 04 2017 00:46
well the problem i am having is about mutating an array at the outer scope
    responses.splice(a, 0, sum);
this line doesn’t work
Jody LeCompte
@jodylecompte
Jun 04 2017 00:47
That shouldn't be a problem due to scope
Since responses is declared as a var in what appears (based on gist) to be global scope
Which http library is that?
alican karalar
@alicankaralar
Jun 04 2017 00:48
its the core http module of node
Jody LeCompte
@jodylecompte
Jun 04 2017 00:48
ah, I need to learn more of that stuff
Kenny
@Kennnnnyd
Jun 04 2017 00:48
anyone know why i cant push new elements onto an array in javascript - for example: array = array.push(str.charAt(i)) does not process in a loop
Jody LeCompte
@jodylecompte
Jun 04 2017 00:49
I use Axios for most of my node projects because thats what I Was already using frontend side
and it allowed for promise chaining
alican karalar
@alicankaralar
Jun 04 2017 00:49
let me check what is it
well in this i am required to use the default stuff
Jody LeCompte
@jodylecompte
Jun 04 2017 00:50
I'd try console logging your responses object outside of your arrow function and inside your arrow function
alican karalar
@alicankaralar
Jun 04 2017 00:50
i did
the results were well
Jody LeCompte
@jodylecompte
Jun 04 2017 00:51
So outside the function but inside the for loop, responses is accessible but you get undefined inside arrow function?
alican karalar
@alicankaralar
Jun 04 2017 00:51
inside it shows a responses array with elements, outside empty
its probably undefined but it defines it on the way
on the go*
outside, it is defined as a var, i mean just 1 step out
inside http.get methods’ callback it is defined the way it should be
Jody LeCompte
@jodylecompte
Jun 04 2017 00:53
oh
I think I see it
I think your a variable is the issue
inside your for loop, you declare it using let
alican karalar
@alicankaralar
Jun 04 2017 00:53
oh my god
Jody LeCompte
@jodylecompte
Jun 04 2017 00:53
so it only has block scope for the for loop if Im not mistaken
wouldn't carry over into the arrow function inside that loop
alican karalar
@alicankaralar
Jun 04 2017 00:54
nah nah
its not the issue
i changed it
no effect
Moisés Man
@moigithub
Jun 04 2017 00:56

resp.on('end', () => {
responses.splice(a, 0, sum);
//console.log(responses);

 if (a==process.argv.length - 2 ){
 printAll(responses);
}
     });
 });

};

inside end ....cuz async
alican karalar
@alicankaralar
Jun 04 2017 00:56
let me try @moigithub
this actually works i guess in a sense… moi
@moigithub
it doesn’t work good for async though
Moisés Man
@moigithub
Jun 04 2017 01:02
soo works or dont?? how u did.. show full code
alican karalar
@alicankaralar
Jun 04 2017 01:02
i’ll paste
it doesn’t but at least i can get an response output
Moisés Man
@moigithub
Jun 04 2017 01:02
dont use this var deez = this;
put the url directly on http.get
not sure what value this will have
u can check doing console.log(this)
James Kirby
@JamesKirby17
Jun 04 2017 01:02
var myStr;"FirstLine\n\SecondLine\n\rThirdLine\";
can someone please help me with escape sequences
The firstline \SecondLine\ ThirdLine I have no idea how to do it
alican karalar
@alicankaralar
Jun 04 2017 01:03
var http = require('http');
 var responses = [];
-for (var  a = 0; a < 3 ; a++) {
-    http.get(process.argv[a+2],(resp) => {
2        var sum = "";
-        resp.on('data', (chunk) => {
3            sum += chunk;
3        });
-        resp.on('end', () => {
3            responses.splice(a, 0, sum);
-            if (a === process.argv.length - 2) {
-                (function printAll(array) {
-                    for (var i = 0; i < array.length; i++) {
6                        console.log(array[i]);
6                    }
5                })(responses);
4            }
3        });
2    });
|};
 /*
 var printAll = (array) => {
     for (var i = 0; i < array.length; i++) {
     console.log(array[i]);
     }
 }
 printAll(responses);*/
Moisés Man
@moigithub
Jun 04 2017 01:04
escaped backslashes should be around SecondLine @JamesKirby17
alican karalar
@alicankaralar
Jun 04 2017 01:05
────────────────────────────────────────────────────────────────────────────────

1.  ACTUAL:    "Get a dog up ya turps when as cunning as a prezzy. Mad as a g'day when shazza got us some corker. She'll be right barbie where as cunning as a dunny. Trent from punchy swag no dramas grab us a bog standard. As stands out like dill no dramas as dry as a servo. "
1.  EXPECTED:  "Get a dog up ya turps when as cunning as a prezzy. Mad as a g'day when shazza got us some corker. She'll be right barbie where as cunning as a dunny. Trent from punchy swag no dramas grab us a bog standard. As stands out like dill no dramas as dry as a servo. "

2.  ACTUAL:    "Get a dog up ya turps when as cunning as a prezzy. Mad as a g'day when shazza got us some corker. She'll be right barbie where as cunning as a dunny. Trent from punchy swag no dramas grab us a bog standard. As stands out like dill no dramas as dry as a servo. "
2.  EXPECTED:  "As cunning as a muster bloody as stands out like counter meal. Come a bities bloody she'll be right cark it. "

3.  ACTUAL:    "As cunning as a muster bloody as stands out like counter meal. Come a bities bloody she'll be right cark it. "
3.  EXPECTED:  "She'll be right op shop heaps we're going budgie smugglers. As stands out like yabber how stands out like a lurk. He's got a massive outback no dramas watch out for the cut lunch. "

4.  ACTUAL:    "Get a dog up ya turps when as cunning as a prezzy. Mad as a g'day when shazza got us some corker. She'll be right barbie where as cunning as a dunny. Trent from punchy swag no dramas grab us a bog standard. As stands out like dill no dramas as dry as a servo. "
4.  EXPECTED:  ""

5.  ACTUAL:    "She'll be right op shop heaps we're going budgie smugglers. As stands out like yabber how stands out like a lurk. He's got a massive outback no dramas watch out for the cut lunch. "
5.  EXPECTED:

6.  ACTUAL:    ""
6.  EXPECTED:


────────────────────────────────────────────────────────────────────────────────
this is the result
Moisés Man
@moigithub
Jun 04 2017 01:05
var http = require('http');
 var responses = [];
-for (var  a = 0; a < 3 ; a++) {
-    http.get(process.argv[a+2],(resp) => {
2        var sum = "";
-        resp.on('data', (chunk) => {
3            sum += chunk;
3        });
-        resp.on('end', () => {
3            responses.splice(a, 0, sum);
-            if (a === process.argv.length - 2) {
                       printAll(responses)
4            }
3        });
2    });
|};
-                function printAll(array) {
-                    for (var i = 0; i < array.length; i++) {
6                        console.log(array[i]);
6                    }
5                })
if u put function inside a loop.. everytime it iterates will re-create the function (no good for performance)
alican karalar
@alicankaralar
Jun 04 2017 01:06
right.
also this can’t be the right way
because print all is also a loop
and it doesn’t handle the async
it has to be outside the function
Moisés Man
@moigithub
Jun 04 2017 01:07
why itsa< 3 where that 3 coming from ?
alican karalar
@alicankaralar
Jun 04 2017 01:07
3 is the max argument size
they also test with putting in 4
so that should not return anything
Kien Ngoc Nguyen
@tgsoon2002
Jun 04 2017 01:08
Hi am working on the problem seek and destroy.
the definition function they gave me only take 1 parrameter as array.
Moisés Man
@moigithub
Jun 04 2017 01:08
printall only gets CALLED after ALL ur result gets back @alicankaralar
Kien Ngoc Nguyen
@tgsoon2002
Jun 04 2017 01:08
but when being used. it take in more than 1
anyone idea how to use other parameter?
alican karalar
@alicankaralar
Jun 04 2017 01:09
@moigithub true thats why it has to be outside the main loop
Moisés Man
@moigithub
Jun 04 2017 01:09
but HOW do u know u already got ALL ur results... ??
remember http.get is async
alican karalar
@alicankaralar
Jun 04 2017 01:09
right, i don’t actually,
Moisés Man
@moigithub
Jun 04 2017 01:10
thats why code should be like that :point_up:
unless u use promises
alican karalar
@alicankaralar
Jun 04 2017 01:10
but when i print at “on.end” it doesn’t print the right thing
i guess i have to use promises man
i never used one let me see how does that work
Frank McCroy
@fmccroy
Jun 04 2017 01:11
@tgsoon2002 One of the helpful links on the challenge tells how to convert the arguments into an array, which you can access. The initial array is always at position [0], the rest is after that
alican karalar
@alicankaralar
Jun 04 2017 01:11
or i can set timeout to printall function for like 3 secs to make sure i got all my responses back
lets try that first
Moisés Man
@moigithub
Jun 04 2017 01:11
then isntead if (a === process.argv.length - 2) {
do .. cuz thats the final value of ur for loop
if (a === 3) {
not sure if same value.. but first line i copied fro ur gist
alican karalar
@alicankaralar
Jun 04 2017 01:12
but that only means i am at the 3rd iteration and 3rd response is over - doesn’t mean that first response has ended
therefore it might still print prematurely
Moisés Man
@moigithub
Jun 04 2017 01:13
then create another variable.. and increase it on end..
then u can evaluate this new var to count how many responses u got
alican karalar
@alicankaralar
Jun 04 2017 01:13
thats a better way to do it i believe
@moigithub
i passed the test with this line
setTimeout(printAll.bind(null, responses), 3000);
instead of printAll(responses);
so you were right
i misjudged the problem
thought it was a scope issue which left me scratching my head
Moisés Man
@moigithub
Jun 04 2017 01:16
async is tricky :)
alican karalar
@alicankaralar
Jun 04 2017 01:16
so your method is a better one than setting timeout
let me implement that
hm. doesn’t work yet.
Bob Adams
@Lifelessrva
Jun 04 2017 01:18
I can't figure out the instructions on Quoting Strings with Single Quotes JS
alican karalar
@alicankaralar
Jun 04 2017 01:18
‘just like that’ === string
‘nothing really complicated'
“a” === ‘a'
@Lifelessrva
Bob Adams
@Lifelessrva
Jun 04 2017 01:19
Yeah I get that lol, but it the instructions are kind of confusing.
alican karalar
@alicankaralar
Jun 04 2017 01:19
can you paste a bit
Bob Adams
@Lifelessrva
Jun 04 2017 01:19
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
is the code i need to change
alican karalar
@alicankaralar
Jun 04 2017 01:20
change to what :)
Bob Adams
@Lifelessrva
Jun 04 2017 01:20
Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
Only remove the backslashes \ used to escape quotes
Proconsul
@proconsu1
Jun 04 2017 01:20
@Lifelessrva basically they are trying to show how using single quotes for your entire string lets you use double quotes inside that string without having to escape them
Bob Adams
@Lifelessrva
Jun 04 2017 01:21
That makes a lot more sense than what was typed lol.
alican karalar
@alicankaralar
Jun 04 2017 01:21
yes exactly, you use \ to escape a quote inside a quote
lets assume our string is as follows:
i like “you"
if i wanted to represent this as a string
i had to type
“i like \”you\”"
notice the backslash quote pairs
\"
this represents a single quote inside a string
so when you use single quotes
you can do it this way :
‘i like “you"'
without having to escape
Bob Adams
@Lifelessrva
Jun 04 2017 01:23
var myStr = '<a href=\"http://www.example.com\" target=\"_blank\">Link</a>';
Would that work?
Moisés Man
@moigithub
Jun 04 2017 01:23
Remove all the backslashes \
alican karalar
@alicankaralar
Jun 04 2017 01:23
remove the backslashes that are followed by a quote
Bob Adams
@Lifelessrva
Jun 04 2017 01:24
var myStr = "<a href="http://www.example.com" target="_blank">Link</a>;
alican karalar
@alicankaralar
Jun 04 2017 01:24
correct
but
Bob Adams
@Lifelessrva
Jun 04 2017 01:24
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
Proconsul
@proconsu1
Jun 04 2017 01:24
@Lifelessrva remember, you no longer need to escape double quotes there, but (for future reference) you still need to escape anything else that would normally be escaped in a string
alican karalar
@alicankaralar
Jun 04 2017 01:24
you have to use singles
Moisés Man
@moigithub
Jun 04 2017 01:24
>
You should have two single quotes ' and four double quotes "
alican karalar
@alicankaralar
Jun 04 2017 01:24
ok you have to enclose them inside single quotes
‘ your string here '
Bob Adams
@Lifelessrva
Jun 04 2017 01:26
Do i need to enclose each double quote in a single quote?
Proconsul
@proconsu1
Jun 04 2017 01:26
@Lifelessrva no
alican karalar
@alicankaralar
Jun 04 2017 01:26
no, you have to enclose your string inside your single quote
if your strings contain double quotes, include them as well
lets try another example
let this be our string candidate
Proconsul
@proconsu1
Jun 04 2017 01:27
use single quotes at the ends of the string, and then you can put as many double quotes inside the string as you want and they won't need to be escaped with \
alican karalar
@alicankaralar
Jun 04 2017 01:27
i envy “mustard” a lot
‘ i envy “mustard” a lot'
Bob Adams
@Lifelessrva
Jun 04 2017 01:27
'i envy "mustard" a lot'?
alican karalar
@alicankaralar
Jun 04 2017 01:27
true
so that way you don’t have to escape your double quotes
because if you do it this way “i envy “mustard” a lot”
it will interpret the line between the first two double quotes as a string, and the next two as another
Bob Adams
@Lifelessrva
Jun 04 2017 01:28
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
Is this correct?
alican karalar
@alicankaralar
Jun 04 2017 01:29
not yet
oh
wait
Moisés Man
@moigithub
Jun 04 2017 01:29
click run test button....
if it pass.. then is correct...
alican karalar
@alicankaralar
Jun 04 2017 01:29
it is
Proconsul
@proconsu1
Jun 04 2017 01:29
yep
Bob Adams
@Lifelessrva
Jun 04 2017 01:30
@alicankaralar @proconsu1 Thank you both very much!
CamperBot
@camperbot
Jun 04 2017 01:30
lifelessrva sends brownie points to @alicankaralar and @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 160 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:cookie: 329 | @alicankaralar |http://www.freecodecamp.com/alicankaralar
alican karalar
@alicankaralar
Jun 04 2017 01:30
don’t forget @moigithub :)
Abdallah ElSallal
@Abdallah-Youssef
Jun 04 2017 01:30

help on the challenge check for palindromes
here's my code:

function palindrome(str) {
// Good luck!
str = str.replace(/[^a-z0-9]/g, '');
str = str.replace(/ /g, '');
str = str.toLowerCase();

for (var i = 0; i < str.length / 2;i++)
{
if (str[i] != str[str.length - i])
return false;
}
return true;
}

palindrome("eye");

alican karalar
@alicankaralar
Jun 04 2017 01:31
“anything between two quotes is a string"
thanks @moigithub
CamperBot
@camperbot
Jun 04 2017 01:31
alicankaralar sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3315 | @moigithub |http://www.freecodecamp.com/moigithub
alican karalar
@alicankaralar
Jun 04 2017 01:31
by the way you helped a lot man
but i am still running into problems lol :(
-        resp.on('end', () => {
3            responses.splice(a, 0, sum);
3            endcount++;
-            if (endcount === 3 ) {
4                printAll(responses)
4            }
3        });
Proconsul
@proconsu1
Jun 04 2017 01:34
@Abdallah-Youssef that entire function becomes a lot easier if you start by converting the string to an array. then you can use methods that are not available for strings, like .filter and .reverse
Wisdom Peters
@blackcytographer
Jun 04 2017 01:34

pls someone should help me with this code..... var gear = 0;

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

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

};

var myCar = new Car();

var myBike = new Bike();

Abhilash Kumar
@apravink
Jun 04 2017 01:35
Hey guys
Is there a way in JS to typecast something to an array?. For example : arr = function([1,2,3],'a','b']{ var first_array = arr[0];}
Is there a way to ensure that first_array will inherit all the methods for the Array.prototype?
Wisdom Peters
@blackcytographer
Jun 04 2017 01:36
please i help help with this

var gear = 0;

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

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

};

var myCar = new Car();

var myBike = new Bike();

Proconsul
@proconsu1
Jun 04 2017 01:37
@blackcytographer @apravink what is the name of that challenge?
Abhilash Kumar
@apravink
Jun 04 2017 01:37
@proconsu1 Destroyer
Cesar Fernandez
@Diamond713
Jun 04 2017 01:37
How do you change celsius into fahrenhiet?
Abhilash Kumar
@apravink
Jun 04 2017 01:37
@proconsu1 Sorry "Seek and Destroy"
Wisdom Peters
@blackcytographer
Jun 04 2017 01:37
@proconsu1 make object properties private
https://www.freecodecamp.com/challenges/make-object-properties-private#?solution=%0Avar Car %3D function() {%0A %2F%2F this is a private variable%0A var speed %3D 10%3B%0A%0A %2F%2F these are public methods%0A this.accelerate %3D function(change) {%0A speed %2B%3D change%3B%0A }%3B%0A%0A this.decelerate %3D function() {%0A speed -%3D 5%3B%0A }%3B%0A%0A this.getSpeed %3D function() {%0A return speed%3B%0A }%3B%0A}%3B%0A%0Avar Bike %3D function() {%0A%0A %2F%2F Only change code below this line.%0A var gear %3D 0%3B%0A %0A this.getGear %3D function(change) {%0A gear %3D change%3B%0A }%3B%0A %0A this.setGear %3D function(){%0A return gear%3B%0A }%3B%0A%0A}%3B%0A%0Avar myCar %3D new Car()%3B%0A%0Avar myBike %3D new Bike()%3B%0A
Proconsul
@proconsu1
Jun 04 2017 01:38
@apravink you might consider converting the entire list of arguments into an array and then shifting that inner array, the first argument, out of the resulting arguments array
Frank McCroy
@fmccroy
Jun 04 2017 01:38
@Diamond713 Multiply, etc using the formula given in the challenge.
Abhilash Kumar
@apravink
Jun 04 2017 01:39
@proconsu1 Ill give that a shot
alican karalar
@alicankaralar
Jun 04 2017 01:41
 var http = require('http');
 var responses = [];
 var endcount = 0;
-var printAll = (array) => {
-    for (var i = 0; i < array.length; i++) {
2    console.log(array[i]);
2    }
|}
-for (var  a = 0; a < 3; a++) {
-    http.get(process.argv[a+2],(resp) => {
2        var current = a;
2        var sum = "";
-        resp.on('data', (chunk) => {
3            sum += chunk;
3        });
-        resp.on('end', () => {
3            responses.splice(current, 0, sum);
3            endcount++;
-            if (endcount === 3 ) {
4                printAll(responses)
4            }
3        });
2    });
|};

this works @moigithub

nevermind it doesn'T

Abhilash Kumar
@apravink
Jun 04 2017 01:41
@proconsu1 Doesnt work still
function destroyer(arr) {
  var big_array = arr;
  var arr1 =big_array[0];
  var arr2 = arr1.filter(function(num){
    for (var i=1;i<big_array.length-1;i++){
      if (num != big_array[i]){
        return num;
      }
    }
  });

//   for(var i=1;i<arguments.length-1;i++){
//     var a = arguments[i];
//     arr2 = arr.filter(function(a){
//       console.log(a);
//     });
//   }
  return arr2;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
alican karalar
@alicankaralar
Jun 04 2017 01:42
var http = require('http')
    var bl = require('bl')
    var results = []
    var count = 0

    function printResults () {
      for (var i = 0; i < 3; i++) {
        console.log(results[i])
      }
    }

    function httpGet (index) {
      http.get(process.argv[2 + index], function (response) {
        response.pipe(bl(function (err, data) {
          if (err) {
            return console.error(err)
          }

          results[index] = data.toString()
          count++

          if (count === 3) {
            printResults()
          }
        }))
      })
    }

    for (var i = 0; i < 3; i++) {
      httpGet(i)
    }
this is the official solution @moigithub
Proconsul
@proconsu1
Jun 04 2017 01:42
@apravink well, it was just a hint, not a solution. once you do as I suggested you will then have two arrays: one will be just the initial array you are testing, and the other will all the values you want to check within that first array. then .filter with a certain use of .indexOf should put you over the top
@blackcytographer just a sec
@blackcytographer ok, this one is more less just adapting the code in the example from the car accelerating function for a gear changing function. but since the gear goes directly from one value to another, rather than just having something added or subtracted, you can just use = instead +=. other than that you are just emulating what was done in the top (provided) section of code. now if you want more explanation of what that this business is about. holler.
Wisdom Peters
@blackcytographer
Jun 04 2017 01:46
@proconsu1 thanks my man
CamperBot
@camperbot
Jun 04 2017 01:46
blackcytographer sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 161 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Proconsul
@proconsu1
Jun 04 2017 01:47
@apravink ok, looking over your code now. sec
@apravink first thing that jumps out is that for loop. the .filter method automatically iterates through each value in the source array one at a time. in other words it has a loop function already built in. you just need to provide it with the function you want it to check each iteration. bear in mind, the .filter is only looking for a return of true or false. if true, it keeps the array element it was looking at for that iteration; if false, it discards it
Proconsul
@proconsu1
Jun 04 2017 01:53
@apravink i am willing to give you code that would work, but i am avoiding that because then you might not learn how to adapt these different functions to your own purposes. so i am just trying to nudge to the next step each time
frederickalcantara
@frederickalcantara
Jun 04 2017 01:54
WHo knows about json ajax requests?
Proconsul
@proconsu1
Jun 04 2017 01:54
@frederickalcantara not i. that is all still in my future
frederickalcantara
@frederickalcantara
Jun 04 2017 01:54
ok
Nirab Shrestha
@Nirav11
Jun 04 2017 01:59

function findLongestWord(str,space) {


 var a = str.split(space);
   var maxLength= a[0];
  for (var i=0; i < a.length; i++){


    if (maxLength.length < a[i].length) {
      maxLength = a[i];

    }

  }

   return maxLength.Length;
}
var space = " ";
findLongestWord("The quick brown fox jumped over the lazy dog",space);
can anyone help me with this code
to find the longest length of string
Frank McCroy
@fmccroy
Jun 04 2017 02:00
@Nirav11 Why do Length change cases from length?
*does
Nirab Shrestha
@Nirav11
Jun 04 2017 02:01
@fmccroy THank you :)
CamperBot
@camperbot
Jun 04 2017 02:01
nirav11 sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 330 | @fmccroy |http://www.freecodecamp.com/fmccroy
Frank McCroy
@fmccroy
Jun 04 2017 02:02
@Nirav11 Glad to help
Nirab Shrestha
@Nirav11
Jun 04 2017 02:02
@fmccroy And what are other problem with this code
I still have some problem with it
Frank McCroy
@fmccroy
Jun 04 2017 02:04
@Nirav11 Heh, I was hoping that was all. :) But what is it doing or not doing? I tend to put console.log statements in to see where things are going wrong.
Nirab Shrestha
@Nirav11
Jun 04 2017 02:05
Hehe... it returns 6 for the first case but I still can't pass this test
Frank McCroy
@fmccroy
Jun 04 2017 02:05
What is var maxLength= a[0]; for? The length is inside the array itself?
ahh, maxlength isn’t a number, its the variable holding the longest string
Nirab Shrestha
@Nirav11
Jun 04 2017 02:06
It's just an initialization for comparison with the next string
in an array
frederickalcantara
@frederickalcantara
Jun 04 2017 02:06
Can someone please explain to me why I am unable to get properties from an object to show?
Nirab Shrestha
@Nirav11
Jun 04 2017 02:07
The problem with this code is i used space for the separator but the question asked is I cannot pass a separator
Can you help me to fix this?
Objects are not showing some of the properties
Nirab Shrestha
@Nirav11
Jun 04 2017 02:09
@fmccroy : You there?
Frank McCroy
@fmccroy
Jun 04 2017 02:09
@Nirav11 I don’t understand what you are asking. Space is passed in when the function is called, looking at the test example at the bottom?
mattr12
@mattr12
Jun 04 2017 02:12

Trying to complete "Testing Objects for Properties" -- what is wrong with my code?

```

function checkObj(checkProp) {

  if(myObj.hasOwnProperty("checkProp")){
    var x = myObj[checkProp]; 
    return x; 
  } else { 
    return "Not Found"; 
  }
}
Frank McCroy
@fmccroy
Jun 04 2017 02:13
@Nirav11 Looking at my own code, there is no space variable. My split was just =str.split(“ “); I hard coded in the space
Moisés Man
@moigithub
Jun 04 2017 02:16
:point_up: June 3, 2017 8:41 PMur first code didnt work because a variable.. when ur loop ends will be 3.. and cuz async nature of http.get when callback gets executed ur current variable will be 3 too (thats why told u use let.. which keep context on block scope.. so its value doesnt change per iteration)
on ur second code.. index keep its value cuz its on function scope @alicankaralar
Joseph
@revisualize
Jun 04 2017 02:16
@mattr12 Quotes define strings.
Proconsul
@proconsu1
Jun 04 2017 02:16
@mattr12 "checkProp" - checkProp is an argument, not a string
Joseph
@revisualize
Jun 04 2017 02:16
@mattr12 Should myObj.hasOwnProperty("checkProp") be a string or the parameter?
@proconsu1 checkProp is not an argument. It is a parameter
Proconsul
@proconsu1
Jun 04 2017 02:17
@revisualize yeah, my bad
@mattr12 one minor thing: if you want to tighten that up you don't need the else in there. should the 'if' condition not trip the return of x, then the return of not found will happen with or without the else
Aata-allah
@Atalaa
Jun 04 2017 02:21
Can somebody help me to put quotes between my sentence please ?
https://codepen.io/Atalaa/pen/ZyEEEY
Sam Soucie
@samdsou
Jun 04 2017 02:24
can someone tell me why this doesn't titlecase?
function titleCase(str) {
  str.toLowerCase();
  var strArray = str.split(" ");
  for (var i = 0; i < strArray.length; i++){
    strArray[i][0].toUpperCase();

  }
  str = strArray.join(" ");
  return str;
}

titleCase("I'm a little tea pot");
Joseph
@revisualize
Jun 04 2017 02:26
@samdsou strArray[i][0].toUpperCase();
@samdsou That doesn't mutate the string
@samdsou Even str.toLowerCase(); doesn't mutate the string.
Sam Soucie
@samdsou
Jun 04 2017 02:27
@revisualize why not?
Joseph
@revisualize
Jun 04 2017 02:27
@samdsou Because Strings are Immutable.
Frank McCroy
@fmccroy
Jun 04 2017 02:27
@Atalaa I’ve had a problem with CodePen not liking https links.. couldn’t get an image to show, someone suggested using http and it fixed the problem.
Joseph
@revisualize
Jun 04 2017 02:27
@samdsou If you want to change a string you have to do a re-assigment.
Aata-allah
@Atalaa
Jun 04 2017 02:28
@fmccroy dont get it
Joseph
@revisualize
Jun 04 2017 02:31
@samdsou Do you understand what I'm getting at?
Frank McCroy
@fmccroy
Jun 04 2017 02:31
Try your links without https?Just use http ? Or someone else can give you better help.
Jose Antonio Rivas
@joseantonio
Jun 04 2017 02:31
Greetings folks
Joseph
@revisualize
Jun 04 2017 02:31
Greetings.
Sam Soucie
@samdsou
Jun 04 2017 02:31
@revisualize yes, I'm just trying to figure out how to do that in my code
Joseph
@revisualize
Jun 04 2017 02:31
@samdsou If you want to make str lowercase..
@samdsou You have to reassign the value.
@samdsou str = str.toLowerCase();
Sam Soucie
@samdsou
Jun 04 2017 02:32
@revisualize yep, got that part, I'm just working on strArray part
Joseph
@revisualize
Jun 04 2017 02:33
@samdsou Because strings are immutable.
@samdsou If each array element is a string ... you need to re-assign the string value
@samdsou You can't do
var str = "hello";
str[0] = str[0].toUpperCase();
It doesn't work.
Strings are immutable.
You have to completely reassign the string value.
Sam Soucie
@samdsou
Jun 04 2017 02:35
@revisualize I understand that
now
Joseph
@revisualize
Jun 04 2017 02:37
@samdsou okay. Where are you stuck at?
Sam Soucie
@samdsou
Jun 04 2017 02:38
function titleCase(str) {
  str = str.toLowerCase();
  var strArray = str.split(" ");
  for (var i = 0; i < strArray.length; i++){
    strArray[i][0] = strArray[i][0].toUpperCase();

  }
  str = strArray.join(" ");
  return str;
}

titleCase("I'm a little tea pot");
@revisualize so I'm trying to reassign the toUpperCase value of the array of strings back into the array before joining them
@revisualize I know this doesn't work
Joseph
@revisualize
Jun 04 2017 02:38
@samdsou strArray[i][0] = strArray[i][0].toUpperCase(); ... STRINGS ARE IMMUTABLE.
Sam Soucie
@samdsou
Jun 04 2017 02:39
I thought I could reassign them
Joseph
@revisualize
Jun 04 2017 02:39
@samdsou You can't just re-assign a PART.
You have to reassign the whole thing.
Because strings are immutable.
Sam Soucie
@samdsou
Jun 04 2017 02:39
strArray[0] = strArray[i][0].toUpperCase(); works
Joseph
@revisualize
Jun 04 2017 02:39
@samdsou Show me.
frederickalcantara
@frederickalcantara
Jun 04 2017 02:40
You could join the string into an array and then grab the first string then do your uppercase
Joseph
@revisualize
Jun 04 2017 02:41

@samdsou

var arr = [ "hello" , "world" ];
arr[0] = arr[0][0].toUpperCase();

The arr becomes [ "H" , "world" ]

Sam Soucie
@samdsou
Jun 04 2017 02:43
@revisualize why does strArray[i] = strArray[i][0].toUpperCase(); work (as in the code runs) but then adding strArray [i][0] doesn't?
Dovydas Stirpeika
@Giveback007
Jun 04 2017 02:44
@revisualize hey remember you were helping me out with the tic tac toe game?
well its finished:
https://codepen.io/giveback007/full/YVRONB/
Joseph
@revisualize
Jun 04 2017 02:44
@Giveback007 I wasn't helping you with the Tic Tac Toe Game. I haven't helped anyone with it other than play.
@samdsou What?
Dovydas Stirpeika
@Giveback007
Jun 04 2017 02:45
@revisualize oh I thought you have
Joseph
@revisualize
Jun 04 2017 02:45
@samdsou Look, I really think you need to look at using www.pythontutor.com/javascript.html
@Giveback007 I haven't completed that project. In fact, I haven't completed any project. So, I don't help people with them.
Dovydas Stirpeika
@Giveback007
Jun 04 2017 02:47
sorry
Joseph
@revisualize
Jun 04 2017 02:48
@samdsou I need to see your code where you say: strArray[i] = strArray[i][0].toUpperCase(); works.
@samdsou And I'd like to see a function call.
Sam Soucie
@samdsou
Jun 04 2017 02:49
@revisualize it outputs the first letters of the input string capitalized
Joseph
@revisualize
Jun 04 2017 02:49
@samdsou correct.

@samdsou

var arr = [ "hello" , "world" ];
arr[0] = arr[0][0].toUpperCase();
arrp[1] = arr[1][0].toUpperCase();

The arr becomes [ "H" , "W" ]

If you were to change that...

@samdsou

var arr = [ "hello" , "world" ];
arr[0][0] = arr[0][0].toUpperCase();
arrp[1][0] = arr[1][0].toUpperCase();

This doesn't do anything because the value of arr[0] is a string and you can't mutate the value of a string the way you want to.

@samdsou You have to completely reassign the value of the string if you want to change it.
@samdsou Array's hold a series of elements. Those elements can be Strings, Numbers, Other Array's, Objects ... whatever.
@samdsou You access an array element with the index.
@samdsou If the array element is a string you have to constrain to all of the rules of strings when working with them.
aRtoo
@artoodeeto
Jun 04 2017 02:54
hey guys. i bought a book. and im confused with they sample. of the this. method
Joseph
@revisualize
Jun 04 2017 02:54

@samdsou If you had an array of numbers:

var numArr = [3,5,6];
numArr[0]++;
console.log(numArr);

you'd get the output of [4,5,6]

Pedro Pineda
@pedropda
Jun 04 2017 02:54
Hi! Any idea why my code does not work with the cases at the bottom? It shifts an extra element for those two examples ignoring the if clause. Please help :smile:
function dropElements(arr, func) {
  // Drop them elements.
  var bool = arr.map(func);

  for (var i in bool) {
    console.log(i, bool[i]);
    if (bool[i] === false) {
      arr.shift();
    }
  }
  return arr;
}

dropElements([0, 1, 0, 1], function(n) {return n === 1;});
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;});
aRtoo
@artoodeeto
Jun 04 2017 02:56
hey guys. i bought a book. and im confused with they sample. of the this. method.
see this code is i use this and the object name its still working. my question is when do we use this and the objectName
code:

var hotel = {};

//hotel2
hotel.name = 'test111';
hotel.name = 'Shiwaert';
hotel.rooms= 20;
hotel.booked= 1;
hotel.checkAvailability = function(){
    return this.rooms - this.booked; //book sample this.room - this.booked
};

console.log(hotel.checkAvailability());

//hotel1
hotel.name = 'asdf';
hotel.name = 'Shit';
hotel.rooms= 50;
hotel.booked= 30;
hotel.checkAvailability = function(){
    return hotel.rooms - hotel.booked; //book sample this.room - this.booked
};

console.log(hotel.checkAvailability());
Jody LeCompte
@jodylecompte
Jun 04 2017 02:58
That test case seems bizarre to me
dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1].
If you only return elements that === 1, why on earth would 0 be included in the set?
Am I missing something?
Geof Holbrook
@geofholbrook
Jun 04 2017 03:00
i don't see the "should return" part in the original question ...
it should be [1,1]
as you say
Aata-allah
@Atalaa
Jun 04 2017 03:02
im stuck guys, how do i fix my right quote ?
Click on quote to see it
https://codepen.io/Atalaa/pen/ZyEEEY
Geof Holbrook
@geofholbrook
Jun 04 2017 03:07
@pedropda i get it. shift() just takes an element from the beginning, no matter the value of i
Jody LeCompte
@jodylecompte
Jun 04 2017 03:13
sorry wrong room
for the full joke, see main
Proconsul
@proconsu1
Jun 04 2017 03:16
@geofholbrook but in that case shouldn't it the output array be [0,1]?
Lucas Valadares
@lucasmhv
Jun 04 2017 03:16
hey guys
dumb question here
Proconsul
@proconsu1
Jun 04 2017 03:16
@lucasmhv i'm dumb, so i might be able to answer it
Lucas Valadares
@lucasmhv
Jun 04 2017 03:16

```function nextInLine(arr, item) {
// Your code here
item = arr.splice();
arr += item;
return temp; // Change this line
}

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

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

what i'm doing wrong?
Geof Holbrook
@geofholbrook
Jun 04 2017 03:17
@proconsu1 it is!
Proconsul
@proconsu1
Jun 04 2017 03:17
@geofholbrook i thought he said it was expecting [1,0,1]
Lucas Valadares
@lucasmhv
Jun 04 2017 03:18
oh forget temp that's suposed to be item
Geof Holbrook
@geofholbrook
Jun 04 2017 03:18
@proconsu1 not sure where that came from, from the boolean function we would expect [1,1]
what comes out [0,1]
Proconsul
@proconsu1
Jun 04 2017 03:19
@geofholbrook me either, but's that's what he said
dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1].
Geof Holbrook
@geofholbrook
Jun 04 2017 03:21
huh. the original post has this:

dropElements([0, 1, 0, 1], function(n) {return n === 1;});
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;});
anyway, doesn't matter! shift won't work! :)
i think, splice?
Proconsul
@proconsu1
Jun 04 2017 03:22
yeah, i'd say it looks like a job for .splice
Geof Holbrook
@geofholbrook
Jun 04 2017 03:22
or .filter
Proconsul
@proconsu1
Jun 04 2017 03:28
that's the Drop It challenge, yeah?
Lucas Valadares
@lucasmhv
Jun 04 2017 03:30
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  return arr.splice(0, 1);  // Change this line
}

// Test Setup
var testArr = [4];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
guys this is working but I don't get it
I can't advance
the idea was that the item is included and the first one is returned
this is the Stand in Line lesson from JavaScript basic
help pls
Proconsul
@proconsu1
Jun 04 2017 03:33
@lucasmhv try shift instead of splice
Lucas Valadares
@lucasmhv
Jun 04 2017 03:33
how?
oh
it work, but what I did was getting the same result
Proconsul
@proconsu1
Jun 04 2017 03:34
@lucasmhv from return arr.splice(0, 1); to return arr.shift();
Lucas Valadares
@lucasmhv
Jun 04 2017 03:35
thanks @proconsu1
CamperBot
@camperbot
Jun 04 2017 03:35
lucasmhv sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 163 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Lucas Valadares
@lucasmhv
Jun 04 2017 03:35
I guess splice is not recommended
Proconsul
@proconsu1
Jun 04 2017 03:36
@lucasmhv not exacfly. it doesnt do what was requested.
the instructions said return the element that was removed. splice returns the modified array without the removed element
shift returns the removed element but not the modified array
be alert. a future challenge is going to reverse this on you. you'll think you need to shift, but you want that modified array so you'll really need splice
Lucas Valadares
@lucasmhv
Jun 04 2017 03:39
oh right
splice returns the array
I mean
a array
in the case was a array with one element
got it
johnjest
@johnjest
Jun 04 2017 03:55
Hello what's wrong with this var myStr = "I am a \"double quoted" string inside "double quotes\"." ;
Proconsul
@proconsu1
Jun 04 2017 03:55
what are the instructions?
johnjest
@johnjest
Jun 04 2017 03:55

Instructions
Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes".

Proconsul
@proconsu1
Jun 04 2017 03:55
ahh, nm,, i remember tha tone
@johnjest you need to escape every single quote character except the ones that enclose the entire string. you're missing a couple there
Ken Haduch
@khaduch
Jun 04 2017 03:56
@johnjest - any double quote character between the first and last quotes (which means, all except the first and last quotes) should be preceded by the backslash. Otherwise the interpretation of the string by the javascript processor will be incorrect.
Proconsul
@proconsu1
Jun 04 2017 03:58
var str = "this is an \"example\" of what \"they\" are looking for" -- it would output like this in JS this is an "example" of what "they" are looking for
johnjest
@johnjest
Jun 04 2017 03:59
ok I understood thanks
Joseph
@revisualize
Jun 04 2017 04:20
Hello. How can I help?
frederickalcantara
@frederickalcantara
Jun 04 2017 04:22
how do you turn an empty object into a real object? I have an object that is empty but I know that it is not empty
xp0sr
@xp0sr
Jun 04 2017 04:33
same thing here
Raymond
@Raymondshen
Jun 04 2017 04:34
@xp0sr you on the same question haha?
xp0sr
@xp0sr
Jun 04 2017 04:34
yeah
Joseph
@revisualize
Jun 04 2017 04:42

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

function nextInLine(arr, item) { }

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

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

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

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

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

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

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

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

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

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

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

@xp0sr @Raymondshen
Raymond
@Raymondshen
Jun 04 2017 04:43
@revisualize Thank you
CamperBot
@camperbot
Jun 04 2017 04:43
raymondshen sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4091 | @revisualize |http://www.freecodecamp.com/revisualize
Raymond
@Raymondshen
Jun 04 2017 04:44
This made much more sense.
xp0sr
@xp0sr
Jun 04 2017 04:45
I get the idea but my code doesn't seem to work @revisualize
This message was deleted
Raymond
@Raymondshen
Jun 04 2017 04:49
@xp0sr whats up
@xp0sr I'm still trying to figure it out did you find out how to get it working?
xp0sr
@xp0sr
Jun 04 2017 04:50

@Raymondshen
arr.push(item);
var ary = arr.shift();

return ary;

got it
Raymond
@Raymondshen
Jun 04 2017 04:50
hmmm alright ill try it out
@xp0sr Thanks man! I'ma try and understand what you did there haha.
CamperBot
@camperbot
Jun 04 2017 04:50
raymondshen sends brownie points to @xp0sr :sparkles: :thumbsup: :sparkles:
:cookie: 172 | @xp0sr |http://www.freecodecamp.com/xp0sr
xp0sr
@xp0sr
Jun 04 2017 04:51
haha sure @Raymondshen
Joseph
@revisualize
Jun 04 2017 04:51
@xp0sr You don't need to create a variable just to return the variable.
function myFunc ( ) {
     var thing = "value";
     return thing;
}
Why do that when you can just
function myFunc ( ) {
    return "value";
}
Raymond
@Raymondshen
Jun 04 2017 04:53
how do you embeed these code
o.o
xp0sr
@xp0sr
Jun 04 2017 04:53
first line adds(pushes) 'item' to the array "arr"
second line removes first value in the array and stores it in 'ary'
third line returns the value @Raymondshen
Joseph
@revisualize
Jun 04 2017 04:53
@xp0sr But, why create a random non-descriptive variable?
Raymond
@Raymondshen
Jun 04 2017 04:54
@xp0sr thanks still trying to comprehend what has happen ima see if i can comprehend it
CamperBot
@camperbot
Jun 04 2017 04:54
raymondshen sends brownie points to @xp0sr :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave xp0sr points
xp0sr
@xp0sr
Jun 04 2017 04:54
@revisualize just for the sake of understanding. it doesn't matter
Alexander W. Stevenson
@supernal-android
Jun 04 2017 04:54
Hello
Joseph
@revisualize
Jun 04 2017 04:54
@xp0sr ary is not a descriptive variable name.
might as well call it q
Raymond
@Raymondshen
Jun 04 2017 04:55
@revisualize how do you embed these code to look readable?
Joseph
@revisualize
Jun 04 2017 04:55

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

xp0sr
@xp0sr
Jun 04 2017 04:55
I know. naming is not the first thing on my mind right now haha @revisualize
Raymond
@Raymondshen
Jun 04 2017 04:55
'variable'
Joseph
@revisualize
Jun 04 2017 04:56
@Raymondshen You're using quote
@Raymondshen back tick
@Raymondshen It's up by the 1
Raymond
@Raymondshen
Jun 04 2017 04:56
variable
Joseph
@revisualize
Jun 04 2017 04:56
@xp0sr But why?
Raymond
@Raymondshen
Jun 04 2017 04:56
i see
@revisualize Thanks.
CamperBot
@camperbot
Jun 04 2017 04:56
raymondshen sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave revisualize points
Joseph
@revisualize
Jun 04 2017 04:57

@xp0sr Why do this:

arr.push(item);
var ary = arr.shift();
return ary;

... Instead of ...

arr.push(item);
return arr.shift();
@xp0sr ary is not a descriptive variable.
xp0sr
@xp0sr
Jun 04 2017 04:57
both work. it doesn't matter really. @revisualize
Joseph
@revisualize
Jun 04 2017 04:58
@xp0sr And it doesn't have any significance in your code.
Raymond
@Raymondshen
Jun 04 2017 04:58
@xp0sr still kind of confused because I'm like getting mind f*ked by the fact there is a var testArr = [ 1,2,3,4,5];
Joseph
@revisualize
Jun 04 2017 04:58
@Raymondshen That's just a global variable.
@Raymondshen Ignore it. Just focus on the function.
xp0sr
@xp0sr
Jun 04 2017 04:59
@Raymondshen that's just the array variable that is gonna be used as an argument in your function
Raymond
@Raymondshen
Jun 04 2017 04:59
okay but what about the function you have given
Joseph
@revisualize
Jun 04 2017 04:59
@Raymondshen Look, when you work in the real world you're going to need to work around other code that isn't part of the problem that you're working on.
@Raymondshen Also, In my rewrite of the instructions ... I addressed global variables.
Raymond
@Raymondshen
Jun 04 2017 05:00
like where are those variables being pushed O.o its what im confused on
Joseph
@revisualize
Jun 04 2017 05:00

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

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

Raymond
@Raymondshen
Jun 04 2017 05:01
ahhh i see thanks
Joseph
@revisualize
Jun 04 2017 05:03
I'm going to go back to listening to Elton John.
maakiel
@maakiel
Jun 04 2017 05:05

can someone please help me complete this challenge? Its the counting cards challenge.This is what I have so far: var count = 0;

function cc(card) {
// Only change code below this line
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case 'j':
case 'Q':
case 'K':
case 'A':
count--;
break;
}
if (count > 0) {
return count +" Bet";
} else {
return count + " Hold";
}

// Only change code above this line
}

Ogundele Olumide
@Lumexralph
Jun 04 2017 05:06
@maakiel case 'j': J
Joseph
@revisualize
Jun 04 2017 05:06
@maakiel case 'j': ??
maakiel
@maakiel
Jun 04 2017 05:06
Lol
thanks
Ogundele Olumide
@Lumexralph
Jun 04 2017 05:07
@maakiel :joy:
Md Abu Zafar
@mdaz78
Jun 04 2017 05:11
str = str.replace(/([a-z])([A-Z])/g, '$1 $2');
str = str.replace(/([a-z])([A-Z])/g, '$1 $2’);
can anybody please explain me the above code to me.
Markus Kiili
@Masd925
Jun 04 2017 05:18
@revisualize @Lumexralph Morning.
Raymond
@Raymondshen
Jun 04 2017 05:24

@xp0sr ```js

// Setup
function testEqual(val) {
if (val) { // Change this line
return "Equal";
}
return "Not Equal";
}

// Change this value to test
testEqual(10=="12");
``` did you get this to work?

Jody LeCompte
@jodylecompte
Jun 04 2017 05:24
@mdaz78 Those are regular expressions
Gulsvi
@gulsvi
Jun 04 2017 05:25
Hey.... how do I unencode HTML with javascript?
This: German%e2%80%a2Imperium
Should be: German•Imperium
But when I try using unescape(), it becomes: Germanâ¢Imperium
Md Abu Zafar
@mdaz78
Jun 04 2017 05:25
@jodylecompte I know that but how that, but I am unable to figure out how this particular expression is working
Raymond
@Raymondshen
Jun 04 2017 05:25

// Setup
function testEqual(val) {
  if (val) { // Change this line
    return "Equal";
  }
  return "Not Equal";
}

// Change this value to test
testEqual(10=="12");
kind of need help on making the testEqual(10) should return "Not Equal"
johnjest
@johnjest
Jun 04 2017 05:28

Hello how to solve it
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
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");

ReedGotSpeed
@ReedGotSpeed
Jun 04 2017 05:29
Change the provided string from double to single quotes and remove the escaping.
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
can anyone help me
Raymond
@Raymondshen
Jun 04 2017 05:31
oh i was working on that one earlier
ReedGotSpeed
@ReedGotSpeed
Jun 04 2017 05:31
@Raymondshen you know how to solve this?
Raymond
@Raymondshen
Jun 04 2017 05:32
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
@ReedGotSpeed
Jody LeCompte
@jodylecompte
Jun 04 2017 05:33
@mdaz78 I recommend you check out https://regex101.com/
It has a regex analysis tool to help you both decipher existing patterns and write your own
ReedGotSpeed
@ReedGotSpeed
Jun 04 2017 05:33
@Raymondshen soooo.... you just changed the outside double quotes?
Jody LeCompte
@jodylecompte
Jun 04 2017 05:33
for example, I put in your regex (minus the / and /g because those are suplied automatically by javascript flavor mode) and it idenfies as such
image.png
Sorry I can't provide a bettter explanation than that, regex just doesn't come up much in the sort of work I usually do
johnjest
@johnjest
Jun 04 2017 05:35

Hello friends could you help me out from this
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
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");

Bethany Roberts
@Betanya
Jun 04 2017 05:35
I just can't say enough how much I love the little encouragements after challenges ^^
Jody LeCompte
@jodylecompte
Jun 04 2017 05:36
POWER LEVEL OVER 9000!!!!!!1111111oneone
Bethany Roberts
@Betanya
Jun 04 2017 05:37
@jodylecompte EXACTLY! Hahs
Markus Kiili
@Masd925
Jun 04 2017 05:41
@johnjest Make a long sentence by using the parameters myNoun, myAdjective, myVerb, myAdverb, string operations and perhaps some filler words.
Joseph
@revisualize
Jun 04 2017 05:42

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

Here's an example of this:

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

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

When you have the function declaration of:

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

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

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

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

Raymond
@Raymondshen
Jun 04 2017 05:43
http://bit.ly/2qTz5HH kind of need help on it still
captainshukla
@captainshukla
Jun 04 2017 05:43
Can anyone help me out with this problem? I am supposed to add 3 to every value in the array using .map

var oldArray = [1,2,3,4,5];
var newArray=oldArray.map(function(val){
return val+4;

});

// Only change code below this line.

var newArray = oldArray;

doesnt work though
Joseph
@revisualize
Jun 04 2017 05:43
@captainshukla Why are you overwriting newArray with this line: var newArray = oldArray; ?
Request-Off-Work
@Request-Off-Work
Jun 04 2017 05:44

Does anyone know the best way to structure 'next' and 'previous' content still on the same page? Maybe a JS object?... Really have no idea here.

This is what I'm building: https://codepen.io/TylerL-uxai/pen/QvezdM

captainshukla
@captainshukla
Jun 04 2017 05:45
@Raymondshen replace the 10 with val
It will work
Need any help to understand?
Joseph
@revisualize
Jun 04 2017 05:45
@captainshukla Look:
var oldArray = [1,2,3,4,5];
var newArray=oldArray.map(function(val){
return val+4;
});
console.log(newArray);     // [ 5, 6, 7, 8, 9 ]
// Only change code below this line.
var newArray = oldArray;
console.log(oldArray);     // [1,2,3,4,5]
console.log(newArray);     // [1,2,3,4,5]
Raymond
@Raymondshen
Jun 04 2017 05:45
@captainshukla alright hold on gonan try and see if it works.
@captainshukla I get it thanks man
CamperBot
@camperbot
Jun 04 2017 05:46
:warning: @captainshukla's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
raymondshen sends brownie points to @captainshukla :sparkles: :thumbsup: :sparkles:
Raymond
@Raymondshen
Jun 04 2017 05:46
@captainshukla didn't think of it
Joseph
@revisualize
Jun 04 2017 05:53
@captainshukla Did that help?
kind of confused how to combine both results to show up.

function testElse(val) {
  var result = "";
  // Only change code below this line

  if (val <= 5 && val > 5) {
    result = "5 or Smaller";
  }
  else{
     result = "Bigger than 5";
  }

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

// Change this value to test
testElse(4);
kirontoo
@kirontoo
Jun 04 2017 06:17

hey guys a little help?
```
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < 4; i += 1){
if(firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)){

  return contacts[i][prop];

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

}
// Only change code above this line
}

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

Joseph
@revisualize
Jun 04 2017 06:18
@kirontoo Okay.
@kirontoo Can I break something down for you?
kirontoo
@kirontoo
Jun 04 2017 06:18
sure
Joseph
@revisualize
Jun 04 2017 06:18
@kirontoo Let's make a smaller for loop. Okay?

@kirontoo

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

Can you kind of walk through what happens in this code.. one line at a time. And just type out your thoughts into chat?
@kirontoo

Hemant Kumar
@rareh21
Jun 04 2017 06:22
little bit confusion in escape sequence in strings
Joseph
@revisualize
Jun 04 2017 06:22
@kirontoo Side note: There's actually several things wrong with your code. But, I'm going from top down.
@rareh21 What code do you have?
Hemant Kumar
@rareh21
Jun 04 2017 06:22
initially there is nothing
Raymond
@Raymondshen
Jun 04 2017 06:23

function testElse(val) {
  var result = "";
  // Only change code below this line


  if (val <= 5 && val > 5) {
    result = "5 or Smaller";
  }else{
    result = "Bigger than 5";
  }

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

// Change this value to test
testElse(4);
@revisualize do you know whats wrong? cause I'm trying to print out both answer but for what I have rn only prints out one answer.
Joseph
@revisualize
Jun 04 2017 06:23
@Raymondshen How can a value be less than equal to 5 ... AND ... value greater than 5
Hemant Kumar
@rareh21
Jun 04 2017 06:23
i have to print
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Joseph
@revisualize
Jun 04 2017 06:24
@rareh21 You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline?
How do you escape a backslash?
How do you escape a carriage-return?
Raymond
@Raymondshen
Jun 04 2017 06:24
@revisualize it was the default setting.
Muhammad Hussain
@ReactorboY
Jun 04 2017 06:24
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var filtered =  arr.filter(function (el) {
    if(typeof(el) === Boolean)
      return false;
    else
      return true;
  })

  return filtered;
}

console.log(bouncer([7, "ate", "", false, 9]));
what's wrong in it ?
Hemant Kumar
@rareh21
Jun 04 2017 06:25
how sir?
Joseph
@revisualize
Jun 04 2017 06:25
@Raymondshen Okay.
@Raymondshen I just re-solved it.
Markus Kiili
@Masd925
Jun 04 2017 06:26
@ReactorboY You are not supposed to filter Boolean values. You are supposed to filter truthy values.
Muhammad Hussain
@ReactorboY
Jun 04 2017 06:26
like ?
Ayush Mahajan
@ay2306
Jun 04 2017 06:26
Hey guys can you share your Random Quote machine freeCodeCamp project. I am getting very confused about using JSON. Would appreciate it... Thank you...
Please tag in me as well in the message in which you share the link
Joseph
@revisualize
Jun 04 2017 06:27
@Raymondshen I think you should really reset the challenge and look at it again.
Markus Kiili
@Masd925
Jun 04 2017 06:27
@ReactorboY For example a simple if(el){...} test whether the looped arr element el is truthy.
Raymond
@Raymondshen
Jun 04 2017 06:27
@revisualize alright.
Muhammad Hussain
@ReactorboY
Jun 04 2017 06:27
filter() calls a provided callback function once for each element in an array, and constructs a new array of all the values for which callback returns a value that coerces to true
Joseph
@revisualize
Jun 04 2017 06:27
@Raymondshen I solved the challenge by just changing line 10.
Raymond
@Raymondshen
Jun 04 2017 06:28
@revisualize ahhh thanks for the hint!
CamperBot
@camperbot
Jun 04 2017 06:28
raymondshen sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4092 | @revisualize |http://www.freecodecamp.com/revisualize
Markus Kiili
@Masd925
Jun 04 2017 06:28
@ReactorboY From that you can see that filter automatically does the coercion and you could solve it even more simply.
Muhammad Hussain
@ReactorboY
Jun 04 2017 06:29
@Masd925 thnx
CamperBot
@camperbot
Jun 04 2017 06:29
reactorboy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4192 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
Jun 04 2017 06:30
Okay, I'm going to go back to this youtube video of a guy making an axe.
Raymond
@Raymondshen
Jun 04 2017 06:31
@revisualize lmao okay! thanks alot once again!
CamperBot
@camperbot
Jun 04 2017 06:31
raymondshen sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave revisualize points
Joseph
@revisualize
Jun 04 2017 06:33
Joseph
@revisualize
Jun 04 2017 06:42
@Masd925 It's interesting watching a Swedish guy make a Viking Axe.
Markus Kiili
@Masd925
Jun 04 2017 06:43
@revisualize We do that stuff a lot here. I just smelted some lead couple of months ago.
Joseph
@revisualize
Jun 04 2017 06:44
@Masd925 I just watched this video: Blacksmithing - Forging a bearded axe by Torbjörn Åhman
Markus Kiili
@Masd925
Jun 04 2017 06:45
@revisualize Doing a career change?
Joseph
@revisualize
Jun 04 2017 06:45
@Masd925 I'd like to.
@Masd925 Fuck IT... This shit sucks.
Aakriti
@Aakriti94
Jun 04 2017 06:52
i have a pen: https://codepen.io/aakriti_1012/pen/owNQPE
i have assigned slide 5 to home2
when we click to home2 it jumps to slide 5
but i can only drag in right to slide 6, 7, 8.. but not to left slide 4,3... after the click on home2
why so?
rugano
@rugano
Jun 04 2017 07:01
Hello campers, can someone correct me in this link that i want to use for my twitch tv app here: https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.1
Joseph
@revisualize
Jun 04 2017 07:02
barry01000010
@barry01000010
Jun 04 2017 07:14
anyone heard this this site??? https://www.pluralsight.com/
rugano
@rugano
Jun 04 2017 07:14
@revisualize thanks
CamperBot
@camperbot
Jun 04 2017 07:14
rugano sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4093 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 04 2017 07:15
@barry01000010 I have.
@barry01000010 My boss even pays for a subscription.
barry01000010
@barry01000010
Jun 04 2017 07:15
@revisualize you used it then hmmm
ok, I went to a web dev company and they recommended it
@revisualize so you are front,end or full stack
Joseph
@revisualize
Jun 04 2017 07:16
@barry01000010 Neither.
barry01000010
@barry01000010
Jun 04 2017 07:16
hmm what?
programmer?
Raymond
@Raymondshen
Jun 04 2017 07:16
http://bit.ly/2qMy05j not sure why I'm wrong..
Joseph
@revisualize
Jun 04 2017 07:17
@barry01000010 I'm not a developer.
Raymond
@Raymondshen
Jun 04 2017 07:17

function golfScore(par, strokes) {
  // Only change code below this line
  if (par < 6 && strokes < 5) {
    return "Hole-in-one";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Joseph
@revisualize
Jun 04 2017 07:17
@Raymondshen I'm not sure either. Because that link doesn't work.
@Raymondshen That isn't correct at all.
barry01000010
@barry01000010
Jun 04 2017 07:17
what are you man....?? , are you even human??? :laughing:
well thanks all the same , who ever you are or what ever you are..... :wink:
Raymond
@Raymondshen
Jun 04 2017 07:18
@revisualize why? i thought par=5
Joseph
@revisualize
Jun 04 2017 07:18
@barry01000010 I'm a Senior Network Systems Administrator working with Healthcare IT Systems. I manage the network infrastructure for over one million square foot campus.
Raymond
@Raymondshen
Jun 04 2017 07:18
so if 5 <6
barry01000010
@barry01000010
Jun 04 2017 07:19
I bow down to you, you are a god!! :clap:
Joseph
@revisualize
Jun 04 2017 07:19
@Raymondshen You really need to re-read the instructions.
Raymond
@Raymondshen
Jun 04 2017 07:19
@revisualize okay.
Joseph
@revisualize
Jun 04 2017 07:20
@Raymondshen Your return values need to be exact by the way. What you have isn't correct.
barry01000010
@barry01000010
Jun 04 2017 07:20
ok well back off to coding !! farewell all my fellow coders and a like :sparkles:
Joseph
@revisualize
Jun 04 2017 07:20
@barry01000010 Meh. I'd like to get laid off.
Raymond
@Raymondshen
Jun 04 2017 07:20
@revisualize ahh i see got it
barry01000010
@barry01000010
Jun 04 2017 07:20
@revisualize oh shit! wasssup wid dat!
Joseph
@revisualize
Jun 04 2017 07:20
@Raymondshen But, even for that return statement your if condition is incorrect.
Raymond
@Raymondshen
Jun 04 2017 07:21
@revisualize hmmm okay let me think about it again.
Joseph
@revisualize
Jun 04 2017 07:21
@barry01000010 Sometimes... You need a change and the opportunity to make that change.
barry01000010
@barry01000010
Jun 04 2017 07:21
so many lives depend on you ..
Joseph
@revisualize
Jun 04 2017 07:21
@barry01000010 ummm... fuck'em.
Raymond
@Raymondshen
Jun 04 2017 07:22
heres the link to it btw http://bit.ly/2qTZAwx
barry01000010
@barry01000010
Jun 04 2017 07:22
well, i get that too. haha. I have recently changed career path, not easy but finally got there
Raymond
@Raymondshen
Jun 04 2017 07:22
@revisualize The answers have given the parameters so im not quite sure if i were to utilize those parameters or am i suppose to use the table .
barry01000010
@barry01000010
Jun 04 2017 07:23
peace out bitches!! (you know I love you babes)
Joseph
@revisualize
Jun 04 2017 07:25
@Raymondshen Do you know what parameters are?
Raymond
@Raymondshen
Jun 04 2017 07:26
is it the functions argument
Joseph
@revisualize
Jun 04 2017 07:26
@Raymondshen What are arguments?
Raymond
@Raymondshen
Jun 04 2017 07:26
their like variables
Joseph
@revisualize
Jun 04 2017 07:26
@Raymondshen Incorrect.
Raymond
@Raymondshen
Jun 04 2017 07:27
gah let me do some research and take notes on it
Joseph
@revisualize
Jun 04 2017 07:27

If I have this code:

function addThree (num) { }

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
...
If you then make another function call..

addThree(39);

When we do addThree(39) then the value of the parameter num is passed the argument value of ... 39

If you make the function call of addThree(21) the value of num inside the function is 21.
If you make the function call of addThree(1000) the value of num inside the function is 1000.
If you make the function call of addThree(123456) the value of num inside the function is 123456.

@Raymondshen For the example code above.
@Raymondshen The parameter is num
Raymond
@Raymondshen
Jun 04 2017 07:28
Thank you, sorry I'm very new to programming and coding still.
Joseph
@revisualize
Jun 04 2017 07:28
@Raymondshen When you call the function... addThree(42); the argument is the value in the ( )
An-mode
@an-mode
Jun 04 2017 07:29
function palindrome(str) {
str=str.toLowerCase();
var stringArr=str.split("");
var trueLength=stringArr.length;
for(i=0;(i<Math.floor(trueLength/2));i++){
if((stringArr[i])!==(stringArr[(trueLength-i-1)])){
return "Not a palindrome";
}
}
return true;
}
palindrome("eye");
Joseph
@revisualize
Jun 04 2017 07:29
@Raymondshen So, if you have: function golfScore(par, strokes) { } ... You have a function name of golfScore with two parameters par and strokes.
Raymond
@Raymondshen
Jun 04 2017 07:30
@revisualize yes I understand.
An-mode
@an-mode
Jun 04 2017 07:30
In the code I was trying to figure out if the string is a palindrome
Joseph
@revisualize
Jun 04 2017 07:30
@Raymondshen You use par and strokes in your function just like variables.
Raymond
@Raymondshen
Jun 04 2017 07:30
@revisualize yes thats what I'm envisioning of it but am i wrong.
Joseph
@revisualize
Jun 04 2017 07:31
@Raymondshen In golf how many strokes to get a hole in one?
Raymond
@Raymondshen
Jun 04 2017 07:31
1
An-mode
@an-mode
Jun 04 2017 07:31
But the program expects me to return true on inputs like _eye, white spaces, , etc
Joseph
@revisualize
Jun 04 2017 07:31
@Raymondshen So if strokes equals 1 ... you get a hole in one?
@an-mode That's because you're not removing any of the non-alphanumeric characters.
Raymond
@Raymondshen
Jun 04 2017 07:32
yeah
Joseph
@revisualize
Jun 04 2017 07:32
@Raymondshen How would you write that with javascript?
Raymond
@Raymondshen
Jun 04 2017 07:32
hmmm so if the function golfScor(par,strokes)
An-mode
@an-mode
Jun 04 2017 07:33
would I need to use a filter function?
Raymond
@Raymondshen
Jun 04 2017 07:33
and is golfScore(5,1)?
Joseph
@revisualize
Jun 04 2017 07:33
@an-mode Re-read the instructions.
Raymond
@Raymondshen
Jun 04 2017 07:33
cause the golfscore(5=par , 1=stroke)?
Joseph
@revisualize
Jun 04 2017 07:33
@Raymondshen Sure. But, that isn't an if.
Jasper
@Jasperaine
Jun 04 2017 07:34
Please could somebody take a look at my weather app! I cant get the data from the dark sky API to show in my HTML. would be very grateful to anybody who can help at all. https://codepen.io/Jasperaine/pen/ZKZgPb
Raymond
@Raymondshen
Jun 04 2017 07:34
@revisualize I see hmmm let me think about it again
Joseph
@revisualize
Jun 04 2017 07:35
We have many official chat rooms for hanging out and getting help. Here’s the list: http://forum.freecodecamp.com/t/free-code-camp-official-chat-rooms
@Raymondshen Do you sail?
Raymond
@Raymondshen
Jun 04 2017 07:35
@revisualize nope i dont really go out much haha.
function golfScore(par, strokes) {
  // Only change code below this line
  if (par <= 4 && strokes >= 1) {
    return "Hole-in-one!";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(3, 1);
Joseph
@revisualize
Jun 04 2017 07:36
@Raymondshen Ummm.
No.
Raymond
@Raymondshen
Jun 04 2017 07:37
x.x
Joseph
@revisualize
Jun 04 2017 07:37
@Raymondshen So if strokes equals 1 ... you get a hole in one?
@Raymondshen Is PAR anywhere in that statement?
Raymond
@Raymondshen
Jun 04 2017 07:37
no
Joseph
@revisualize
Jun 04 2017 07:37
@Raymondshen Then why is it in your if condition?
Raymond
@Raymondshen
Jun 04 2017 07:37
OHHHH
let me see
kay I GET IT
Joseph
@revisualize
Jun 04 2017 07:38
12885721_10155348507566959_36532751687551016_o.jpg
Raymond
@Raymondshen
Jun 04 2017 07:38
yeah im pretty stupid.. i understand now... I'm sorry
Joseph
@revisualize
Jun 04 2017 07:38
@Raymondshen That's me running mast.
Raymond
@Raymondshen
Jun 04 2017 07:38
cool man!
where you from?
if you dont mind me asking
Joseph
@revisualize
Jun 04 2017 07:42
@Raymondshen Hover over my picture.
Raymond
@Raymondshen
Jun 04 2017 07:42
ahh i see
I'm from SF haha.

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes <= 5) {
    return "Hole-in-one!";
  } 

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
@revisualize
?
Raymond
@Raymondshen
Jun 04 2017 07:48
@revisualize ahhh nvm i got it now thanks for the help though ima head off hope you have a great day!
CamperBot
@camperbot
Jun 04 2017 07:48
raymondshen sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4094 | @revisualize |http://www.freecodecamp.com/revisualize
Anshul Adlakha
@anshuladlakha
Jun 04 2017 07:51
var convertToRoman = function(num) {

  var decimalValue = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];
  var romanNumeral = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];

  var romanized = '';

  for (var index = 0; index < decimalValue.length; index++) {
    while (decimalValue[index] <= num) {
      romanized += romanNumeral[index];// I dont get this part
      num -= decimalValue[index];// and this part too
    }
  }

  return romanized;
}
Can anyone explain this code to me?
alican karalar
@alicankaralar
Jun 04 2017 07:56

:point_up: June 3, 2017 8:41 PMur first code didnt work because a variable.. when ur loop ends will be 3.. and cuz async nature of http.get when callback gets executed ur current variable will be 3 too (thats why told u use let.. which keep context on block scope.. so its value doesnt change per iteration)
on ur second code.. index keep its value cuz its on function scope @alicankaralar

yes man as you said async is tricky lol

Joseph
@revisualize
Jun 04 2017 07:56
tpondant
@tpondant
Jun 04 2017 07:57
@tpondant
Hello everyone, I have a problem with last advanced front-end project, the Simon game.
The problem is that, when it's supposed to highlight all colors already in the array, it does at the same time so the user does not see which one is first and which one is last
could someone help me out with that?
alican karalar
@alicankaralar
Jun 04 2017 07:58
@tpondant
use setTimeout for each highlight
and when you have an array of colors to highlight you can use this logic for timeout
for (var i =0 ; i < array.length ; i++) {
    setTimeout(highlightColor, i * 500)
}
Chris
@chrisfrisss
Jun 04 2017 08:02
good morning, campers!
alican karalar
@alicankaralar
Jun 04 2017 08:02
so it sets timeout values iteratively, highlighting them in a succession
Chris
@chrisfrisss
Jun 04 2017 08:03
I'm having an issue with the "repeat a string" challage.
This is what I've got and it's paasinfg all the right answer's but it does'nt accept my coding somehow. Can anyone take a look at it please
```
var x = "";
function repeatStringNumTimes(str, num) {
  for (var i =0; i < num; i++){
    x += str;
  }
  return x;
}

repeatStringNumTimes("*", -8);
Joseph
@revisualize
Jun 04 2017 08:06
@chrisfrisss Global variables are not reset with freeCodeCamp
Chris
@chrisfrisss
Jun 04 2017 08:07
ok thx I'll have a throw at it
Vedant Kashyap
@vedant15188
Jun 04 2017 08:08
Hey guys im stuck in Smallest Common Multiple Challenge... Could someone tell me where I am going wrong?
function lcm(a,b) {
  var k=a;
  while (b) {
    var t=b;
    b=a%b; 
    a=t;
  }
  return k*b/a;
}

function smallestCommons(arr) {
  var array=[];
  for (var i=arr[0]+1; i<arr[1]; i++) {
    array.push(i);
  }
  return array.reduce(lcm);
}


smallestCommons([1,5]);
Joseph
@revisualize
Jun 04 2017 08:08
@chrisfrisss So, if you make the function call repeatStringNumTimes("a", 4); the value of x stays as "aaaa" on the next function run.
@chrisfrisss just move x into your function.
Marcus Ervin
@maverick01552
Jun 04 2017 08:08
Hi. How do I post code snippets for help?
Joseph
@revisualize
Jun 04 2017 08:09

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

Chris
@chrisfrisss
Jun 04 2017 08:09
Thx Joseph, That did the trick!
Marcus Ervin
@maverick01552
Jun 04 2017 08:09
Thanks Joseph :D
Joseph
@revisualize
Jun 04 2017 08:10
@chrisfrisss You're welcome.
@maverick01552 You're also welcome.
codebook92
@codebook92
Jun 04 2017 08:13
what to do in stand in line task
Marcus Ervin
@maverick01552
Jun 04 2017 08:14
test
Yay now to post lol :)
tpondant
@tpondant
Jun 04 2017 08:15
@alicankaralar thanks, I'll try and do that. Just one thing, I don't understand why you multiply i * 500, why not leave it as 500?
CamperBot
@camperbot
Jun 04 2017 08:15
tpondant sends brownie points to @alicankaralar :sparkles: :thumbsup: :sparkles:
:cookie: 330 | @alicankaralar |http://www.freecodecamp.com/alicankaralar
Marcus Ervin
@maverick01552
Jun 04 2017 08:17

var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      count++;
      break;
  }

  if (count <= 0){
    return count + " Hold";
  } else {
    return count + " Bet";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
I can't seem to figure out why keep getting "2 Bet" instead of "5 Bet". It's the Counting Cards function.
alican karalar
@alicankaralar
Jun 04 2017 08:21
@tpondant if you leave it at 500, then it will highlight all the colors after 500 ms
Marcus Ervin
@maverick01552
Jun 04 2017 08:21
Nevermind I fixed it. haha :)
alican karalar
@alicankaralar
Jun 04 2017 08:21
by adding a 500 ms at each iteration you have a delay of 500ms between each highlight
so your highlight function should also handle the lights turning off under your desired delay value (500 in our case) @tpondant
Marcus Ervin
@maverick01552
Jun 04 2017 08:22

var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count--;
      break;
  }

  if (count <= 0){
    return count + " Hold";
  } else {
    return count + " Bet";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Sometimes you just gotta clear it out and start at the first step. It's funny how simple it gets if you just calm down and breathe. lol
liuxiaoping
@stronglxp
Jun 04 2017 08:26

对象和字典一样,可以用来存储键/值对。如果你的数据跟对象一样,你可以用对象来查找你想要的值,而不是使用switch或if/else语句。当你知道你的输入数据在某个范围时,这种查找方式极为有效。

这是简单的反向字母表:

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"

任务

把switch语句转化为一个叫做lookup的对象。

tpondant
@tpondant
Jun 04 2017 08:28
@alicankaralar ok I tried to do as you said, but it still isn't working. What did I do wrong?
alican karalar
@alicankaralar
Jun 04 2017 08:29
@tpondant this looks a bit complicated buddy
i’d say structurewise
you need a higlight function that works with a number as an argument, and takes another argument that is a variable for i maybe
such as
tpondant
@tpondant
Jun 04 2017 08:34
but since the function depends on the color (to highlight red for example I need to addClass('lightRed')), does it mean I have to change the way I highlight the colors?
alican karalar
@alicankaralar
Jun 04 2017 08:37
@tpondant
function highlight (num, itr) {
     document.getElementById(num).style.brightness = 100%;
     setTimeout(function (itr) {
          document.getElementById(num).style.brightness = 60%;
           }, itr * 350);
//the array contains a sequence of numbers each correspond to 
//a color
for (var  i = 0; i < array.length; i++) {
//set Timeout doesn’t get arguments for passed in functions //unless you “.bind” them, check docs for more info
    setTimeout(highlight.bind(null, array[i], i), i * 500);
}

but since the function depends on the color (to highlight red for example I need to addClass('lightRed')), does it mean I have to change the way I highlight the colors?

maybe. check above code

DevGor
@DevGor16
Jun 04 2017 08:38

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

return item; // Change this line
}

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

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

can anyone help me with this one? i need to add a number to the end of an array , remove the first element and return the value of that first element
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 08:41
@DevGor16 You have to use two array methods. Push and Shift.
mrszop
@mrszop
Jun 04 2017 08:42
Hey guys. I have some troubles getting "Profile Lookup" right. My first idea was to iterate through an array of objects and match the property which I was looking for in the lookUpProfile function to get a result set of all firstName properties, but it gives me more (Akira, Akira,Harry,Akira) results back than I was actually expecting:
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    }
];

function lookUpProfile(firstName, prop){
  for (var i = 0; i < contacts.length; i++) {
    if(contacts[i].firstName === firstName) {
      console.log(contacts[i].firstName);
    }
  }
}

lookUpProfile("Akira", "likes");
Jasper
@Jasperaine
Jun 04 2017 08:43
Please could somebody take a look at my weather app! I cant get the data from the dark sky API to show in my HTML. would be very grateful to anybody who can help at all. https://codepen.io/Jasperaine/pen/ZKZgPb
Pieter Stokkink
@forkerino
Jun 04 2017 08:50
@mrszop I don't see why this code would output so many names, except maybe because of the tests running the function multiple times?
mrszop
@mrszop
Jun 04 2017 08:51
Hm strange, this is what I get in my Chrome Console Log
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 08:52
@mrszop This is because fcc runs all the tests you can see on the left.
mrszop
@mrszop
Jun 04 2017 08:52
Ah
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 08:52
@mrszop So you should return it, then you would see that in that little window.
mrszop
@mrszop
Jun 04 2017 08:52
That makes perfect sense
Damn. Sorry for bothering and thanks for clarifying-.-
Pieter Stokkink
@forkerino
Jun 04 2017 08:54
@Jasperaine There are some issues with the way you close your functions. Click the red :exclamation: in the code window and you'll see an error. After fixing it, you'll get another error in your browser console.... You seemed to have misnamed one of your parameters.
Abhinav Mishra
@abhinav-m
Jun 04 2017 08:57
@forkerino Hello.
can you help me out with something
https://codepen.io/abhinavthinktank/pen/yXLGRP This is my minesweeper app i've made for self learning
Caleb David
@microworlds
Jun 04 2017 08:57
Hello there, I using multer express js for file uploads, but the uploaded files are stored on the server, I want to store them in Mongodb, what's the best way to do that please?
Abhinav Mishra
@abhinav-m
Jun 04 2017 08:57
2 things ->
i want the <td> elements not to have gaps between them
i want my buttons not to expand on click. (Im setting their font size to initial on click , earlier they were 0. Im stuck on this
Can someone help me out
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:00
@abhinav-thinktank
table{
  border-spacing: 0;
}
Caleb David
@microworlds
Jun 04 2017 09:00
Hello there, I am using multer with express js for file uploads, but the uploaded files are stored on the server, I want to store them in Mongodb instead, what's the best way to save and retrieve them from Mongodb? ?
_
Kriis1
@Kriis1
Jun 04 2017 09:01
The value of remainder should be 2
You should use the % operator
var remainder = 11 % 3 = 2;
help me please))
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:01
@Kriis1 Remove the 2 on the end!
var remainder = 11 % 3;
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:02
@ivancsicsmarkus Hello, that almost solves the problem
theres still a tiny bit of gap left, is that possible to be removed? i guess it's the border fo the button itself
Kriis1
@Kriis1
Jun 04 2017 09:02
@ivancsicsmarkus thanks a lot!
CamperBot
@camperbot
Jun 04 2017 09:02
kriis1 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 569 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:03
@abhinav-thinktank Yes, it is because the borders.
@abhinav-thinktank Not the table.
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:04
@ivancsicsmarkus You have any idea how i can stop my the sizes from changing on click
@ivancsicsmarkus Im changing the font size inside to display a number, before click->0 after click -> inherit
Pieter Stokkink
@forkerino
Jun 04 2017 09:05
@abhinav-thinktank you have some padding on the td, which causes some empty space around the buttons
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:05
@forkerino ok , ill try and remove that
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:05
@abhinav-thinktank You should set font-size: 16px always, but make the color of the text transparent!
@abhinav-thinktank Onclick add a color black!
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:06
@ivancsicsmarkus oooh, that sounds neat.
@ivancsicsmarkus ill try that too. thanks @forkerino @ivancsicsmarkus
CamperBot
@camperbot
Jun 04 2017 09:06
abhinav-thinktank sends brownie points to @ivancsicsmarkus and @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2418 | @forkerino |http://www.freecodecamp.com/forkerino
:cookie: 570 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Caleb David
@microworlds
Jun 04 2017 09:06
Hello there, I am using multer with express js for file uploads, but the uploaded files are stored on the server, I want to store them in Mongodb instead, what's the best way to save and retrieve them from Mongodb? ?
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:09
@microworlds It is not a good practice but you can use mongo to store files.
@microworlds You need the built-in fs module to encode it.
Pieter Stokkink
@forkerino
Jun 04 2017 09:10
@microworlds if your files are larger than 16mb you might need GridFS
'cause 16mb is the largest document size in mongo
but smaller files you can just encode in the BSON you write to the db
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:12
@forkerino @forkerino nice, that worked! One last thing that i need to do is give the buttons a "depressed" look as if they have focus. Any hints on how i can achieve this
@ivancsicsmarkus ^
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:14
@abhinav-thinktank What do you mean „focus”?
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:14
@ivancsicsmarkus if you click on a button on my sample , it will get "pressed" , i want to do that for all the elements that are currently revealed on the board
@ivancsicsmarkus i am using the focus property of an element to do that
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:16
@abhinav-thinktank You should add a class to the revealed ones.
I don’t want to read all your js now.
But it is probably possible.
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:16
@ivancsicsmarkus yeah i can do that,
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:17
@abhinav-thinktank okey, with css you can style that class of course
Caleb David
@microworlds
Jun 04 2017 09:17
@forkerino thank you for that response. But is it a good idea to just leave the uploaded files in the "uploads" folder of my server code since I'm intending to store files of less than 200kb to the db
CamperBot
@camperbot
Jun 04 2017 09:17
microworlds sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2419 | @forkerino |http://www.freecodecamp.com/forkerino
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:17
@ivancsicsmarkus yeah thats easy, what is the property i change to give the button a 'pressed' look, i cant find that
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:19
@abhinav-thinktank just replace yourClass!
button:focus, button.yourClass {
  background: #e0e0e0;
  outline: none;
  -webkit-box-shadow: inset 0px 0px 4px #ccc;
     -moz-box-shadow: inset 0px 0px 4px #ccc;
          box-shadow: inset 0px 0px 4px #ccc;
}
Pervinan
@Pervinan
Jun 04 2017 09:19
hey guys, I am very new to JS but I am having so much trouble with it
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:19
@Pervinan Hello, it is normal. Javascript is never easy for beginners.
Pervinan
@Pervinan
Jun 04 2017 09:20
What would you guys suggest to ease things at free code camp
Certain things are simple but I feel like I need somemthing visual to help me figure it out
Abhinav Mishra
@abhinav-m
Jun 04 2017 09:20
@ivancsicsmarkus oh allright, ill try that. im not that familiar with css thanks again.
CamperBot
@camperbot
Jun 04 2017 09:20
abhinav-thinktank sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:warning: abhinav-thinktank already gave ivancsicsmarkus points
Pervinan
@Pervinan
Jun 04 2017 09:21
Thank you, I will check it out now
Pieter Stokkink
@forkerino
Jun 04 2017 09:23
@microworlds I guess storing it in one place is enough for most applications (of course if it is something that requires a backup it's a different story). I like to keep things clean, so not have old files on my server too much.
mixa1901
@mixa1901
Jun 04 2017 09:25
Hi guys ... how can i upgrade my code with for loop ??? i cant get how
https://codepen.io/mixa1901/pen/yXBJKV?editors=1111
Markus Ivancsics
@ivancsicsmarkus
Jun 04 2017 09:29
@mixa1901 Something like:
for (var i = 1; i <= 10; i++) {
    $("#info"+i).html(wiki[2][i-1]);
    $("#main"+i).html(wiki[1][i]);
 }
Caleb David
@microworlds
Jun 04 2017 09:29
@forkerino so if you were to store users' profile pictures of less than 200kb using multer and express, where would you store them up? Server or Mongodb. Sorry please, I want to get it straight
mixa1901
@mixa1901
Jun 04 2017 09:31
@ivancsicsmarkus ty
CamperBot
@camperbot
Jun 04 2017 09:31
mixa1901 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 574 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Pieter Stokkink
@forkerino
Jun 04 2017 09:33
@microworlds I'm not sure how well files are cached if you store them as a binary in mongodb... Obviously minimizing network requests would be best, especially if you have many places where you need the same image, I think just storing a link to the image might be more performant. But I'm not 100% sure.
@microworlds maybe also ask in the /HelpBackEnd room...
Han
@ahenna
Jun 04 2017 09:40

SEEK AND DESTROY

function destroyer(arr) {

  var args=Array.prototype.slice.call(arguments, 1);
  console.log(args);

  for(i=0; i<args.length; i++){
         var newArr = arr.filter(function(value){
                return value !== args[i];
          });

  }
        console.log(newArr);
    return newArr;
}

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

newArr is returned as [ 1, 2, 1, 2 ] so I think there is a problem with having my filter inside a for loop but I don't know what to try next (omit the for loop altogether? Or try to make it work?)

ignore console.logs; they're to help me see what's going on
Caleb David
@microworlds
Jun 04 2017 09:40
@forkerino Thanks for shedding more light on that
CamperBot
@camperbot
Jun 04 2017 09:40
microworlds sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: microworlds already gave forkerino points
Pieter Stokkink
@forkerino
Jun 04 2017 09:41
@ahenna yeah, you don't need a loop. You can use .indexOf to check for the presence of a value in the args array.
Kriis1
@Kriis1
Jun 04 2017 09:42

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

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

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

Pieter Stokkink
@forkerino
Jun 04 2017 09:42
The problem is that newArr is overwritten each time, without arr changing. @ahenna
Kriis1
@Kriis1
Jun 04 2017 09:42
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value
help i dont know what to do
Han
@ahenna
Jun 04 2017 09:42
Ah ok... thanks @forkerino let me look into using indexOf instead
:)
CamperBot
@camperbot
Jun 04 2017 09:42
ahenna sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2420 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 04 2017 09:44
@Kriis1 you have to use the formula and the celsius function parameter and store the result in the fahrenheit variable
Kriis1
@Kriis1
Jun 04 2017 09:45
return fahrenheit = celsius *5/9 - 32;
}
convertToF(-30) should return a value of -22
what formula should be to make this work?
Pieter Stokkink
@forkerino
Jun 04 2017 09:47
@Kriis1 it would be better to do the assignment on its own line and return afterwards. Or just return directly without assignment. However, the formula is not correct. Should be * 9/5 + 32
DevGor
@DevGor16
Jun 04 2017 09:49
@ivancsicsmarkus Thanks!
CamperBot
@camperbot
Jun 04 2017 09:49
devgor16 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 576 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 09:57
good <time-of-day> all
Can anyone help with weather?
Zafar Khodjaev
@thezaff
Jun 04 2017 09:59
hi guyz
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 09:59
hello @thezaff
nikpapad
@nikpapad
Jun 04 2017 09:59
anyone at seek and destroy algorithm??
Zafar Khodjaev
@thezaff
Jun 04 2017 09:59
Diff two arrays challenge.

function diffArray(arr1, arr2) {
  var newArr = [];
  for (var i = 0; i < arr2.length; i++) {
    if (arr1[i] !== arr2[i]) {
      newArr = arr1.slice(1);
    }
  }
  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 09:59
:) I did that one
Zafar Khodjaev
@thezaff
Jun 04 2017 09:59
anything to suggest?
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:00
I am not familiar with yours @thezaff
Zafar Khodjaev
@thezaff
Jun 04 2017 10:00
@nikpapad tough one
@nikpapad what have u got so far?
nikpapad
@nikpapad
Jun 04 2017 10:00
i cannot get the second and third argument...
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:00
Oh
You are having problems with arguments[] ?
nikpapad
@nikpapad
Jun 04 2017 10:01
yep
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:01
Okay, I can maybe help
It's weird, it's not an array, but has .length
nikpapad
@nikpapad
Jun 04 2017 10:02
the .length returns 6 from the first arg
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:02
so you can see how many you have. Start at arguments[1] and iterate to the length
no
not the lenght of arguments[0]
the length of arguments.length
arguments[0] will be an array, it's a .... in python we call it a precondition.
but they tell you it will be.
and then you don't know how many other arguments you'll get or what they will be
nikpapad
@nikpapad
Jun 04 2017 10:05
so how i acces the second argument?
it's arguments[1]
Ayush Kenhi
@AyushKenhi
Jun 04 2017 10:05
Need help with challenge Profile Lookup
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:05
and if there is a third one, it's arguments[2]
Ayush Kenhi
@AyushKenhi
Jun 04 2017 10:06

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

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

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

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

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

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

Abhinav Mishra
@abhinav-m
Jun 04 2017 10:06
@AyushKenhi what help do you need
@baseballpoetess Hello :wave:
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:06
so you iterate :wave: @abhinav-thinktank
Ayush Kenhi
@AyushKenhi
Jun 04 2017 10:06
@abhinav-thinktank How do I access multiple objects inside Arrays
Abhinav Mishra
@abhinav-m
Jun 04 2017 10:07
@AyushKenhi using a loop
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:07
the arguments object is not an array.
Ayush Kenhi
@AyushKenhi
Jun 04 2017 10:07

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


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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Abhinav Mishra
@abhinav-m
Jun 04 2017 10:07
@AyushKenhi hmm?
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:07
@nikpapad did you get the link?
Ayush Kenhi
@AyushKenhi
Jun 04 2017 10:08
as in i use a for loop
Abhinav Mishra
@abhinav-m
Jun 04 2017 10:08
@AyushKenhi yea , you could do that
@AyushKenhi each index in the array will contain an object
nikpapad
@nikpapad
Jun 04 2017 10:08
thank u very much people!! u hedlped me tons!!! :D
J-Mag Guthrie
@baseballpoetess
Jun 04 2017 10:09
:):):) You are welcome :)