These are chat archives for FreeCodeCamp/Help

2nd
Nov 2017
Ken Haduch
@khaduch
Nov 02 2017 01:34
@alexanderkopke @DarrenfJ - hello to you and thanks for thinking of us all, and thanks for your help and participation in keeping the chat rooms going...
CamperBot
@camperbot
Nov 02 2017 01:34
khaduch sends brownie points to @alexanderkopke and @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2225 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 1700 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Manish Giri
@Manish-Giri
Nov 02 2017 01:37
@khaduch @DarrenfJ @alexanderkopke @korzo @GitHub-Henry @daddycardona @heroiczero @thekholm80 ty too
CamperBot
@camperbot
Nov 02 2017 01:37
manish-giri sends brownie points to @khaduch and @darrenfj and @alexanderkopke and @korzo and @github-henry and @daddycardona and @heroiczero and @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 2226 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 3447 | @khaduch |http://www.freecodecamp.com/khaduch
:cookie: 445 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 1993 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 1562 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:cookie: 449 | @daddycardona |http://www.freecodecamp.com/daddycardona
:cookie: 718 | @korzo |http://www.freecodecamp.com/korzo
:star2: 1701 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Henry
@GitHub-Henry
Nov 02 2017 01:39
@Manish-Giri hello & thank you :+1:
CamperBot
@camperbot
Nov 02 2017 01:39
github-henry sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6740 | @manish-giri |http://www.freecodecamp.com/manish-giri
Kyle Holm
@thekholm80
Nov 02 2017 03:13
@Manish-Giri @daddycardona @DarrenfJ @heroiczero ty
CamperBot
@camperbot
Nov 02 2017 03:13
thekholm80 sends brownie points to @manish-giri and @daddycardona and @darrenfj and @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1994 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 2227 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 6742 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 450 | @daddycardona |http://www.freecodecamp.com/daddycardona
xuenan
@xuenan678
Nov 02 2017 06:03
dajiahao
heroiczero
@heroiczero
Nov 02 2017 06:04
@thekholm80 @DarrenfJ @daddycardona @longnt80 @khaduch @GitHub-Henry @sjames1958gm @Marmiz @Manish-Giri @longnt80 @sjames1958gm @Marmiz @korzo @alexanderkopke TY :)
CamperBot
@camperbot
Nov 02 2017 06:04
heroiczero sends brownie points to @thekholm80 and @darrenfj and @daddycardona and @longnt80 and @khaduch and @github-henry and @sjames1958gm and @marmiz and @manish-giri and @korzo and @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 639 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 448 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 2228 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 1563 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:cookie: 451 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 8652 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1076 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 3448 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 6743 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 720 | @korzo |http://www.freecodecamp.com/korzo
:star2: 1702 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Henry
@GitHub-Henry
Nov 02 2017 06:07
@heroiczero hello & thank you :shipit: :dizzy:
Jill Lee
@jill-lee
Nov 02 2017 09:59

Why is the margin not working on github?
https://phoenix-burn.github.io/jewelers/

But it does on codepen.
https://codepen.io/phoenix-burn/full/VzWOpa/

Stephen James
@sjames1958gm
Nov 02 2017 10:42
@phoenix-burn Which margins are you having trouble with
rscales02
@rscales02
Nov 02 2017 13:41
console.log(checkWin(origBoard, team));

function checkWin(board, team) {
    const winArrays = [
        [0, 1, 2],
        [3, 4, 5],
        [6, 7, 8],
        [0, 3, 6],
        [1, 4, 7],
        [2, 5, 8],
        [0, 4, 8],
        [2, 4, 6]
    ];

    winArrays.forEach( function(element) {
        // statements
        if (board[element[0]] == team && board[element[1]] == team && board[element[2]] == team){
            console.log('hi');
            return true;
        } 
    });
    return false;
}
why does this never return true? even when hi logs to the console it returns false
Manish Giri
@Manish-Giri
Nov 02 2017 13:43
@rscales02 replace forEach with a regular for loop
Ken Haduch
@khaduch
Nov 02 2017 13:43
@rscales02 - I'd have to check, but the return true; in your callback function for the .forEach is returning true to the .forEach... that's what I think is happening.
Manish Giri
@Manish-Giri
Nov 02 2017 13:43
or for-of
@khaduch hey buddy, good morning, and ty :smile:
CamperBot
@camperbot
Nov 02 2017 13:44
manish-giri sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3449 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Nov 02 2017 13:45
@Manish-Giri - hey there - how's it going? Thanks for helping out here...
CamperBot
@camperbot
Nov 02 2017 13:45
khaduch sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6744 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Nov 02 2017 13:45
@heroiczero @thekholm80 @DarrenfJ @daddycardona @GitHub-Henry @alexanderkopke ty
CamperBot
@camperbot
Nov 02 2017 13:45
manish-giri sends brownie points to @heroiczero and @thekholm80 and @darrenfj and @daddycardona and @github-henry and @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1564 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 1996 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 2229 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 1703 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
:cookie: 450 | @github-henry |http://www.freecodecamp.com/github-henry
:cookie: 452 | @daddycardona |http://www.freecodecamp.com/daddycardona
Ken Haduch
@khaduch
Nov 02 2017 13:49

@rscales02 - from the documentation for Array.forEach

There is no way to stop or break a forEach() loop other than by throwing an exception. If you need such behavior, the forEach() method is the wrong tool. Use a plain loop instead. If you are testing the array elements for a predicate and need a Boolean return value, you can use every() or some() instead. If available, the new methods find() or findIndex() can be used for early termination upon true predicates as well.

Kyle Holm
@thekholm80
Nov 02 2017 14:05
@Manish-Giri angular 5 is out, have you learned 2 and 4 yet?
Manish Giri
@Manish-Giri
Nov 02 2017 14:17
:sob:
:cry:
:books:
:boom:
@thekholm80
Kyle Holm
@thekholm80
Nov 02 2017 14:19
just graduate already! lol
then you can start on your doctorate @Manish-Giri
Dr Manish
Manish Giri
@Manish-Giri
Nov 02 2017 14:21
Pfffft
Although if it’s a Dr. Strange kinda Dr. then I wouldn’t mind that
Kyle Holm
@thekholm80
Nov 02 2017 14:22
or Dr Who?
Manish Giri
@Manish-Giri
Nov 02 2017 14:22
:sunglasses:
I have to renew car insurance today
F u progressive
Kyle Holm
@thekholm80
Nov 02 2017 14:23
bleh, i did that last month
my rates went up and I called to find out why, they said "we did that for everyone in your state"
I told them i was going to get some quotes from other companies before i decide to renew and suddenly i was getting a bunch more discounts
Manish Giri
@Manish-Giri
Nov 02 2017 14:25
Lol
I’m gonna try that today
zootechdrum
@zootechdrum
Nov 02 2017 14:25

Good Morning everyone! i have this regex right now that is supposed to validate telephone numbers.

function telephoneCheck(str) {

  var checkagainst = /^([1]{1})?\s?\(?([0-9]{3})\)?\s?[-]?([0-9]{3})[-]?\s?([0-9]{4})/g;
  if (checkagainst.test(str)) {
    console.log(true);
  } else {
    console.log(false);
  }

  }

telephoneCheck("(275)76227382");

The parameter that is currently being passed in should return false but its its actually returning true. I am using the regexr.com website and it looks like it matches everything but the last two. If it doesn't match everything why does it not return false?

Manish Giri
@Manish-Giri
Nov 02 2017 14:25
My total rate went up too
By $11
Kyle Holm
@thekholm80
Nov 02 2017 14:25
mine was about $300 a year increase
zootechdrum
@zootechdrum
Nov 02 2017 14:26
by the last two I actually mean the last number 2
Manish Giri
@Manish-Giri
Nov 02 2017 14:26
Oh fk
Kyle Holm
@thekholm80
Nov 02 2017 14:26
@zootechdrum i'm sorry i don't really know regex
Manish Giri
@Manish-Giri
Nov 02 2017 14:26
Pffffft
zootechdrum
@zootechdrum
Nov 02 2017 14:27
@thekholm80 Its alright.
Kyle Holm
@thekholm80
Nov 02 2017 14:27
@zootechdrum but, your phone number has too many digits "(275)76227382"
275 762 2738 2
zootechdrum
@zootechdrum
Nov 02 2017 14:28
I know! my regex only is supposed to capture 10 digits
Manish Giri
@Manish-Giri
Nov 02 2017 14:28
x
@thekholm80
Kyle Holm
@thekholm80
Nov 02 2017 14:29
@Manish-Giri i'll never understand that
do you win a prize if you get your new fruity phone on day one?
Manish Giri
@Manish-Giri
Nov 02 2017 14:29
lol
Kyle Holm
@thekholm80
Nov 02 2017 14:29
the only thing better than consumerism is turning it into a competition
Manish Giri
@Manish-Giri
Nov 02 2017 14:37
@zootechdrum it's returning true because it found the pattern you're specifying in the regex
there's nothing telling it to reject it if more characters are found, apart from your pattern
Joshua Waller
@Obscureether1
Nov 02 2017 14:39
Morning All
zootechdrum
@zootechdrum
Nov 02 2017 14:42
Here is what I came up with basically added a dollar sign at then end .
^(([1]{1}))?\s?\(?([0-9]{3})\)?\s?[-]?([0-9]{3})[-]?\s?([0-9]{4})$
Manish Giri
@Manish-Giri
Nov 02 2017 14:43
Nice
@thekholm80 buy me iPhone X
zootechdrum
@zootechdrum
Nov 02 2017 14:43
Now I am trying to make this parameter return as false
555)-555-5555
ill keep screwing around with it
Manish Giri
@Manish-Giri
Nov 02 2017 14:45
Use a look ahead for that
zootechdrum
@zootechdrum
Nov 02 2017 14:46
what is a lookahead lol
Manish Giri
@Manish-Giri
Nov 02 2017 14:46
Accept ( only if a ) exists later
Kyle Holm
@thekholm80
Nov 02 2017 14:46
@Manish-Giri go stand in line and I'll send you my credit card info when you're ready to check out
Manish Giri
@Manish-Giri
Nov 02 2017 14:46
lol
zootechdrum
@zootechdrum
Nov 02 2017 14:47
le @Manish-Giri let me check that out really quick
Manish Giri
@Manish-Giri
Nov 02 2017 14:47
home delivery pls thanks
Kyle Holm
@thekholm80
Nov 02 2017 14:47
I don't think Apple delivers to Ohio
Manish Giri
@Manish-Giri
Nov 02 2017 14:47
:sweat:
@zootechdrum see this
Screenshot 2017-11-02 10.48.37.png
matches ( only if followed by 3 digits and a )
Joshua Waller
@Obscureether1
Nov 02 2017 14:50
yes they do for a price...lol
Manish Giri
@Manish-Giri
Nov 02 2017 14:51
and this doesn't match coz there are 4 digits between the ( )
Screenshot 2017-11-02 10.48.46.png
neither this one coz there's no closing )
Screenshot 2017-11-02 10.51.12.png
Joshua Waller
@Obscureether1
Nov 02 2017 14:52
okay, ive been away for a little because of some family things... Getting back into this..... Need a little help
trying to get ALL the mail form to be centered and it is not working for me
zootechdrum
@zootechdrum
Nov 02 2017 14:54
@Manish-Giri Let me play around with this for a bit. Thank you for leading in the righ direction
CamperBot
@camperbot
Nov 02 2017 14:54
zootechdrum sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6745 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Nov 02 2017 14:55
@thekholm80 x
Kyle Holm
@thekholm80
Nov 02 2017 14:56
lol
Ken Haduch
@khaduch
Nov 02 2017 15:01
@Obscureether1 - your page is not loading - you have some (potential) problem in the SCSS code - maybe it's just the stry </head> tag at the end?
And for CodePen, you should not have the <html>, <head>, and other tags in the HTML panel, only the actual HTML code. Any header stuff you want to include has a place in the HTML config panel....
but basically it isn't loading...
Joshua Waller
@Obscureether1
Nov 02 2017 15:03
Ken Haduch
@khaduch
Nov 02 2017 15:06
@Obscureether1 - is it loading for you? It is not loading for me... at least not very quickly. Let me check the dev console. Funny, if I open it as a full-page view, it loads, If I open in the editor mode, it doesn't....
Joshua Waller
@Obscureether1
Nov 02 2017 15:07
found the issue... was the background i was using.. system does not like it
Ken Haduch
@khaduch
Nov 02 2017 15:08
@Obscureether1 - one way that I got the mail "Name" input and "Email address" input to center was to add margin: 0 auto; in the devtools to those two ID values. Same for #message
not sure if that's what you're looking for...
zootechdrum
@zootechdrum
Nov 02 2017 15:09
@Manish-Giri Here is what I am a typing again but it does not match the first parenthesis.
^(([1]{1}))?\s?\((?=[\d]{3}\))?\s?[-]?([0-9]{3})[-]?\s?([0-9]{4})$
Joshua Waller
@Obscureether1
Nov 02 2017 15:10
i tried that and will not go ... ill try once more
Ken Haduch
@khaduch
Nov 02 2017 15:10
@Obscureether1 - just like this, it looks like it works:
#name, #email,  {
  width: 50%;
  margin: 0 auto;

}
#message{
  width: 80%;
  margin: 0 auto;
}
rscales02
@rscales02
Nov 02 2017 15:14
@khaduch thanks! that works!
CamperBot
@camperbot
Nov 02 2017 15:14
rscales02 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3450 | @khaduch |http://www.freecodecamp.com/khaduch
Joshua Waller
@Obscureether1
Nov 02 2017 15:17
@khaduch okay so through here it is working right with that, but when i try and do it fom my "page" it does not load the same?
Ken Haduch
@khaduch
Nov 02 2017 15:20
@Obscureether1 - you mean on a local page, or some other page?
Joshua Waller
@Obscureether1
Nov 02 2017 15:21
local.. im using Sublime and when i click on open in web page that is where it does not load right
Ken Haduch
@khaduch
Nov 02 2017 15:22
@Obscureether1 - hmmm - I don't know how to debug that? Is it just the centering that isn't working, or other things?
Joshua Waller
@Obscureether1
Nov 02 2017 15:22
right
Ken Haduch
@khaduch
Nov 02 2017 15:22
are you relying on any other external CSS that might be being loaded via sublime and not set up properly in your CodePen, or vice-versa?
Joshua Waller
@Obscureether1
Nov 02 2017 15:24
that i know of no... i just downloaded it and have not loaded anyother thing in... and have no other CSS that it should be hitting off of look ing but yea
nope not else in that folder to hit off of
yes there was i Found the issue... thanks @khaduch
CamperBot
@camperbot
Nov 02 2017 15:27
obscureether1 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3451 | @khaduch |http://www.freecodecamp.com/khaduch
Joshua Waller
@Obscureether1
Nov 02 2017 15:33
love how you = me over look the simple things in a caode that you take for granted
Ken Haduch
@khaduch
Nov 02 2017 15:36
@Obscureether1 - I don't know how Sublime works, I haven't used it for web development, but I'm sure that are many things that go on behind the scenes that might make it a little tricky to figure out... good luck with your project!
Joshua Waller
@Obscureether1
Nov 02 2017 15:37
im sure , but no it was a pice of the code i got from some where else and did not even thing about it ...
now that ive got that out im going to have a little work to get the layout back to how it needs to be....ol
Joshua Waller
@Obscureether1
Nov 02 2017 16:11
@khaduch what are you using for coding?
Ken Haduch
@khaduch
Nov 02 2017 16:30
@Obscureether1 - well, for the projects I've been working directly in CodePen. I have used Eclipse in the past (doing some PHP server stuff for another learning project) and I'm taking a React course and the instructor recommended Visual Studio Code, so I'm giving that a shot, but basically not too experienced with it, yet. I'm sure that it could be doing a lot more helpful stuff, with additional plugins, etc. So that's my current setup. I also do some stuff in Notepad++ and have played around with Atom in the not-too-distant past. So basically I've flip-flopped around between different editors...
Joshua Waller
@Obscureether1
Nov 02 2017 16:39
so where do you store the pictures and all that then?
alpox
@alpox
Nov 02 2017 17:00
@khaduch VSCode is :fire:
Ken Haduch
@khaduch
Nov 02 2017 17:05
@Obscureether1 - so far, I've used mostly my own pictures, I have a Flickr account that I linked pictures from. I haven't really done too many of the projects to completion so things are not in a finalized state. I also have my own ISP account that I could use to store pictures, that was what I was probably going to end up doing if I get more images that I need to use. I fact, I was considering that I would move all of my projects out to my own ISP site eventually, putting the CodePen version (so that code was easily accessible if they were going to be reviewed) and then removing the CodePen "influence" from the actual display of the site. As of yet, I haven't tried that either... :)
Joshua Waller
@Obscureether1
Nov 02 2017 17:13
CodePen "influence" ?
Ken Haduch
@khaduch
Nov 02 2017 17:17
@Obscureether1 - yeah, the editor API sometimes gets in the way, I don't understand the full reasons for it, but I've seen problems running a project on a mobile device that works fine if you can run it in the "debug" view, which just gives you the raw HTML output, but you cannot use that unless you own the project. That's just an example. Other things happen because of trying to open a page in an iframe or something like that. (My recollection is a little foggy.) It's something to watch out for.
Joshua Waller
@Obscureether1
Nov 02 2017 17:37
AH... is see... yea ill have to watch out for that one... would like to be able to "Share it from here , but just under the Full view and not all of the coding.
gishy1
@gishy1
Nov 02 2017 19:48
im back and still working on truncating the string challenge
Tychro van den Broeke
@tychro
Nov 02 2017 20:04
i'm not getting text inside an div cuz everything i write in there jumps out of my box, can anyone help???
Stephen James
@sjames1958gm
Nov 02 2017 20:05
@tychro This the FCC editor?
Tychro van den Broeke
@tychro
Nov 02 2017 20:05
no
Stephen James
@sjames1958gm
Nov 02 2017 20:05
@tychro You might need to give some more context.
Tychro van den Broeke
@tychro
Nov 02 2017 20:06
shall i send my code? or
Stephen James
@sjames1958gm
Nov 02 2017 20:07
@tychro If you can send a link - if you are using something like codepen.
Tychro van den Broeke
@tychro
Nov 02 2017 20:07
for the programming?
gishy1
@gishy1
Nov 02 2017 20:11
@sjames1958gm driving you and me both nuts but bear with me mate
Stephen James
@sjames1958gm
Nov 02 2017 20:12
@tychro Yes. Where are you writing the code?
Tychro van den Broeke
@tychro
Nov 02 2017 20:12
notepad++
Stephen James
@sjames1958gm
Nov 02 2017 20:12
@tychro Ah, local to your PC - If it is not too much code you can paste here.
https://forum.freecodecamp.com/t/markdown-code-formatting/18391
Tychro van den Broeke
@tychro
Nov 02 2017 20:14
well it is a lot with the css and html that i need for it
Stephen James
@sjames1958gm
Nov 02 2017 20:14
@gishy1 You need to organize your if conditions. You can post your current attempt here.
Kaz Baig
@kbaig
Nov 02 2017 20:14
you could paste it into a codepen
gishy1
@gishy1
Nov 02 2017 20:15
@sjames1958gm how do i post to the background instead of a screen shot?
Kaz Baig
@kbaig
Nov 02 2017 20:15
oh god I have the ugliest one liner solution to that truncate a string problem
gishy1
@gishy1
Nov 02 2017 20:16
@kbaig better than not having it pass
Kaz Baig
@kbaig
Nov 02 2017 20:16
Fair
I mean I could do it in more lines but it just feel so satisfying to do it in one
gishy1
@gishy1
Nov 02 2017 20:17
can i swear here?
i just stumbled on the answer playing around with the code
Kaz Baig
@kbaig
Nov 02 2017 20:22
:D
gishy1
@gishy1
Nov 02 2017 20:22
whats the difference between | | and &&?
Kaz Baig
@kbaig
Nov 02 2017 20:23
or vs and
if a is not true and b is true
a || b is true but a && b is false
gishy1
@gishy1
Nov 02 2017 20:24
@kbaig small things all things
that was where i was messing up
i was gong mad
going*
@sjames1958gm thanks any way mate
CamperBot
@camperbot
Nov 02 2017 20:26
gishy1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8655 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
gishy1
@gishy1
Nov 02 2017 20:26
@kbaig you too
Stephen James
@sjames1958gm
Nov 02 2017 20:27
@gishy1 :+1:
gishy1
@gishy1
Nov 02 2017 20:27
@sjames1958gm it was me putting the or operator that messed the whole thing up
Stephen James
@sjames1958gm
Nov 02 2017 20:27
@gishy1 Ah. That can do it.
gishy1
@gishy1
Nov 02 2017 20:28
but how do you post the code here without the print screen
Kaz Baig
@kbaig
Nov 02 2017 20:28
@gishy1 now that you've solved it, enjoy this mess of a one liner
return str.length <= num ? str : (num <= 3 ? str.slice(0, num) : str.slice(0, num - 3)) + '...';
gishy1
@gishy1
Nov 02 2017 20:28
@kbaig yes thats it!! how do i post here like that ?
Kaz Baig
@kbaig
Nov 02 2017 20:29
Oh I didn't mean to answer your question lmao
gitter uses markdown
in which you need to put three backticks (`) above and below your code
to format it that way
gishy1
@gishy1
Nov 02 2017 20:29
let me try it
Henry
@GitHub-Henry
Nov 02 2017 20:30
@Manish-Giri hello & thank you :shipit: :dizzy:
CamperBot
@camperbot
Nov 02 2017 20:30
github-henry sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6748 | @manish-giri |http://www.freecodecamp.com/manish-giri
Kaz Baig
@kbaig
Nov 02 2017 20:30
@gishy1 but ye that line I wrote is another solution to that problem lul
gishy1
@gishy1
Nov 02 2017 20:32

``` function truncateString(str, num) {
//truncate if longer than the maximum length
//if length of word>num return slice str.slice(0,num)+"..."
var lengthOfword=str.length;
var truncWord=str.slice(0,num)+"...";
var truncWord2=str.slice(0,num-3)+"...";
if(lengthOfword>num&&num<3){

return truncWord;

}
else if(lengthOfword>num&&num>=3){
return truncWord2;
}

else{
return str;
}
}
truncateString("Peter Piper picked a peck of pickled peppers", 14);

```

well that didnt turn out well
Kaz Baig
@kbaig
Nov 02 2017 20:33
the backticks need to be on a separate line
try editing it
gishy1
@gishy1
Nov 02 2017 20:33
function truncateString(str, num) {
  //truncate if longer than the maximum length
  //if length of word>num return slice str.slice(0,num)+"..."
  var lengthOfword=str.length;
var truncWord=str.slice(0,num)+"...";  
var truncWord2=str.slice(0,num-3)+"...";  
if(lengthOfword>num&&num<3){

    return truncWord;
  }
 else if(lengthOfword>num&&num>=3){
 return truncWord2;
} 

else{  
  return str;
}
}
truncateString("Peter Piper picked a peck of pickled peppers", 14);
Kaz Baig
@kbaig
Nov 02 2017 20:33
you can edit by hovering over the message and clicking the '...'
gishy1
@gishy1
Nov 02 2017 20:34
:smile: thanks bro
Uriel Guzmán
@Burinson
Nov 02 2017 21:17

function truthCheck(collection, pre) {
  // Is everyone being true?

  var result = '';

    for (var x in collection) {
      if (collection[x][pre]) {
        return true;
      } return false;
      //console.log(collection[x][pre]);

    }

}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Any help?
I want to check if the pre argument exists in every object as a key
artbohr
@artbohr
Nov 02 2017 21:47
@Burinson
function truthCheck(collection, pre) {

  var result = '';

  for (var x in collection) {
    if (collection[x].sex === undefined) {
      return false
    }  
  } return true

}
@Burinson get rid of var results obviously :D
@Burinson you need to access object properties by dot . notation .user .sex
Uriel Guzmán
@Burinson
Nov 02 2017 21:50
@artbohr
function truthCheck(collection, pre) {
  // Is everyone being true?
  var result = '';
for ( var i in collection){
 if(!collection[i][pre])
return false;
} 
return true;
}
I somehow passed it like this
I tried doing collection[i].pre but it doesn't work for some reason
function truthCheck(collection, pre) {
  // Is everyone being true?

for ( var i in collection){

 if(!collection[i][pre]) {
   // If property is not found...
return false;
 }
  // Return false.
} 
return true;
  // Return true.
}
Oh, I understand now, it returns true outside the loop only
Uriel Guzmán
@Burinson
Nov 02 2017 21:55
True is the default return value
False is only returned if it doesn't exist inside the loop
alpox
@alpox
Nov 02 2017 21:58
@Burinson Yea dot notation is not possible to use here because that would try to access the property pre, but the name of the property you want to access is stored in the variable pre - for that you need the bracket notation. So this is fine.
artbohr
@artbohr
Nov 02 2017 21:59
@Burinson
@Burinson that's why .pre doesn't work
console.log(typeof [pre]); #returns object
console.log(typeof pre); #returns String
alpox
@alpox
Nov 02 2017 21:59
@Burinson So your solution is totally alright
@artbohr Thats not really why
@artbohr [pre] is an array. collection[i][pre] <-- here its no array. Its an indexer
col.pre is short for col["pre"] which is different of col[pre] where pre is a variable. Thats why it doesn't work
artbohr
@artbohr
Nov 02 2017 22:07
@alpox ye, you are right
Darren
@DarrenfJ
Nov 02 2017 22:07
Hi fCC.. almost forgot to pop in and say my hi's and thanks
thanks to everyone who helps out regularly...
alpox
@alpox
Nov 02 2017 22:08
@DarrenfJ :wave: hi
Darren
@DarrenfJ
Nov 02 2017 22:09
thanks @Manish-Giri @heroiczero @thekholm80 @daddycardona @GitHub-Henry @alexanderkopke @khaduch @longnt80 @sjames1958gm @Marmiz @korzo
CamperBot
@camperbot
Nov 02 2017 22:09
darrenfj sends brownie points to @manish-giri and @heroiczero and @thekholm80 and @daddycardona and @github-henry and @alexanderkopke and @khaduch and @longnt80 and @sjames1958gm and @marmiz and @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 453 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 6749 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 721 | @korzo |http://www.freecodecamp.com/korzo
:star2: 1997 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 640 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 451 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 1704 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
:star2: 8656 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1077 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 1565 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 3452 | @khaduch |http://www.freecodecamp.com/khaduch
Darren
@DarrenfJ
Nov 02 2017 22:09
@alpox :wave:
you definitely also deserve a thank you @alpox
CamperBot
@camperbot
Nov 02 2017 22:10
:star2: 1427 | @alpox |http://www.freecodecamp.com/alpox
darrenfj sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
alpox
@alpox
Nov 02 2017 22:10
@DarrenfJ Lol :D thank you too
Dude where is this bot when one needs it
@DarrenfJ thanks
CamperBot
@camperbot
Nov 02 2017 22:10
alpox sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2230 | @darrenfj |http://www.freecodecamp.com/darrenfj
alpox
@alpox
Nov 02 2017 22:10
:D
Darren
@DarrenfJ
Nov 02 2017 22:11
:D
Uriel Guzmán
@Burinson
Nov 02 2017 22:23
@alpox @artbohr thanks
CamperBot
@camperbot
Nov 02 2017 22:23
burinson sends brownie points to @alpox and @artbohr :sparkles: :thumbsup: :sparkles:
api offline
:cookie: 318 | @artbohr |http://www.freecodecamp.com/artbohr
Uriel Guzmán
@Burinson
Nov 02 2017 22:23
How can I call the 3?
addTogether(2)(3);
alpox
@alpox
Nov 02 2017 22:24
@Burinson Its another function call. addTogether(2) has to return a function. That function then gets called with (3)
Uriel Guzmán
@Burinson
Nov 02 2017 22:25
Hm...
@alpox
 if (arguments.length === 1) {
    var sumTwoAnd = addTogether(2);
  }
}
Like that?
alpox
@alpox
Nov 02 2017 22:36
@Burinson Like that you only call the function again with 1 argument which ends up in endless recursion
@Burinson i meant more like:
function addTogether(a) {
    ....
    return function(b) { console.log(a, b); };
    ....
}

addTogether(2)(3); // Logs "2 3"
Uriel Guzmán
@Burinson
Nov 02 2017 22:41

@alpox

function addTogether(a) {
  if (arguments.length === 2) {
    return arguments[0] + arguments[1];
  }
  else if (arguments.length === 1) {
    return function addTogether(b) {
      return a + b;
    };
  }
}

addTogether(2,3);

Nice

Now I need to check if a and b are real numbers
alpox
@alpox
Nov 02 2017 22:45
@Burinson the function in there doesnt need a name. Especially taking the same name as the outer function is no good because it overrides the function in that scope
korzo
@korzo
Nov 02 2017 23:11
@heroiczero @DarrenfJ Thanks guys
CamperBot
@camperbot
Nov 02 2017 23:11
korzo sends brownie points to @heroiczero and @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 1998 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 2231 | @darrenfj |http://www.freecodecamp.com/darrenfj
dyon3334
@dyon3334
Nov 02 2017 23:50
can someone tell me why i not get NEGATIVE_INFINITY
console.log(Number.MIN_VALUE-10)
VM546:1 -10
knight2
@knight2
Nov 02 2017 23:50
hey guys
is the betbsite down?
nothing loads in the map except 'No Super Blocks'
and old links I have to previous beta site challengestutorials are empty
try going here