These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Sep 2017
John
@AnonymousLords
Sep 04 2017 00:09
Hey guys how do i put quotes inside of a string, ik theirs special escapes, but i froget what its called
like if i wanted to do "he said "hello""
Gersho
@Gersho
Sep 04 2017 00:10
@AnonymousLords
"he said \"hello\""
John
@AnonymousLords
Sep 04 2017 00:11
@Gersho Okay
@Gersho thanks
CamperBot
@camperbot
Sep 04 2017 00:11
anonymouslords sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 398 | @gersho |http://www.freecodecamp.com/gersho
John
@AnonymousLords
Sep 04 2017 00:11
I forgot what itw as called :P
Gersho
@Gersho
Sep 04 2017 00:11
also if your string is made with "" you can freely use ' ' inside (like "I'm a person" )
the opposite is also true ( 'he said "hello" '
John
@AnonymousLords
Sep 04 2017 00:13
Okay
Greg Duncan
@GregatGit
Sep 04 2017 00:35
@odm275 mongoose.connect('mongodb://localhost/users_test')
@odm275 just use ''
odm275
@odm275
Sep 04 2017 00:48
can do URL shortener with just node(express) and mongodb?
or do i need like angular/react?
what im thinking is ultimately i need to mess with href
Stephen James
@sjames1958gm
Sep 04 2017 00:51
@odm275 You don't need angular or react to do that -
odm275
@odm275
Sep 04 2017 00:52
@sjames1958gm ok, thanks for clearing it up
CamperBot
@camperbot
Sep 04 2017 00:52
odm275 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8433 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Sep 04 2017 00:58
@odm275 yw
Marc
@MWBauer
Sep 04 2017 02:04
Hey folks. In using str.substr() can you use (str.length -target)?
Some problems are asking about the last character, some are asking about the last, perhaps, 4 characters
I have the true/false working for the last character, but not for the longer ones.
Do I need to find a way to count target and use a variable to start from the end?
function confirmEnding(str, target) {
 var last = str.substring(str.length -1);  
  if (last === target) {
    return true;
  } else {
    return false;
  }
}
maybe target.length? -target.length?
FlashHero
@FlashHero
Sep 04 2017 02:20
How do you access the session in nodejs
Moisés Man
@moigithub
Sep 04 2017 02:21
req.session
Marc
@MWBauer
Sep 04 2017 02:25
Hello?
piteto
@piteto
Sep 04 2017 02:26
Hello @MWBauer figure out .substr()?
Claudio Restifo
@Marmiz
Sep 04 2017 02:29
@MWBauer substr accept two parameters, the start and the end of the substring you want to look at.
in other word you can start = last - 4 and end = last
Moisés Man
@moigithub
Sep 04 2017 02:38
mdn.io/substring <-- takes start, length as arguments
mdn.io/substr <-- takes start , end
on both cases 2nd argument is optional
LovingVi
@LovingVi
Sep 04 2017 02:53
function myReplace(str, before, after) {
  var arr = str.split(" ")
    if(before[0] === before[0].toUpperCase){
      after = after[0].toUpperCase() + after.slice(1);
    }
  arr.splice(arr.indexOf(before),1,after);
  return arr.join(" ");
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting")
js if(before[0] === before[0].toUpperCase){ after = after[0].toUpperCase() + after.slice(1); }why doesn't working?
korzo
@korzo
Sep 04 2017 03:02
@LovingVi should be before[0].toUpperCase()
LovingVi
@LovingVi
Sep 04 2017 03:03
@korzo Oh I see! THK
ElfAC
@ElfAC
Sep 04 2017 03:07
cannot read property apply of undefined
what can i do???
"push( Math.math.apply(null,arr[i]));"
Sean
@seanreeise
Sep 04 2017 03:11
@ElfAC Is that your exact code? Maybe you mean Math.mac.apply(). JS mdn apply() is func.apply(thisArg, [argsArray])
correction Math.max.apply()
ElfAC
@ElfAC
Sep 04 2017 03:40
@seanreeise THX!!
CamperBot
@camperbot
Sep 04 2017 03:40
elfac sends brownie points to @seanreeise :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @seanreeise |http://www.freecodecamp.com/seanreeise
WAINGOR
@WAINGOR
Sep 04 2017 06:16
Hi all, I am currently using this jsfiddle for a webshop:
Reference: http://jsfiddle.net/BB3JK/47/
but there is only one issue... Even though this piece of code hides the original options nicely, the following doesnt work:
  • because the php core of the webshop looks strictly at the original <select> element, I need a click event on the new <li> element to select an <option> from the original hidden <select> element. Does anybody know how to do this with JS?
korzo
@korzo
Sep 04 2017 06:23
@WAINGOR listen on click event on <ul> and then change value on select
@WAINGOR You don't even have to use select. You can use <input type="hidden" /> instead
korzo
@korzo
Sep 04 2017 06:32
@WAINGOR
$('.options').on('click', 'li', function(
    $('#selectbox1').val($(this).attr('rel'));
){});
Markus Kiili
@Masd925
Sep 04 2017 06:50
@korzo Shouldn't the jQuery code there be inside the callback function code block? Now it is as an argument.
korzo
@korzo
Sep 04 2017 06:53
@Masd925 of course :)
I hate writing code on gitter
$('.options').on('click', 'li', function() {
    $('#selectbox1').val($(this).attr('rel'));
});
@Masd925 thanks
CamperBot
@camperbot
Sep 04 2017 06:53
korzo sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4469 | @masd925 |http://www.freecodecamp.com/masd925
Bryan Reese
@breese8009
Sep 04 2017 07:09
Screen Shot 2017-09-04 at 12.08.06 AM.png
why would i be gettin this error when jquery is running just fine ?
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:12
@breese8009 can you paste your jquery just the ajax calling ?
your ajax should be define as:
$.ajax({
   // things goes here
});
Bryan Reese
@breese8009
Sep 04 2017 07:13
@forwebtech thats my jquery
  $.ajax({
    method: 'GET',
    url: '/api/bjj',
    success: renderMultipleReviews
  })
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:14
where is semicolon ?
Bryan Reese
@breese8009
Sep 04 2017 07:15
that shouldnt matter but i just added it an refreshed, same error
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:16
did you wrap $.ajax into some method ?
Bryan Reese
@breese8009
Sep 04 2017 07:17
nope
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:17
maybe:
$(document).ready(function(){
  // ajax goes here
});
Bryan Reese
@breese8009
Sep 04 2017 07:18
i have that
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:18
don't put ajax into ready method just call it in global scope.
Bryan Reese
@breese8009
Sep 04 2017 07:18
ill try that
well
that wouldnt make sense tho would it
?
$.ajax is jquery
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:19
yes ! just try it.
Bryan Reese
@breese8009
Sep 04 2017 07:20
same error yo
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:21
well i think you are passing arguments in a wrong way try to define as given:
$.ajax({url: "demo_test.txt", success: function(result){
            $("#div1").html(result);
        }});
Bryan Reese
@breese8009
Sep 04 2017 07:21
and whats weird is that the body click event i have works fine
$(document).ready(function(){
console.log('works');



$('body').on('click', function() {
    alert("it worked");
});



});

  $.ajax({
    method: 'GET',
    url: '/api/bjj',
    success: console.log('success')
  });
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:21
@breese8009 or
Markus Kiili
@Masd925
Sep 04 2017 07:22
@breese8009 Do you get the same error with just $.ajax(); ?
Bryan Reese
@breese8009
Sep 04 2017 07:22
@Masd925 i just tested, yessir
same error
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:23
$.ajax("your url", {
            // some properties
        });
Bryan Reese
@breese8009
Sep 04 2017 07:24
its very weird
@forwebtech I jsut dont think that the way im writing the ajax call is the problem, ive written it the way i have it a million times an never had this problem
Markus Kiili
@Masd925
Sep 04 2017 07:25
@breese8009 If the empty ajax call gives the error, then jQuery is not defined at that point.
Bryan Reese
@breese8009
Sep 04 2017 07:26
@Masd925 its the order of cdns?
u think?
Markus Kiili
@Masd925
Sep 04 2017 07:26
@breese8009 I would check those and then write the code again step by step.
Bryan Reese
@breese8009
Sep 04 2017 07:26
heres how i have my cdns set up
  <!-- STYLESHEETS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">



<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>

  <link rel="stylesheet" href="/styles/styles.css">

  <script src="/scripts/app.js"></script>
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:28
@breese8009 i just saw that jQuery.ajax( url [, settings ] ) so that's why i suggested.
but it's some another issue.
i did also catch in that type of error, but didn't remember, how i came up with that.
Bryan Reese
@breese8009
Sep 04 2017 07:30
ok i got rid of the rror
@Masd925 was right
it was my cdn
that jquery cdn i got from bootstrap website...but i forget its no good
went to cdnjs.com an got the real cdn
@Masd925 @forwebtech thanks guys
CamperBot
@camperbot
Sep 04 2017 07:31
breese8009 sends brownie points to @masd925 and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 729 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 4470 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Sep 04 2017 07:31
@breese8009 :+1:
Bryan Reese
@breese8009
Sep 04 2017 07:31
why does bootstrap have a bad jquery cdn?
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:36
@breese8009 is the version changed ? or same, when you take the new url
Bryan Reese
@breese8009
Sep 04 2017 07:56
@forwebtech which version?
of ajax?
its pretty much been the same for a while now i think
or version of jquery
i donno
Aizaz Shahid
@aizazshahid
Sep 04 2017 07:59
jquery version !
Bryan Reese
@breese8009
Sep 04 2017 07:59
i donno lol
Aizaz Shahid
@aizazshahid
Sep 04 2017 08:00
@breese8009 its ok, i was just wondering.
@Masd925 how's your progress on FCC ?
Bryan Reese
@breese8009
Sep 04 2017 08:04
@forwebtech hes prolly completed it, he helps everyone on here. i think hes solved every promlem ive come to him with
problem*
Aizaz Shahid
@aizazshahid
Sep 04 2017 08:04
but seems he is not focusing on projects of FCC
Bryan Reese
@breese8009
Sep 04 2017 08:05
prolly does his own
Aizaz Shahid
@aizazshahid
Sep 04 2017 08:05
i know he can do those but spending time to help others.
Bryan Reese
@breese8009
Sep 04 2017 08:06
yep, its why this place is great, got some nice ppl with alot experience givin their time to help
Markus Kiili
@Masd925
Sep 04 2017 08:08
@forwebtech Not really progressing at the moment. Enough programming at work. I did the tribute page but nothing after that yet.
Focusing more on java at the moment on my free time.
Aizaz Shahid
@aizazshahid
Sep 04 2017 08:08
Are you freelancer or working with some company ?
Markus Kiili
@Masd925
Sep 04 2017 08:09
@forwebtech Normal 8-16 programmer for a small software company.
Aizaz Shahid
@aizazshahid
Sep 04 2017 08:10
that's good :+1: and i think Java is little bit complex in coding.
Daniel Romero
@Ranacode
Sep 04 2017 08:10
I'm working with Node.js && MongoDB and I want to secure one route but I don't need a registration step. Just a field with a password to join that route. What's the better way to do this?
Aizaz Shahid
@aizazshahid
Sep 04 2017 08:14
@Ranacode did you ask there https://gitter.im/FreeCodeCamp/HelpBackEnd ?
Daniel Romero
@Ranacode
Sep 04 2017 08:15
No, I'm gonna do it
Fernando
@lestairon
Sep 04 2017 09:35

function rot13(str) { // LBH QVQ VG!

  return str.split("").map((L) => L.charCodeAt()).replace(/[A-Z]/g, (X) => X.);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Hm, what can i do here?
Markus Kiili
@Masd925
Sep 04 2017 09:37
@lestairon No need for split and map there. Use replace straight on str.
Blauelf
@Blauelf
Sep 04 2017 09:37
You cannot use replace on an array of charcodes. Either use replace, or the split/map, not both.
Markus Kiili
@Masd925
Sep 04 2017 09:37
@Blauelf Good evening.
Fernando
@lestairon
Sep 04 2017 09:40
But i f i use Replace i cant use charCodeAt and fromCharCode
Or i can use it?
Blauelf
@Blauelf
Sep 04 2017 09:42
@Masd925 Evening? Half past eleven... almost noon (upper culmination of sun around 13:30 due to daylight saving time and the 15° meridian being far in the east, but it's worse for those in Spain which are far in the west and still in same time zone)
@lestairon You can use charCodeAt and fromCharCode within the function passed as second argument to replace
Fernando
@lestairon
Sep 04 2017 09:46
I just saw the solution and it looks like i was trying to do the Advanced solution
But i still don't know how String.fromCharCode((L.charCodeAt(0) % 26) + 65) this works
Markus Kiili
@Masd925
Sep 04 2017 09:48
@lestairon Those are called magic numbers. The code should explain them or better yet work without such magic.
Blauelf
@Blauelf
Sep 04 2017 09:57
@lestairon It should be more like String.fromCharCode(L.charCodeAt(0) - 65 + 13) % 26 + 65). 65 is the ASCII code of 'A', while 13 is the shift in the alphabet that's to be applied. But since (-65+13)%26 is 0, it works either way.
-65 shifts from 'A'..'Z' to 0..25
+13 shifts from 0..25 to 13..38
%26 wraps back to 13..25+0..12
+65 shifts back from 0..25 to 'A'..'Z'
Abhinav Mishra
@abhinav-m
Sep 04 2017 10:11
Hello
but using fetch, it gives me an error
VM134:3 Refused to connect to 'https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/cyclist-data.json' because it violates the document's Content Security Policy.
I read about CSP, it seems the server has control over this.
is there any way around this?
The FCC example has pasted the json content from the URL to the project
Fernando
@lestairon
Sep 04 2017 10:17
Cant it just be charCodeAt() -13?
No, it can't be that way...
Abhinav Mishra
@abhinav-m
Sep 04 2017 10:29
nvm, it seems something else was wrong
Daniel Romero
@Ranacode
Sep 04 2017 10:37
hi guys, anyone worked with passport library?
Fernando
@lestairon
Sep 04 2017 10:40
@Blauelf @Masd925 Ok, now i know how it works.
Thanks
CamperBot
@camperbot
Sep 04 2017 10:40
lestairon sends brownie points to @blauelf and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4588 | @blauelf |http://www.freecodecamp.com/blauelf
:star2: 4473 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Sep 04 2017 10:41
@lestairon In my opinion, it is still better to use a way that doesn't use such numbers:
  var FROM = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var INTO = "NOPQRSTUVWXYZABCDEFGHIJKLM";
for example.
user
@user-ap
Sep 04 2017 10:42
could someone please help with the below issue. I have no idea what is going on
test.gif
Fernando
@lestairon
Sep 04 2017 10:43
Push the "Insert" key on your keyboard
I think that's the problem
user
@user-ap
Sep 04 2017 10:43
@lestairon thank you bro. you are right.
CamperBot
@camperbot
Sep 04 2017 10:43
gothamknight sends brownie points to @lestairon :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @lestairon |http://www.freecodecamp.com/lestairon
user
@user-ap
Sep 04 2017 10:43
never had that happen before...
Markus Kiili
@Masd925
Sep 04 2017 10:44
@gothamknight It is quite easy to physically remove such keys from the keyboard and live happily ever after.
Fernando
@lestairon
Sep 04 2017 10:45
@Masd925 So, if it's A i just can use index of it, find where is it locate on "FROM" and replace it with INTO and the same index?
Markus Kiili
@Masd925
Sep 04 2017 10:46
@lestairon Yes, you can use indexOf to find the index and then use it.
Elizabeth Paul
@Kowalatam
Sep 04 2017 10:49
so i have been seeing this.. im quite unsure what it means..
when variables are declared like this
var someThing = oneThing, another, yetAnother, andAnother
what does that mean ?... someThing is all the things mentioned ?..
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:51
yes
Markus Kiili
@Masd925
Sep 04 2017 10:51
@Kowalatam You declare four variables and only one is initialized.
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:52
Anyone can help me out. I have set border/outline to 0, and none when it didn't work, the outline still appears when on focus, click, and also the background color is messed up. Here is the pen: https://codepen.io/Morched23MJ/pen/VzRQZM
Elizabeth Paul
@Kowalatam
Sep 04 2017 10:53
@Masd925 how. i don't get it
Markus Kiili
@Masd925
Sep 04 2017 10:53
@Kowalatam It is just how the var syntax works. It is the same as:
var someThing = oneThing;
var another;
var yetAnother;
var andAnother;
You can put them in one line with commas in between as you did.
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:54
@Morched23MJ what border?
each tag
which
when you click in new game?
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:54
.btn
Elizabeth Paul
@Kowalatam
Sep 04 2017 10:54
@Masd925 ohh.. i see.. thank you
CamperBot
@camperbot
Sep 04 2017 10:54
kowalatam sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4474 | @masd925 |http://www.freecodecamp.com/masd925
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:54
In all buttons
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:55
sec
you wanna remove box-shadow?
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:55
@Kowalatam, where you at, in the projects?
That's a shadow? perhaps an outline or border?
@tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:55
add box-shadow:none;
on the focus
Elizabeth Paul
@Kowalatam
Sep 04 2017 10:55
@Morched23MJ im at pomodoro.. been lazy :)
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:55
you can remove those
/* border: 0; */
/* outline: 0; */
insouciantone
@insouciantone
Sep 04 2017 10:56
Can anyone help me out? Why isn't this working? It works on my local machine.
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:56
@Morched23MJ worked?
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:56
@Kowalatam, I finished it, yesterday, trying the TicTacToe :smile:
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:56
"jquery-3.2.1.min.js:4 Mixed Content: The page at 'https://codepen.io/insouciance/pen/wqOxpz' was loaded over HTTPS, but requested an insecure script 'http://en.wikipedia.org/w/api.php?callback=jQuery32101106332766239555_1504522605071&action=query&list=search&srsearch=a&format=json&_=1504522605072'. This request has been blocked; the content must be served over HTTPS."
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:57
@tiagocorreiaalmeida, outline still persists
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:57
sec
you have to use 1 thinghere
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:57
@tiagocorreiaalmeida, can you fork it?
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:57
@insouciantone
Blauelf
@Blauelf
Sep 04 2017 10:57
@insouciantone You can use the wikipedia API over https, too. That way, no mixed content issue.
Elizabeth Paul
@Kowalatam
Sep 04 2017 10:57
@Morched23MJ looking at yours now.. u did good... still trying to figure out how to pause.. :)
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:57
change your like to https*
and it will work
@Morched23MJ ok 1sec
Morchid Chellali
@Morched23MJ
Sep 04 2017 10:58
@Kowalatam, good luck ^^
insouciantone
@insouciantone
Sep 04 2017 10:58
@tiagocorreiaalmeida thanks, that works
CamperBot
@camperbot
Sep 04 2017 10:58
insouciantone sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 336 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
insouciantone
@insouciantone
Sep 04 2017 10:58
@heroiczero that's not needed
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 10:59
@Morched23MJ no outline is showing up
save your project and then ctrl+f5
and tell me if it stills happening
Morchid Chellali
@Morched23MJ
Sep 04 2017 11:00
It still appears when I click, and hold my click
that's the focus, right?
@tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 11:03
.btn-info.active.focus, .btn-info.active:focus, .btn-info.active:hover, .btn-info:active.focus, .btn-info:active:focus, .btn-info:active:hover, .open>.dropdown-toggle.btn-info.focus, .open>.dropdown-toggle.btn-info:focus, .open>.dropdown-toggle.btn-info:hover {
    color: #fff;
    background-color: #269abc;
    border-color: #1b6d85;
somewhere this si happening
bootstrap css I think
@Morched23MJ found it
Morchid Chellali
@Morched23MJ
Sep 04 2017 11:05
Oh, I used a simple css button, much better, everything works great, thanks @tiagocorreiaalmeida, appreciate it
CamperBot
@camperbot
Sep 04 2017 11:05
morched23mj sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 11:06
still I can just paste you the change you had to preform
.btn-info.active.focus, .btn-info.active:focus, .btn-info.active:hover, .btn-info:active.focus, .btn-info:active:focus, .btn-info:active:hover, .open>.dropdown-toggle.btn-info.focus, .open>.dropdown-toggle.btn-info:focus, .open>.dropdown-toggle.btn-info:hover {
    color: #5AE5C8;
    background-color: #194037;
    border: 0;
    outline: none
}
if you writed this on your css file it would work probably
Morchid Chellali
@Morched23MJ
Sep 04 2017 11:08
Alright, thanks :smile:
You liked the design, though?
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 11:08
yeah looks fancy :D
Fernando
@lestairon
Sep 04 2017 11:33

function rot13(str) { // LBH QVQ VG!

  return str.replace(/[A-Z]/g, (L) => String.fromCharCode((L.charCodeAt(0) % 26) + 65));
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Ok, so using this code...
How could i do if i want to shift it 14 instead of 13?
Jefferson
@jeffersonnnn
Sep 04 2017 11:40
Hey people, i need a little help here. The seek and destroy challenge requires us to turn arguments object into arguments. After doing this, it turns destroyer([1, 2, 3, 1, 2, 3], 2, 3); into 1, 2, 3, 1, 2, 3, 1, 2 , but what i do not understand is how will filter work: how do i decide the parts of the new formed array i want to compare. To wit, how do i show that i'd like to compare 1, 2,3,1,2,3 with 1,2
to*
Markus Kiili
@Masd925
Sep 04 2017 11:41
@lestairon Julius Caesar died 44 BC, so you are a bit late.
Blauelf
@Blauelf
Sep 04 2017 11:42
@jeffersonnnn You use filter on an array, and it calls your callback function for each element. If the callback returns truthy, that element will be part of the returned array.
Markus Kiili
@Masd925
Sep 04 2017 11:42
@jeffersonnnn You should turn the arguments from index 1-> into an array, and then use that array and arr to solve it.
Fernando
@lestairon
Sep 04 2017 11:42
Haha, i mean, shift the letters 14 places instead of 13
Blauelf
@Blauelf
Sep 04 2017 11:44
@lestairon Just use String.fromCharCode((L.charCodeAt(0) - 65 + 14) % 26 + 65) (replacing the 13 with 14). The version without the -65 is just a coincidence in case of +13.
@Masd925 March 15th, 44BC, I think. Not a healthy lifestyle.
Fernando
@lestairon
Sep 04 2017 11:48
A coincidence between how many letters are in the alphabet and how many times are they shifted?
Joseph
@Big-jo
Sep 04 2017 11:49
function Validate(args) 
{

    if(args=="")
    {
        return true;
    }



}
Validate("Mary Kingston");
Why does this return undefined?
Markus Kiili
@Masd925
Sep 04 2017 11:51
@Big-jo JS functions return undefined by default.
Joseph
@Big-jo
Sep 04 2017 11:51
But i said return true
Jefferson
@jeffersonnnn
Sep 04 2017 11:51
@Masd925 you know, i thought about this, turning whatever lies after the inital array into another array itself a lá [1, 2, 3, 1, 2, 3], [ 2, 3]. But first is that what you mean?
Markus Kiili
@Masd925
Sep 04 2017 11:51
@Big-jo That return is only executed if the passed string is an empty string.
Joseph
@Big-jo
Sep 04 2017 11:51
oh
Markus Kiili
@Masd925
Sep 04 2017 11:52
@jeffersonnnn arr already holds the first passed argument [1, 2, 3, 1, 2, 3]. You need to put the arguments after that to another array.
Jefferson
@jeffersonnnn
Sep 04 2017 11:55
@Masd925 do that then compare both with .filter, i hope.
Markus Kiili
@Masd925
Sep 04 2017 11:56
@jeffersonnnn Yes, filter is good here.
Fernando
@lestairon
Sep 04 2017 12:25
I stil don't get how it works that way @Blauelf
Ok, so, if i want to shift "C" 13 places it would be
67 - 65 = 2
2 + 13 = 15
15 % 26 = 11
11 + 65 = 76
76 = L
What am i doing wrong?
Stephen James
@sjames1958gm
Sep 04 2017 12:26
@lestairon 15 % 26 is 15 not 11
Fernando
@lestairon
Sep 04 2017 12:27
Why is it 15?
Stephen James
@sjames1958gm
Sep 04 2017 12:27
@lestairon because % is the remainder after division.
15 / 26 is 0 with a remainder of 15
Blauelf
@Blauelf
Sep 04 2017 12:27
@lestairon 15 % 26 is 15 since 15 is 0*26+15. 31 % 26 would be 5 since 31 is 1*26+5
Fernando
@lestairon
Sep 04 2017 12:29
Oh
I was doing it like 26 % 15 instead of 15 % 26
Right, my bad
Stephen James
@sjames1958gm
Sep 04 2017 12:32
@jeffersonnnn 'compare with filter' seems inexact.
You want to filter arr, keeping only those values not in the array created from the remaining arguments
Margaret Greaney
@greaneym
Sep 04 2017 12:40
@sjames1958gm , thanks I agree.
Hello, I have a question about using codepen.io with the react challenges. To learn more about the build environment for react I am learning to use create-react-app which minimizes and bundles the files, but these then can't be used on codepen.io which does not allow for directory structures, correct?
Where do people put their react projects?
Stephen James
@sjames1958gm
Sep 04 2017 12:43
@greaneym I have used cloud9 -
Margaret Greaney
@greaneym
Sep 04 2017 12:44
Is that a pay for service or free host?
Stephen James
@sjames1958gm
Sep 04 2017 12:44
It is free, but they may require a credit card
It's been a while since I joined
Margaret Greaney
@greaneym
Sep 04 2017 12:44
@sjames1958gm , thanks I will check it out
CamperBot
@camperbot
Sep 04 2017 12:44
greaneym sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8434 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Sep 04 2017 12:45
@greaneym :+1: you basically get a linux VM where you can run create-react-app
Margaret Greaney
@greaneym
Sep 04 2017 12:45
@sjames1958gm , do you know if they can also host python there as well?
Stephen James
@sjames1958gm
Sep 04 2017 12:46
I don't know for sure, but I would expect so
Margaret Greaney
@greaneym
Sep 04 2017 12:48
@sjames1958gm , thanks
CamperBot
@camperbot
Sep 04 2017 12:48
greaneym sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: greaneym already gave sjames1958gm points
Georgia
@georgiawang5332
Sep 04 2017 12:55
file:///C:/Users/usre/Desktop/2017-09-04_205418.png
sorry
Margaret Greaney
@greaneym
Sep 04 2017 13:00
@sjames1958gm , I just found a FCC article by Jake Wisler on how to use github and surge.sh with react projects. I think I'll try that first since I have github already available.
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 13:03
wouldnt node js do the trick here?
Staller_y
@stellaryy
Sep 04 2017 13:05
good evening!
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 13:14
hello @stellaryy
Kelechi Chinaka
@kelechy
Sep 04 2017 13:23

Write a program to determine if a string contains all unique characters. Return True/true if it does and False/false otherwise.

The string may contain any of the 128 ASCII characters

function hasUniqueChars(str){
  str = str.toLowerCase();
  for (var i = 0; i < str.length; i++) {
    if (str.indexOf(str[i]) !== str.lastIndexOf(str[i])) return false;
  }
  return true
}
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 13:24
@kelechy you need help or
Kelechi Chinaka
@kelechy
Sep 04 2017 13:24
any ideas how to handle the last case
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 13:24
can you point me the exercise name?will look into min
and see what I have
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 13:26
oh its a kata my bad give me a sec will see what I Can do
Markus Kiili
@Masd925
Sep 04 2017 13:27
@kelechy What last case?
Blauelf
@Blauelf
Sep 04 2017 13:29
@Masd925 Random tests on "Attempt"
Kelechi Chinaka
@kelechy
Sep 04 2017 13:29
The string may contain any of the 128 ASCII characters @Masd925
my algo passes all test but fails ascii test
Blauelf
@Blauelf
Sep 04 2017 13:39
No need to use both indexOf and lastIndexOf, you can use i for one of them, like if (str.indexOf(str[i]) !== i) return false;
This would trigger on the second occurrence of a letter.
@kelechy Why do you lowercase the string? I don't see any requirement for that.
Kelechi Chinaka
@kelechy
Sep 04 2017 13:47
according to the test
" nAa" this returns false @Blauelf
my code just fails the ascii test, i cant handle it @Blauelf
Blauelf
@Blauelf
Sep 04 2017 13:49
@kelechy Why do you lowercase the string? I don't see any requirement for that.
Kelechi Chinaka
@kelechy
Sep 04 2017 13:52
woooow... :smile: i truly did not see that
o that changed the case of the ascii
:smile: thanks @Blauelf
CamperBot
@camperbot
Sep 04 2017 13:53
kelechy sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4589 | @blauelf |http://www.freecodecamp.com/blauelf
Kelechi Chinaka
@kelechy
Sep 04 2017 13:58
No need to use both indexOf and lastIndexOf, you can use i for one of them, like if (str.indexOf(str[i]) !== i) return false; @Blauelf
i normally like to do if (str.indexOf(str[i]) !== str.lastIndexOf(str[i])) return false; @Blauelf
Blauelf
@Blauelf
Sep 04 2017 13:59
If you're using filter to remove all non-unique, that's probably the way to go.
Kelechi Chinaka
@kelechy
Sep 04 2017 13:59
but i think the runtime may be slower compared to yours,
yea
Blauelf
@Blauelf
Sep 04 2017 14:00
Not necessarily. Your solution might test less characters.
Kelechi Chinaka
@kelechy
Sep 04 2017 14:01
true
Alex
@alexandrupintilei
Sep 04 2017 14:02
var sum1 = 0;
var sum2 = 0;
var mediaAx = 0;
var mediaAy = 0;
var mediaAxy = 0;

function mediaTotala(x,y){
for(i=0; i<x.length;i++){
  sum1 += x[i];
  mediaAx = sum1/x.length;
}

for(j=0;j<y.length;j++){
  sum2 += y[i];
  mediaAy = sum2/y.length;
}
}
mediaTotala([1,2,3],[100,101,102]);
console.log(mediaAx);
console.log(mediaAy);

VM281:20 2
VM281:21 NaN
Why i get NaN?
Ken Haduch
@khaduch
Sep 04 2017 14:06
@alexandrupintilei - you need to use the index j in your second calculation loop, instead of i
Alex
@alexandrupintilei
Sep 04 2017 14:08
@khaduch thx
CamperBot
@camperbot
Sep 04 2017 14:08
alexandrupintilei sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3265 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Sep 04 2017 14:27
@alexandrupintilei - you're welcome. That was a hard one to spot! I wonder if jslint would have put a warning about that one?
Marc
@MWBauer
Sep 04 2017 14:36
Morning everyone.
Ken Haduch
@khaduch
Sep 04 2017 14:36
@MWBauer - hello Marc - how are you doing?
Marc
@MWBauer
Sep 04 2017 14:37
I'm ok.
You?
Ken Haduch
@khaduch
Sep 04 2017 14:37
doing alright here, too...
Marc
@MWBauer
Sep 04 2017 14:37
Good to hear.
Got your thinking cap on?
Ken Haduch
@khaduch
Sep 04 2017 14:38
@MWBauer - what's left of it... :)
do you have a question or problem?
Marc
@MWBauer
Sep 04 2017 14:38
I'm working on the confirming the ending challenge. I have the first part where it confirms just the last letter. Can I use a param like -target?
read: minus target
Ken Haduch
@khaduch
Sep 04 2017 14:39
@MWBauer - I think that you can? Are you using .splice() or .slice()?
Markus Kiili
@Masd925
Sep 04 2017 14:39
@MWBauer You can use that on some of the slice-like string methods.
Marc
@MWBauer
Sep 04 2017 14:39
the thought being, whatever the target is, the check will check for that size and those characters
function confirmEnding(str, target) {
 var last = str.substring(str.length -1, target);  
  if (last === target) {
    return true;
  } else {
    return false;
  }
}
Ken Haduch
@khaduch
Sep 04 2017 14:40
@MWBauer - .substr() is what I used. You can use a negative number. Check the docs...
Marc
@MWBauer
Sep 04 2017 14:40
I know that's true, but it won't always be a static number.
For right now, it could be 1, or it could be 4.
Markus Kiili
@Masd925
Sep 04 2017 14:41
@MWBauer Maybe use target.length
Ken Haduch
@khaduch
Sep 04 2017 14:41
@MWBauer - yeah, use .length with your target variable... read the docs (I pointed to the .substr() method... it has a really simple option...)
Brad Coffield
@BradCoffield
Sep 04 2017 14:42
Hi everyone. I have some working JS/Jquery doing what I want but I'm pretty sure I can do it in a lot less code. I'm wondering if it's possible to target this particular part of a JSON object generically.
Ken Haduch
@khaduch
Sep 04 2017 14:42
@BradCoffield - what's your code?
Brad Coffield
@BradCoffield
Sep 04 2017 14:42
json.locations[0].weeks[0].Thursday.date; So that I can go through them with $.map or soemthing
I want to change .Thursday to something like another bracket notation. is that possible?
Marc
@MWBauer
Sep 04 2017 14:44
Now I realize that the length doesn't have to be defined. If it's not it just goes to the end.
Ken Haduch
@khaduch
Sep 04 2017 14:45
@BradCoffield - you can do that - if you're always going through all of the weekdays, you can make an array with the names of the days and increment through it. You can think of some way to also store the date information, like make an object indexed by the day name, and an array at each location to store the date and shortdate?
Brad Coffield
@BradCoffield
Sep 04 2017 14:50
@khaduch okay...I'm thinking about youre saying. And I think I understand it. Create a separate object with the days of the week and no values and then use something like a for loop to take the data from the JSON and put it into the new object I've created.
Ken Haduch
@khaduch
Sep 04 2017 14:51
@BradCoffield - I just drove on Rt 22 a couple days ago and saw the signs for St. Francis University...
Brad Coffield
@BradCoffield
Sep 04 2017 14:51
@khaduch Cool!
Ken Haduch
@khaduch
Sep 04 2017 14:51
@BradCoffield - yes, or you could just create the object on the fly. I haven't looked at the data format... let me see it.
thats where the json is getting pulled from
Ultimately what I'm doing is just pull the name of the week and its time value from the JSON and display it. I feel like I could do it in a lot less lines of code and feel it would be good for my learning to figure it out :)
Ken Haduch
@khaduch
Sep 04 2017 14:57
@BradCoffield - you have the day names as keys in the JSON data, so you don't really need to get them from anywhere - they are already there. You can just try to make an "address" for them in the "weeks" object, then use Object.keys() to get the keys, which will be the day names, and you can use .map() or .reduce() or .forEach() (pick your method) to run through the objects therein... should be a fun exercise to figure out - a good learning experience, as you said!
Brad Coffield
@BradCoffield
Sep 04 2017 14:59
Okay great. thanks a lot for your help @khaduch
CamperBot
@camperbot
Sep 04 2017 14:59
bradcoffield sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3266 | @khaduch |http://www.freecodecamp.com/khaduch
Brad Coffield
@BradCoffield
Sep 04 2017 14:59
I'll keep pluggin away at it :)
Marc
@MWBauer
Sep 04 2017 15:13
thanks @khaduch
CamperBot
@camperbot
Sep 04 2017 15:13
mwbauer sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3267 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Sep 04 2017 15:17
@MWBauer - you're welcome!
odm275
@odm275
Sep 04 2017 15:24
stuck on the url shortener microservice
how do i bond a link to a string?
Moisés Man
@moigithub
Sep 04 2017 15:26
u need to use a db
odm275
@odm275
Sep 04 2017 15:28
how do i store a hyperlink in db?
nv i got it
Moisés Man
@moigithub
Sep 04 2017 15:29
hyperlink is just a string
Serhii Borovskyi
@serhiicss
Sep 04 2017 15:58
Can anyone explain why can't I just get the day of the week this way: console.log(getDay());? Why do I have to assign it to a variable?
Marc
@MWBauer
Sep 04 2017 16:06
What's the point of front end developing?
especially when compared to back end?
Stephen James
@sjames1958gm
Sep 04 2017 16:07
@MWBauer Well if you designing user interfaces, or like the visual creativity of design then front-end would probably be more appealing.
Christopher McCormack
@cmccormack
Sep 04 2017 16:08
@serhiicss did you make a getDay function? If you did, then logging it to console is fine, you don't have to assign to variable. However, if you are trying to use the Date .getDay() method, you need the whole thing:
> console.log(new Date().getDay())
1
Henry
@GitHub-Henry
Sep 04 2017 16:08
front end development is like the working on the body of a car, back end development is like working on a car engine
Marc
@MWBauer
Sep 04 2017 16:09
thanks @GitHub-Henry
CamperBot
@camperbot
Sep 04 2017 16:09
mwbauer sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @github-henry |http://www.freecodecamp.com/github-henry
Henry
@GitHub-Henry
Sep 04 2017 16:10
no problem
Marc
@MWBauer
Sep 04 2017 16:13
While I love the idea of making something look good, I think that the more important part is the working good.
Christopher McCormack
@cmccormack
Sep 04 2017 16:14
They aren't mutually exclusive, if you're making web apps you need a front end as well. There are plenty of people that only work on one side and learn it very well
Serhii Borovskyi
@serhiicss
Sep 04 2017 16:14
@cmccormack Thank you! I get it now.
CamperBot
@camperbot
Sep 04 2017 16:14
serhiicss sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1180 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Sep 04 2017 16:15
@serhiicss np
Marc
@MWBauer
Sep 04 2017 16:32
@cmccormack I understand that. I was trying to figure out if I wanted to be one, the other, or both. I guess I have time and a long ways to go before I really need to decide.
I have a friend that has been programming for nearly 15 years and is trying to help me when he gets time. If I can really learn this and make a buck doing it, then I could see he and I collabing on projects all day long.
Christopher McCormack
@cmccormack
Sep 04 2017 16:33
@MWBauer A good backend engineer should at least know enough frontend to prototype, from what I've heard
Stephen James
@sjames1958gm
Sep 04 2017 16:37
@MWBauer In the past I would have said that backend was more computer sciency stuff, but now with the modern tools like angular and react even the front end is not just design and some js to manipulate some widgets
Marc
@MWBauer
Sep 04 2017 16:47
Thank you for that insight.
I'm currently trying to find a way to start the repeat a string x times challenge.
We have used so many for loops....
Moisés Man
@moigithub
Sep 04 2017 16:48
string concatenation + some kind of loop
Marc
@MWBauer
Sep 04 2017 16:49
concat is just attaching things to other things, right?
Moisés Man
@moigithub
Sep 04 2017 16:49
joining strings.. yes
"a" + "a" :point_right: "aa"
Marc
@MWBauer
Sep 04 2017 16:51
Is that trying to make a new string that can be manipulated?
split/concat -> manipulate
Moisés Man
@moigithub
Sep 04 2017 16:51
strings is immutable.. so it always creates a new string (whatever method u use)
Marc
@MWBauer
Sep 04 2017 16:52
Ok.
Please explain that a little more. I'm not sure exactly what that means or how it applies right now.
Christopher McCormack
@cmccormack
Sep 04 2017 16:59
@MWBauer immutable means it cannot be changed. Strings cannot be changed in place, but you can combine a string with another string to create a new string.

For example:

> var test = 'abc'
> test.replace('a', 'A')
'Abc'
> test
'abc'

Notice how we used the replace method but test did not change. Instead, replace returns a new string that you can assign to a variable or use as part of an expression

Marc
@MWBauer
Sep 04 2017 17:01
Ok. Now I understand that.
However, and here's my ignorance and lack of understanding, how does that apply to this? I'm not trying to change a string, I'm trying to repeat it x times
Christopher McCormack
@cmccormack
Sep 04 2017 17:03
@MWBauer you have to return a new string, correct? How will you store the current value of this return string iterating?
Marc
@MWBauer
Sep 04 2017 17:04
I would need a variable to store the string.
then call the variable
Stephen James
@sjames1958gm
Sep 04 2017 17:06
@MWBauer https://www.freecodecamp.org/challenges/iterate-with-javascript-for-loops
You can use a for loop to do something a specific number of times.
Marc
@MWBauer
Sep 04 2017 17:06
I thought about that, but wasn't sure how I was going to implement.
To make sure I understand, I need to make a var and then run a For loop iterating n times with the output being the var. Right?
is this a good time to use forEach?
Christopher McCormack
@cmccormack
Sep 04 2017 17:08
output should store a new string that is a result of the previous string plus the original string (concatenation)
forEach is an Array method, not really useful here unless you want to make it more difficult than necessary
Marc
@MWBauer
Sep 04 2017 17:09
Didn't realize it was an array method. thank you.
I now understand why you keep talking about concat. I was thinking about just listing it down the page, not across as a growing string
x
x
x
Christopher McCormack
@cmccormack
Sep 04 2017 17:10
I believe the exercise wants it as a single string, correct?
Stephen James
@sjames1958gm
Sep 04 2017 17:11
@MWBauer Don't think of this as output on the page, but the result of the function execution.
you can start with an empty string and concat the input n times
Marc
@MWBauer
Sep 04 2017 17:11
I say yes, only because it wants an empty string if the n is negative
to make the var do I need to split string or just var y = str?
Dang it. Gotta' get.
work in 45. 30 to drive
lol
see ya
Christopher McCormack
@cmccormack
Sep 04 2017 17:15
@MWBauer see ya
BrianWilliams28
@BrianWilliams28
Sep 04 2017 17:55
does anyone know how to write a regular expression that targets the square brackets []
Bryan Reese
@breese8009
Sep 04 2017 17:57
@BrianWilliams28 /[[]]/g ?? maybe?
Caleb David
@microworlds
Sep 04 2017 17:58
@GlobalDevelopment2016 Long time, please I need link to those your frontend designs
Bryan Reese
@breese8009
Sep 04 2017 17:58
@BrianWilliams28
 /[[]]/g.test("[]"); //true
BrianWilliams28
@BrianWilliams28
Sep 04 2017 17:59
@breese8009 i tried that in regex but for some reason it wasnt targeting both brackets, ill try console.logging it 1 sec
Bryan Reese
@breese8009
Sep 04 2017 17:59
@BrianWilliams28 do u want both to be targeted together? or just one or the other?
BrianWilliams28
@BrianWilliams28
Sep 04 2017 17:59
just 1 or the other
should i add an or?
i figured it out
this does it
/\[|]/g
Bryan Reese
@breese8009
Sep 04 2017 18:03
@BrianWilliams28 nice
Screen Shot 2017-09-04 at 11.00.40 AM.png
whyyyyy???? its creating the schema or whatever but with only the data id,,,, why isnt the from input being added on there?? ne one n e one?
dont mind the lack of aestheticness (yes i just made that word up)
using express/mongo/mongoose
Christopher McCormack
@cmccormack
Sep 04 2017 18:09
@breese8009 can you provide some of the related code?
Bryan Reese
@breese8009
Sep 04 2017 18:11
@cmccormack heres my create function inside controllers file

function create(req, res) {
  console.log('body', req.body);


  db.Bjj.create(req.body, function(err, reviews) {
      console.log(reviews);
    if (err) { console.log('error', err); }
    console.log(reviews);
    res.json(reviews);
  });
}
jquery
$(document).ready(function() {
$.ajax({
    method:"GET",
    url: '/api/bjj',
    success: renderMultipleReviews
});



  function formData(e){
    e.preventDefault();
    var formData = $(this).serialize();
    console.log('formData', formData);
   $.ajax({
    method: "POST",
    url: '/api/bjj',
    success: renderMultipleReviews
   })
    $(this).trigger("reset");
  }



$('.form-horizontal').on('submit', formData);



});
function renderMultipleReviews(reviews) {

  reviews.forEach(function(review) {
    console.log(review)
  renderBjj(review);
  });

}


function renderBjj(bjj) {


  var bjjHtml = (`

<div class="container forms">
<div class="row">
<div class="col-sm-4">
<div class="card" style="width: 20rem;">
  <img class="card-img-top" src='${bjj.image}' alt="Card image cap">
  <div class="card-body">
    <h4 class="card-title">${bjj.gymName}</h4>
    <p class="card-text"></p>
  </div>
  <ul class="list-group list-group-flush">
    <li class="list-group-item">${bjj.reviews}</li>
    <li class="list-group-item">${bjj.gymLocation}</li>
  </ul>
  </div>
</div>

  </div>
  </div>
</div>
</div>

  `);


  $('#gymDisplay').prepend(bjjHtml);
}
BrianWilliams28
@BrianWilliams28
Sep 04 2017 18:15
is there a way to search for elements in an array using regex like the way you can do with strings?
Christopher McCormack
@cmccormack
Sep 04 2017 18:16
when you log your formdata before posting, do you see all the properties?
Moisés Man
@moigithub
Sep 04 2017 18:17
@BrianWilliams28 u need to iterate the array
using loops or array methods
Bryan Reese
@breese8009
Sep 04 2017 18:21
@cmccormack yessir
Amit Patel
@AmitP88
Sep 04 2017 18:23

@AmitP88
hey guys, I'm making a 3 match puzzle game using JS and Canvas and I need a little help. I'm trying to figure out how to populate my canvas grid with random tiles. Here's my code so far:

// Function that accesses the canvas element and sets the context to 2D.
// Also serves as the container function for everything else in the game.
function draw() {
    var canvas = document.getElementById("viewport");
    var ctx = canvas.getContext("2d");

// Creates column lines for grid
    for (i=100; i < canvas.width; i=i+100){
        ctx.beginPath();
        ctx.strokeStyle = "gray";
        ctx.moveTo(i,0);
        ctx.lineTo(i,800);
        ctx.stroke();    
    }

// Creates row lines for grid
    for (i=100; i < canvas.height; i=i+100){
        ctx.beginPath();
        ctx.strokeStyle = "gray";
        ctx.moveTo(0,i);
        ctx.lineTo(800,i);
        ctx.stroke();    
    }

// Array that holds all the tile types to be randomly generated in the grid
    var tiles = [
        { name: 'physical', image: 'images/tiles/orbs/physical.png' },
        { name: 'thunder', image: 'images/tiles/orbs/thunder.png' },
        { name: 'fire', image: 'images/tiles/orbs/fire.png' },
        { name: 'earth', image: 'images/tiles/orbs/earth.png' },
        { name: 'light', image: 'images/tiles/orbs/light.png' },
        { name: 'water', image: 'images/tiles/orbs/water.png' },
        { name: 'dark', image: 'images/tiles/orbs/dark.png' },
    ];

//  generates random tiles in the grid
    function generator() {
        for(i=0; i < canvas.width;i=i+100) {
            for(i=0; i < canvas.height; i=i+100) {
                // variable that generates a random tile from the tiles array
                var randomTile = tiles[Math.floor(Math.random() *7) + 0].image;

                // example of how to access tile image
                console.log(randomTile);

                // place randomTile in each square inside grid
                return canvas.randomTile;
            }
        }        
    }

    generator();
};

grid.png

Christopher McCormack
@cmccormack
Sep 04 2017 18:23
@breese8009 ok step it out - did you log reviews in renderMultipleReviews(reviews)?
@AmitP88 you sure you don't want to use SVG instead?
Bryan Reese
@breese8009
Sep 04 2017 18:25
@cmccormack I did, in my screen shot, thats line 36
its logging data
Amit Patel
@AmitP88
Sep 04 2017 18:25
@cmccormack I'm not sure. what's the difference between canvas and SVG?
Christopher McCormack
@cmccormack
Sep 04 2017 18:26
@breese8009 so each review has all the appropriate properties?
Bryan Reese
@breese8009
Sep 04 2017 18:26
but some how theres something missing between my db and the formdata
@cmccormack its creating something, but its not creating whats inputed to the form
i have dummy data that worked
Christopher McCormack
@cmccormack
Sep 04 2017 18:27
@AmitP88 SVG shapes allow you to add event handlers which you may want in a game
Bryan Reese
@breese8009
Sep 04 2017 18:28
just creating the object with the _id
that the db automatically creates
Christopher McCormack
@cmccormack
Sep 04 2017 18:28
@AmitP88 you're returning your randomTile during your first loop iteration which will then end the loop, fyi
Bryan Reese
@breese8009
Sep 04 2017 18:28
so its doing something right
but missing something
at the same time
Amit Patel
@AmitP88
Sep 04 2017 18:28
@cmccormack I see. so using return will just end the loop after first iteration.
Christopher McCormack
@cmccormack
Sep 04 2017 18:29
@AmitP88 return is scoped to the function, so returning will end the function
Amit Patel
@AmitP88
Sep 04 2017 18:29
@cmccormack I see. ok, I'll remove return. But I still have a hard time figuring out how to render the randomTiles into each cell of the grid. I feel like I'm close, but I just can't get it
@cmccormack also, I'll look into using SVG. I've only used Canvas before once on a project a long time ago
Christopher McCormack
@cmccormack
Sep 04 2017 18:33
@AmitP88 ideally you would have an object or array that contains your cell dimensions, and each rectangle or image would be given a position with row (cell height * rowIndex) and column (cell width * colIndex).
@breese8009 without being able to play with the code it might be difficult to help troubleshoot, I would recommend digging in to where the data is not returning properly and see if you can find an issue in your code
@breese8009 someone else here may have more experience with this than myself, sorry
Amit Patel
@AmitP88
Sep 04 2017 18:36
@cmccormack ah I was thinking about that. so for example, I could do something like this?
var grid = [
{ width: 100px, height: 100px },
{ width: 100px, height: 100px },
etc...
]
@cmccormack then just run a for loop over it?
Christopher McCormack
@cmccormack
Sep 04 2017 18:37

@AmitP88 no, your grid should only have one cell size, correct?

var cell = {
   width: '100px',
   height: '100px'
}

then you can just call cell.width or cell.height

adjust as necessary, I don't remember in canvas how to set the sizes
Amit Patel
@AmitP88
Sep 04 2017 18:37
@cmccormack ah I see. so call cell.width and cell.height within a for-loop?
Christopher McCormack
@cmccormack
Sep 04 2017 18:38
@AmitP88 no just set that globally or wherever outside and then use your for loop iterators (need to use unique if using nested for loop) multiplied by the cell.width or cell.height
@AmitP88 you're sort of doing something like that now, but you're using i for both loops, then not even using i in your code
Amit Patel
@AmitP88
Sep 04 2017 18:40
@cmccormack I see. ok, I'll use the cell object and see if I can use it with my for loops. thanks for the guidance! :)
CamperBot
@camperbot
Sep 04 2017 18:40
amitp88 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1184 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Sep 04 2017 18:40
@AmitP88 np good luck!
Neel
@NeelDVirus
Sep 04 2017 19:11

i found this piece of code in one of the pluralsight tutorial

      $("<option />", {
         "selected": "selected",
         "value"   : "",
         "text"    : "Go to..."
      }).appendTo("nav select");

this code is in the form of $( aStringFrom, bJSONForm ).appendto()
i haven't saw before code like this where two arguments aStringForm and bJSONForm are passed together.
i have searched in w3school, but there is also no mention of things like this.
Can anyone pass me a link where i can found information about this kind, please

Sabin Sapkota
@sabin20
Sep 04 2017 19:19
hey guys anyone who can help me implement reating-gen npm?
Stephen James
@sjames1958gm
Sep 04 2017 19:22
@NeelDVirus http://api.jquery.com/jQuery/#jQuery-html-attributes
This is the reference in the jquery docs
Neel
@NeelDVirus
Sep 04 2017 19:23
@sjames1958gm Oh thank you man, you saved me. checking it out now
CamperBot
@camperbot
Sep 04 2017 19:23
neeldvirus sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8436 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sabin Sapkota
@sabin20
Sep 04 2017 19:24
@sjames1958gm can you help me implement rating-gen npm?
Stephen James
@sjames1958gm
Sep 04 2017 19:24
@sabin20 I have never created a node module
Sabin Sapkota
@sabin20
Sep 04 2017 19:25
@sjames1958gm no that module is already there. I just want to use it
Stephen James
@sjames1958gm
Sep 04 2017 19:27
What does it do?
Sabin Sapkota
@sabin20
Sep 04 2017 19:30
So I wanted to have star rating for product-review for the project I am working on
this is the package and I donot know if this is appropariate package or not
Stephen James
@sjames1958gm
Sep 04 2017 19:32
Are you using a bundler like webpack? If not then just download
the .js and css from
https://github.com/knaman2609/Ratings
and load them with your page
If not using a bundler then you wont do the require part
Sabin Sapkota
@sabin20
Sep 04 2017 19:33
I am not using bundler
cool let me try
so here is the link
@sjames1958gm
Pagnito
@Pagnito
Sep 04 2017 19:34
hey anyone here know how to build a fullstack app?
Stephen James
@sjames1958gm
Sep 04 2017 19:36
@sabin20 can you upload files to that? If not you may have to copy the code from githib to glitch
Sabin Sapkota
@sabin20
Sep 04 2017 19:36
@sjames1958gm I have installed the package
Stephen James
@sjames1958gm
Sep 04 2017 19:37
@sabin20 I haven't used glitch, didn't know you could do that.
Sabin Sapkota
@sabin20
Sep 04 2017 19:38
cool cool
Kelechi Chinaka
@kelechy
Sep 04 2017 19:49
function nextItem(xs, item) {
  for (var i = 0; i < xs.length; i++) {
    if (xs[i] === item) return xs[i+1];
  }
  return undefined;
}
it fails the last test, i cant make sense of it
https://www.codewars.com/kata/whats-up-next/train/javascript
the description does not state any
Stephen James
@sjames1958gm
Sep 04 2017 19:52
Kelechi Chinaka
@kelechy
Sep 04 2017 20:00
the doc does not seem to make sense to me now @sjames1958gm
one of those kata you learn something new :smile:
Kelechi Chinaka
@kelechy
Sep 04 2017 20:09
and it was introduced in es6 @sjames1958gm
Stephen James
@sjames1958gm
Sep 04 2017 20:33
yes I have not used at yet
Seems strange for kata level 7
luccifer00
@luccifer00
Sep 04 2017 21:14
function fearNotLetter(str) {
  var abc ="abcdefghijklmnopqrstuvwxyz".split("");
  var place =abc.indexOf(str[0]);
var x = abc.slice(place, place +str.length+1);
  var newArr=[];
  for (var i= 0; i <str.length ; ++i){
    if (x[i] !== str[i]){
    newArr.push(x[i]); 
     str =str[i-1];
    }
  }
  var result = newArr.join("");
  var nothing;
  if (result != ""){
   return result;
  }
}

fearNotLetter("abcdefghjklmno");

hi there! anyone can check if i did many stupid things on this challenge?? i had the goal to finis it with out ask anywhere... so i dont know if i do the way to do that challenge, or i choose the worst way to do it.....

at first looks easy... but i found complicate the way to make the diff between the arr to return the exactly difference... , now i would like to get it with charCodeAt() and fromCharCode

Gersho
@Gersho
Sep 04 2017 21:21
hi, wow that's a interesting way of doing it @luccifer00
luccifer00
@luccifer00
Sep 04 2017 21:25
lol! @Gersho thanks for your kind answer.... i think it is a complicated way (or stupid way) of doing it :D
CamperBot
@camperbot
Sep 04 2017 21:25
luccifer00 sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 400 | @gersho |http://www.freecodecamp.com/gersho
Gersho
@Gersho
Sep 04 2017 21:25
if it's stupid and works, it ain't stupid
Addison
@addisonday
Sep 04 2017 21:28
Halfway through the Basic Algorithm Scripting challenges! Proud of myself for persevering! Time to take on Chunk Monkey XD
Gersho
@Gersho
Sep 04 2017 21:29
@addisonday gogo ! \o/
Stephen James
@sjames1958gm
Sep 04 2017 21:37
@addisonday :+1:
Elizabeth Paul
@Kowalatam
Sep 04 2017 21:39
@addisonday you can do it.. *
working stupid is the best kind of stupid :) .... lol
Gersho
@Gersho
Sep 04 2017 21:44
the style police sometimes comes after you tho
Stephen James
@sjames1958gm
Sep 04 2017 21:45
There is style and there is inefficient
I would hope that part of the learning process would be to learn accepted styles
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 22:45
``` for(var i = 0; i<pin.length; i++){
if(typeof pin[i] !== "number"){
return false;
}
}
  for(var i = 0; i<pin.length; i++){
    if(typeof pin[i] !== "number"){
    return false;
    }
  }
doesnt this check
if the current value is not a number?
FlashHero
@FlashHero
Sep 04 2017 22:50
@tiagocorreiaalmeida what do you mean?
Stephen James
@sjames1958gm
Sep 04 2017 22:51
@tiagocorreiaalmeida yes - what is pin?
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 22:52
```
function validatePIN (pin) {
  //return true or false
  if(pin.length === 4 || pin.length==6){
  for(var i = 0; i<pin.length; i++){
    if(typeof pin[i] !== "number"){
    return false;
    }
  }
  return true;
  }
  return false;
}
```
Stephen James
@sjames1958gm
Sep 04 2017 22:52
I guess I meant maybe
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 22:52
its pretty simple but not working
Stephen James
@sjames1958gm
Sep 04 2017 22:53
PIN is a string so pin[i] is a string not a number. You should use parseInt instead
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 22:55
if the number is integer
a use radix 0?
Stephen James
@sjames1958gm
Sep 04 2017 22:55
10 if they are supposed to be decimals
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2017 22:55
oh yeah my bad saw an example thanks
luccifer00
@luccifer00
Sep 04 2017 22:58
function fearNotLetter(str) {
  var index =str.charCodeAt(0);
  var result;
  for (var i= 0; i<str.length; i++){
   var start= str.charCodeAt(i);
    if (str.charCodeAt(i+1)== start+1){
    } //end if
    else{
    result= String.fromCharCode(str.charCodeAt(i+1));   
  } // end else
  } //end for loop

  return result;
}// end function

fearNotLetter("abcdeFghi");
hi again, i am trying to pass the challenge with charCodeAt() and i think i am trying other stupid method for it :smile:, i think i am close, but i get a red point (like a red dot) at the results.... what does he mean??
the var index, dosent mean nothing.. it's just for test
else{
  return  result= String.fromCharCode(str.charCodeAt(i+1));   
  } // end else
when i write return result=... in the else{} , i get the returned letter.... but i think it is not the way...
Stephen James
@sjames1958gm
Sep 04 2017 23:04
@luccifer00 You can use break; in the loop to stop when you find the result
luccifer00
@luccifer00
Sep 04 2017 23:05
yes!! @sjames1958gm that was the easy trick i was looking for!!, i didnt remember that part!!, essential!!! thanks
CamperBot
@camperbot
Sep 04 2017 23:05
luccifer00 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8438 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Sep 04 2017 23:06
@luccifer00 str.charCodeAt(i+1) this doesn't look correct as i is 0 to str.length
and doesn't relate at all to the values in str
Nicol
@NicolNonga
Sep 04 2017 23:07
help me please
Stephen James
@sjames1958gm
Sep 04 2017 23:07
@NicolNonga What's the issue
Nicol
@NicolNonga
Sep 04 2017 23:07
are you guys using the beta vertion of freecodecamp alread ?
Stephen James
@sjames1958gm
Sep 04 2017 23:07
I have looked around, not gone through in any detail
Nicol
@NicolNonga
Sep 04 2017 23:09
I took look and i like I start to play with it iam try to concatenate a string using += iam getting err
var myStr="This is the first sentence "; myStr += "This is the second sentence";
Stephen James
@sjames1958gm
Sep 04 2017 23:10
@NicolNonga sentences usually end in full stops?
Nicol
@NicolNonga
Sep 04 2017 23:11
what do you mean @sjames1958gm
Stephen James
@sjames1958gm
Sep 04 2017 23:12
@NicolNonga Computers are very particular when comparing strings. Every character has to be there. Look at the instructions -
You have
"This is the first sentence "
The instructions have
"This is the first sentence. "
Nicol
@NicolNonga
Sep 04 2017 23:16
@sjames1958gm thanks you rigth my bad
CamperBot
@camperbot
Sep 04 2017 23:16
nicolnonga sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8439 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
luccifer00
@luccifer00
Sep 04 2017 23:37
function fearNotLetter(str) {
var index =str.charCodeAt(0);
  var result;
  for (var i= 0; i<str.length; i++){
   var start= str.charCodeAt(i);
   if (start<str.charCodeAt(str.length-1)){ 
    if (str.charCodeAt(i+1)!= start+1){
      result=String.fromCharCode(start+1);
      break;
    } //end if next index is equal to index +1
   } // end if to check the length!
  } //end for loop

 return result;
}// end function

fearNotLetter("bcd");
yhep! you were right @sjames1958gm , i am proud of this code! lol, could be simple, but i do it almost by myown! yes!
Gersho
@Gersho
Sep 04 2017 23:37
code that follows your own logic is always better, if you come to it later, you will still understand it :)
Stephen James
@sjames1958gm
Sep 04 2017 23:38
@luccifer00 :+1:
Though I will ask - you compute index but never use the vairable
Gersho
@Gersho
Sep 04 2017 23:40
i like how you don't set result when declaring it, and only modify it if necessary, so the "undefined" answer is taken care of in a smooth way