These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Sep 2017
luccifer00
@luccifer00
Sep 06 2017 00:58
function convertHTML(str) {
  var reg = /&|<|>|'|"/g;
  var repl={'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;', "'":'&apos;'};
 //return reg;
 var x=str.match(reg);
  var final;
 for(var i=0;i<x.length;i++){

 return str.replace(reg, repl[x[i]]);
 }

}

convertHTML("<>");
i'm having troubles with <> result... i return '&gt;'&gt; i dont know why the loop dosent continues with every i var.... any help on this?
Adam Ayd
@adamayd
Sep 06 2017 01:00
Luccifer00 your return in the for loop breaks the loop.
@luccifer00 your return in the for loop breaks the loop
luccifer00
@luccifer00
Sep 06 2017 01:03
ok!, i tried also set a variable, and i have the same issue, i have problema with differents symbols
if the string have same symbol, i have no problem:
ej hello & world & of & freedocamp it is ok
but the hello & world < of > freedocampits bad asignment
Adam Ayd
@adamayd
Sep 06 2017 01:10
@luccifer00 I’m looking at your code. Just trying to debug it. Give me a few minutes
luccifer00
@luccifer00
Sep 06 2017 01:10
thanks @adamayd the issue is on that partrepl[x[i]]
CamperBot
@camperbot
Sep 06 2017 01:10
luccifer00 sends brownie points to @adamayd :sparkles: :thumbsup: :sparkles:
api offline
Randell Dawson
@RandellDawson
Sep 06 2017 01:11
@luccifer00 - Since you already have defined the conversions in repl, use the following logic. You will still need to code the commented section, but the algorithm below will work.
function convertHTML(str) {
  var repl={'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;', "'":'&apos;'};
  var final = '';
  for(var i=0; i < str.length; i++){
    // check if repl has a property called str[i]
    // if it does, use bracket notation with the repl object to get the value
    // for str[i] and add the value to the end of final.
    // if it does not have that property then just add
    // the current character (str[i]) to the end of final
  }
  return final;
}
@luccifer00 - since final will be a string, you would use += to add the values to the end of it.
luccifer00
@luccifer00
Sep 06 2017 01:13
@rmdawson71 thank you! so well explaines step by step, let me see if i can do it! :smile:
CamperBot
@camperbot
Sep 06 2017 01:13
api offline
luccifer00 sends brownie points to @rmdawson71 :sparkles: :thumbsup: :sparkles:
Randell Dawson
@RandellDawson
Sep 06 2017 01:14
@luccifer00 - you can use repl.hasOwnProperty(str[i])
Moisés Man
@moigithub
Sep 06 2017 01:26
i did tht using 4 replaces :)
Stephen James
@sjames1958gm
Sep 06 2017 01:30
map replace join
luccifer00
@luccifer00
Sep 06 2017 01:30
@moigithub what do u mean with that? with no loops?
mmmm interesant, probably i will try also :+1:
Stephen James
@sjames1958gm
Sep 06 2017 01:31
Replace with second parameter as a function
luccifer00
@luccifer00
Sep 06 2017 01:34
function convertHTML(str) {
  var reg = /&|<|>|'|"/g;
  var repl={'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;', "'":'&apos;'};
 //return reg;
  var final ="";
 var x=str.match(reg);
  if(x==null){
    return str;
  }else{
for(var i=0; i < str.length; i++){
  if(repl.hasOwnProperty(str[i])){
    final += repl[str[i]];
  }else{
    final += str[i];
  }
}
return final;

convertHTML("Dolce & jaja & Gabbana");
}

@rmdawson71 Works perfect!! thanks, its a pitty that i can not reach the goal by myself!, i dont know why, i have to ask too much...

also i will work to fix my strange system to do it , and maybe the @moigithub .mapand .join can help me with that! thanks both!

CamperBot
@camperbot
Sep 06 2017 01:34
luccifer00 sends brownie points to @rmdawson71 and @moigithub :sparkles: :thumbsup: :sparkles:
api offline
api offline
Randell Dawson
@RandellDawson
Sep 06 2017 01:38
@luccifer00 - I am glad you got it to work. It was not necessary to use .match. Another solution would look like:
function convertHTML(str) {
  var repl={'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;', "'":'&apos;'};
  var final = '';
  for(var char of str){
    final += repl.hasOwnProperty(char) ? repl[char] : char;
  }
  return final;
}
Stephen James
@sjames1958gm
Sep 06 2017 01:46
Using the same object - you can use
  return str.replace(/[&<>"']/g, function(e) {
    return repl[e];
  });
Randell Dawson
@RandellDawson
Sep 06 2017 01:50
@sjames1958gm - even better :smile:
GgL
@liuhuan248650
Sep 06 2017 02:37
创建一个变量 myDecimal 并给它复制一个浮点数。 (e.g. 5.7)。 How to realize?
Claudio Restifo
@Marmiz
Sep 06 2017 02:49
@liuhuan248650 there are rooms for different language. Maybe you could try asking there.
For example:
https://gitter.im/FreeCodeCamp/chinese
Jake
@JakeDVirus
Sep 06 2017 02:53

I am getting a strange quirk.
postion: absolute hides the element even after i added z-index: 99.
the above mentioned statement is on line-138 in the given codepen below.
https://codepen.io/neel111/pen/EvMmgZ

by removing the position: absolute the element show up. Why position: absolute is hidding the element?

williamsb
@williamsb
Sep 06 2017 03:01
@NeelDVirus I don't see it hiding the element, I see the element but it is hovering over the black text outside the nav bar
@NeelDVirus position absolute will take the element out of the page flow, meaning the navbar with the background red, won't wrap around it
Jake
@JakeDVirus
Sep 06 2017 03:05
@williamsb yeah i got it. since the background color was white so i coouldn't distinguish it. both the background-color and color went white so i thought it got hidden.. Thanks for assisting man
CamperBot
@camperbot
Sep 06 2017 03:05
neeldvirus sends brownie points to @williamsb :sparkles: :thumbsup: :sparkles:
api offline
Marc
@MWBauer
Sep 06 2017 03:42
my stringrepeat went from abc to undefinedundefinedundefined
lol
williamsb
@williamsb
Sep 06 2017 03:48
@MWBauer did you need help? post code
Marc
@MWBauer
Sep 06 2017 03:52
I'm not sure yet. It's possible.
probable, even.
function repeatStringNumTimes(str, num) {
  var newStr = String(str);
  for (var i = 0; i < num; i++) {
    var repeat = newStr += num[i];
  }

  return newStr;
}
Am I correct in how i'm trying to make a useable mutable string
?
JustCodeItBen
@JustCodeItBen
Sep 06 2017 03:54

In this challenge: https://beta.freecodecamp.com/en/challenges/regular-expressions/match-single-characters-not-specified

It says that my regular expression should match 9 items, but I'm not seeing 9...I'm seeing 7.

let quoteSample = "3 blind mice.";
let myRegex = /[^aeiou0-9 .]/ig; // Change this line
let result = quoteSample.match(myRegex); // Change this line
williamsb
@williamsb
Sep 06 2017 03:55
@MWBauer hm, what is repeat for? because you don't use it for anything else and you return newStr
Marc
@MWBauer
Sep 06 2017 03:55
lol
I forgot to change the return after I added code
williamsb
@williamsb
Sep 06 2017 03:56
@MWBauer i would say it's not necessary
Marc
@MWBauer
Sep 06 2017 03:56
tho it doesn't matter. I get the same response.
repeat is what should be returned.
repeat is where the concat should happen.
@JustCodeItBen there are 9 letters
williamsb
@williamsb
Sep 06 2017 03:58
@MWBauer your main error is on line 5
sorry line 3
Marc
@MWBauer
Sep 06 2017 03:58
ou
oy
you no like the for loop?
williamsb
@williamsb
Sep 06 2017 03:59
line 4 -__ - sorry
Marc
@MWBauer
Sep 06 2017 03:59
Now you're just playing with e.
me
I'm not concatting properly
is it more than just + between each iteration?
do I need a concat command?
williamsb
@williamsb
Sep 06 2017 04:01
it's the num[i]
JustCodeItBen
@JustCodeItBen
Sep 06 2017 04:01

@MWBauer it says

Create a single regex that matches all characters that are not a number or a vowel. Remember to include the appropriate flags in the regex. I'm assuming the returned value is suppose to return all characters that isn't in the regex itself.

Marc
@MWBauer
Sep 06 2017 04:02
spaces are characters. So drop the 3 the I the I and the e. even the period is a character.
@williamsb How do I capture the iteration and add it to the growing str/
?
williamsb
@williamsb
Sep 06 2017 04:05
you can't do num[i] because num is a number
Marc
@MWBauer
Sep 06 2017 04:05
@JustCodeItBen from what you've posted it wants to know which of the characters are not vowels or numbers. So minus those things
williamsb
@williamsb
Sep 06 2017 04:05
@MWBauer usually num[i] are done with arrays
Marc
@MWBauer
Sep 06 2017 04:05
@williamsb ok
I hear ya'
so, make a variable that captures the iteration and then adds it?
williamsb
@williamsb
Sep 06 2017 04:08
why not use newStr ?
it's initial value based on your line 2 is str
so just add str again for each loop
so just to be more clear: each time you loop, you add str to newStr
Marc
@MWBauer
Sep 06 2017 04:11

function repeatStringNumTimes(str, num) {
  var repStr;
  var newStr = String(str);
  for (var i = 0; i < num; i++) {
    repStr = newStr += str;
  }  return repStr;
}
Yeah. it works. But it's giving me 1 too many
can I, in the for loop, do I < num-1; ?
lol
or do I take the newStr out of repStr?
repStr += str
williamsb
@williamsb
Sep 06 2017 04:13
repStr = newStr += str; , i'm not sure this is allowed and can be confusing, because it's equal to repStr = newStr = newStr + str
i would do one expression at a time
Marc
@MWBauer
Sep 06 2017 04:13
repStr += str gives me undefinedabcabcabc
williamsb
@williamsb
Sep 06 2017 04:13
repStr is not necessary because you have newStr
remove it and do i<num-1
Marc
@MWBauer
Sep 06 2017 04:15
Ok
That does work for the majority of the challenge.
Now, how do I handle neg numbers>
?
williamsb
@williamsb
Sep 06 2017 04:16
well the instructions say : Return an empty string if num is not a positive number.
Marc
@MWBauer
Sep 06 2017 04:16
I need an empty string if neg number
yes
Shouldn't the loop take care of that>
?
You can't loop negative times, right?
williamsb
@williamsb
Sep 06 2017 04:17
so on the second line i would do that, when you return "" the function won't go through the rest of the code so you don't have to worry about it returning newStr
that's why you would write that expression before the for loop that you don't want to run
does that make sense?
Marc
@MWBauer
Sep 06 2017 04:23
function repeatStringNumTimes(str, num) {
  var newStr = String(str);
  for (var i = 0; i < num-1; i++) {
    newStr += str;
  }  return newStr;
}
try that again
williamsb
@williamsb
Sep 06 2017 04:24
you need an if statement on line 2
for negative number check
Marc
@MWBauer
Sep 06 2017 04:25
if num < 0 return "";
williamsb
@williamsb
Sep 06 2017 04:25
correct
Marc
@MWBauer
Sep 06 2017 04:26
nice
thanks
thanks @williamsb
CamperBot
@camperbot
Sep 06 2017 04:26
mwbauer sends brownie points to @williamsb :sparkles: :thumbsup: :sparkles:
api offline
Marc
@MWBauer
Sep 06 2017 04:26
stupid api
remind me to kick your api
williamsb
@williamsb
Sep 06 2017 04:27
once it returns "", the function won't procede any further into the for loop
Marc
@MWBauer
Sep 06 2017 04:27
right
I actually knew that, but hadn't thought of it.
THis is why I had a hard time in physics. There are so many formulas and variables and trying to remember what var made up which formula and how to get from one to the next.....
This is the same thing. I make a notebook so that I can look back easily and see what I've done and see how I can implement
Time to truncate
williamsb
@williamsb
Sep 06 2017 04:28
@MWBauer yeah, it's one thing to learn it in theory another to actually know how to implement it into an algorithm
Marc
@MWBauer
Sep 06 2017 04:28
Just kidding. It's time to get to bed.
Thanks for helping me end on a high note
williamsb
@williamsb
Sep 06 2017 04:29
@MWBauer see ya
@MWBauer no problem
Claudio Restifo
@Marmiz
Sep 06 2017 04:33
@MWBauer You know that there's a JS method to repeat strings?
Makes what you tried to accomplish way easier:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
Markus Kiili
@Masd925
Sep 06 2017 04:55
@Marmiz Too easy :boat:
Claudio Restifo
@Marmiz
Sep 06 2017 05:01

@Masd925 right... so is that considered cheating? :satisfied:
I can always:

const f = (str, n) => {
  let nstr;
  for(var i = 0; i <= n; i++) {
    nstr = str.repeat(i);
  }
  return nstr;
};

best.
function.
ever.

Markus Kiili
@Masd925
Sep 06 2017 05:04
@Marmiz Yes, that certainly made it not too easy ;)
Claudio Restifo
@Marmiz
Sep 06 2017 05:04
@Masd925 we can always go deeper
Markus Kiili
@Masd925
Sep 06 2017 05:05
@Marmiz JSFuck ?
piteto
@piteto
Sep 06 2017 05:07
lol, wut
Adam Faraj
@adamfaraj
Sep 06 2017 05:07
i need help with something
when you change the city, the first weather icon will stay and show the current weather icon of the new city
Markus Kiili
@Masd925
Sep 06 2017 05:09
piteto
@piteto
Sep 06 2017 05:09
@Masd925 have you seen this one?
console.log([[][[]]+[]][+[]][++[+[]][+[]]]); // 'n'
:)
Now I click on the link, guessing you have
Markus Kiili
@Masd925
Sep 06 2017 05:11
@piteto Yes.
Claudio Restifo
@Marmiz
Sep 06 2017 05:13

@Masd925

const f = (str, n) => {
  let nstr = '';
  while(n > 0) {
    n--;
    nstr += str;
   f(str, n);
  }

  return nstr;
};

Told ya we could have gone deeper

Now we need one with a Promise and one with a Curry :)
Markus Kiili
@Masd925
Sep 06 2017 05:16
@Marmiz Useless recursion is always good. Expecially with JS. Makes sure your browser has enough resources. Should have that on every function.
Daniel Romero
@Ranacode
Sep 06 2017 06:53
@Ranacode
How can I protect the username && password to access my mongodb database=
?
I mean, I have the connection with the mongoose library and my credentials are on plain text
anyone who can see the code, can access to the database
Sean
@seanreeise
Sep 06 2017 07:00
does anybody know a good way to decrease and increase a HTML element by 1 with two separate buttons as long as it is not less than 0 or some number.
Markus Kiili
@Masd925
Sep 06 2017 07:01
@Ranacode I am not an expert, but I think they are sometimes put on environment variables.
Coy Sanders
@coymeetsworld
Sep 06 2017 07:02
@seanreeise build the logic into javascript
Sean
@seanreeise
Sep 06 2017 07:17
@coymeetsworld right. I used an if statement to stop the increase of the number but when I use an if statement on the decrease it resets it to 0 instead of the previous number. Maybe I need to use parseInt on the decrease I am guessing.
Coy Sanders
@coymeetsworld
Sep 06 2017 07:18
or maybe something wrong with your if statement logic
for decrease you just need to check if number is already 0, although if you're doing the pomodoro zipline which it sounds like you are I would make that number a non-zero as the limit
since a pomodoro is pointless with 0 min allocated for work or break
Sean
@seanreeise
Sep 06 2017 07:21
Ok ill try that. and yes I am doing the pomodoro zipline.
Claudio Restifo
@Marmiz
Sep 06 2017 07:23
@Ranacode move them as ENV variables
Sean
@seanreeise
Sep 06 2017 07:25
@coymeetsworld Well I don't know how I didnt think to try not equal to 0 but thanks
CamperBot
@camperbot
Sep 06 2017 07:25
seanreeise sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
api offline
Coy Sanders
@coymeetsworld
Sep 06 2017 07:26
np
Sean
@seanreeise
Sep 06 2017 07:28
Oh right now just change it to 1 since no ones counting down from 0 haha
Coy Sanders
@coymeetsworld
Sep 06 2017 07:37
right, but if they try just catch that in your javascript and dont make any changes to the DOM
Morchid Chellali
@Morched23MJ
Sep 06 2017 07:41
In the tic tac toe game, how to add X or O? What's the pattern for that?
I used on click, but that works only when page loads. :l
Sean
@seanreeise
Sep 06 2017 07:42
@coymeetsworld So you saying don't set a value like starting at 1 in the DOM for the timer so they cant change it?
Coy Sanders
@coymeetsworld
Sep 06 2017 07:43
if the timer is at 1 and someone attempts to decrement it, don't modify the value
Claudio Restifo
@Marmiz
Sep 06 2017 07:43
@Morched23MJ if you divide the board into sections, you can listen for click on that section and perform your action there
something like:
'top_right_square' on click (
 add X or O
)
Coy Sanders
@coymeetsworld
Sep 06 2017 07:43
since you don't want to go to 0 or less
you could alternatively disable the decrement button when said timer is at 1, and enable it back when timer is > 1, up to you on how you want to handle UX
Sean
@seanreeise
Sep 06 2017 07:44
Oh right, yep I got what you mean.
I set the value equal to 1 and then two separate functions for increments and decrements which does not allow for going below 1.
Coy Sanders
@coymeetsworld
Sep 06 2017 07:48
increment logic you don't need to worry about going below 1
just decrement
Morchid Chellali
@Morched23MJ
Sep 06 2017 07:48
@Marmiz, thanks
CamperBot
@camperbot
Sep 06 2017 07:48
morched23mj sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
api offline
Coy Sanders
@coymeetsworld
Sep 06 2017 07:48
increment you may want to create an upper bound though, like you don't want breaks to go too long
Morchid Chellali
@Morched23MJ
Sep 06 2017 07:48
api offline? O.o
Sean
@seanreeise
Sep 06 2017 07:50
I set it to 25 according to the zipline. 25 minutes is what max should be if I am not mistaken. so only numbers between 1-25 @coymeetsworld
I just realized it has to be 25 minutes not between 25 minutes and breaks are at certain times. Is that what you meant
Sean
@seanreeise
Sep 06 2017 07:56
I re-read it because I missed part of it. You have a timer already at 25 minutes and it will start will also being able to customize one. Now I just have to put int the timer and start features.
Ahmed raza
@Raza403
Sep 06 2017 09:30
Hi Need little help, Bug in one line is stopping me complete "Wherefore art thou" challenge. Bug is on line 37 of code which is never true while it should be, I have checked this code through debugger. Here is the code https://repl.it/KjvR/2
Claudio Restifo
@Marmiz
Sep 06 2017 09:36
@Raza403 object keys brigs with them many more values than just the 'key' string (like pointer and stuff).
Thus in JS you cannot compare two object with a === operator.
You can however serialize them with JSON.stringify and then compare those
Coy Sanders
@coymeetsworld
Sep 06 2017 09:43
@seanreeise the instructions doesn't say it has to be 25 minutes, it just says you need to be able to set it to 25 minutes
it can be any number
but realistically somewhere between 20-60 minutes
I think you're over thinking this
go check out a pomodoro timer online, theres hundreds if not thousands of them
Stephen James
@sjames1958gm
Sep 06 2017 09:46
@Raza403 I would suggest you just loop over the source keys, not the collection keys.
Per the instructions the valid collection object has to have all the source keys (but it can have additional keys and still be valid)
Ahmed raza
@Raza403
Sep 06 2017 09:47
OK thanks @sjames1958gm @Marmiz , I am working on it
CamperBot
@camperbot
Sep 06 2017 09:47
raza403 sends brownie points to @sjames1958gm and @marmiz :sparkles: :thumbsup: :sparkles:
api offline
api offline
Razvan Jackson
@RazvanJackson
Sep 06 2017 10:31
Hey
How can i add the same navbar to every page
with node.js?
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 10:44
partials
do you know express @RazvanJackson ?
expressjs
handblebarsjs*
hbs.registerPartials(__dirname + "/views/partials");
<!DOCTYPE html>
<html>
  <head>
    <meta charset ="utf-8">
    <title>Portfolio</title>
  </head>
  <body>
        {{> header}}
    <p>{{message}}</p>
    {{> footer}}
  </body>
</html>
then I call it like this {{> footer}}
in the footer I have this
<footer>
<p>Created by Tiago Correia - Copyright {{getCurrentYear}}</p>
</footer>
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 10:50
all you have to do is make is a parcial
then {{> partialname}}
if you need help about setting it up pm me, probably didnt explained it clearly
Razvan Jackson
@RazvanJackson
Sep 06 2017 10:54
@tiagocorreiaalmeida ty
CamperBot
@camperbot
Sep 06 2017 10:54
razvanjackson sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
api offline
Gokula Krishna
@AKX-X-32
Sep 06 2017 11:37
hi guys, I'm facing a design challenge in game of life project. is it a good idea to change the speed of the simulation via this.ref ?
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:18
Why @camperbot say api offline?
Markus Kiili
@Masd925
Sep 06 2017 12:18
@RoniqueRicketts camperbot is resting apparently.
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:19
Lol. Guess he is calling on sick today or the storm frighten him.
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:25
@Masd925 Hallo!
Markus Kiili
@Masd925
Sep 06 2017 12:26
@Lumexralph Good evening.
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:26
@Masd925 FCC is not as hot as before, are they changing some stuffs? or is there a new direction?
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:27
@Lumexralph yes things are changing
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:27
remember this place is always on fire :fire:
@RoniqueRicketts please fill me in
Markus Kiili
@Masd925
Sep 06 2017 12:27
@Lumexralph I don't follow such things too much.
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:28
@Masd925 same here, think some guys are abreast with FCC news
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:28
@Lumexralph beta.freecodecamp.com
they are working on new content, new certificates, new languages, machine learning, lot and lots more fun stuff. Full stack dev at its highest. :)
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:30
@RoniqueRicketts i know beta version but not started any yet, still on my advanced frontend projects which I have pended for a while due to a change in learning curve
Ahmad Abdolsaheb
@ahmadabdolsaheb
Sep 06 2017 12:30
hi everyone, I have a stupid question regarding linking stylesheet to html
I link the css file in the head of the html file which is in the same directory with this
<link rel="stylesheet" type="text/css" href="styles.css">
and style the body in the css file however nothing happens
here is the code, it is very short
https://github.com/ahmadabdolsaheb/comp-web-
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:33
@Lumexralph well you don't have to put your learning on pause. What I am currently doing is to do all the new projects from beta. So when it launch I'll have the first 2 certificates. Also might do all projects in reactjs for the practice of react.
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:33
@ahmadabdolsaheb are you sure it didn't work? check your DevTool console
Ahmad Abdolsaheb
@ahmadabdolsaheb
Sep 06 2017 12:34
@Lumexralph let me see
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:38
@RoniqueRicketts i'm building 2 projects and it's a fullstack web app and FCC knowledge is not sufficient enough , had to wander a bit.... when I'm done i'll sure love to resume my projects
Kelechi Chinaka
@ke1echi
Sep 06 2017 12:40
congrats @Chrono79 on your 6000 CW honour :clap:
:wave: guys
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:41
@Lumexralph that's cool man. What backend language are you using? I know fcc is not enough you will have to suplente fcc with additional resources. But fcc is a good curriculum to get newbies like myself started
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 12:41
For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be
sortByHeight(a) = [-1, 150, 160, 170, -1, -1, 180, 190]. how can I avoid chaging those array positions?
duplicate the inial array
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:42
@RoniqueRicketts guess? :smirk:
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 12:42
nm that wouldnt work
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:42
when is started fcc I knew nothing and in spacw of a year and some months I landed an internship that may turn out to be my first job. :)
@Lumexralph php or nodejs?
Kelechi Chinaka
@ke1echi
Sep 06 2017 12:42
cool @RoniqueRicketts
Ahmad Abdolsaheb
@ahmadabdolsaheb
Sep 06 2017 12:42
@Lumexralph not sure why but it was not working a few minutes ago. thanks for your help
CamperBot
@camperbot
Sep 06 2017 12:42
ahmadabdolsaheb sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
api offline
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:43
@kelechy it's really cool but I have to stop learning react and learn php and codeignighter
@ahmadabdolsaheb looks like Camper bot is sick today
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:44
@tiagocorreiaalmeida changing the elements but not the index?
@RoniqueRicketts Node.js
@kelechy you and CW.... algorithms all the way :smile:
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 12:45
like if 160 is bigger than 150 then the place of 150 becomes the place of 160 right?
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:45
@Lumexralph sick, I can't wait to learn nodejs fully so I can start at least 1 out of my 6 pending personal projects
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:46
@tiagocorreiaalmeida that's what will happen by default but you don't want their positions to change, right?
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:46
How long did it take you to learn nodejs after learning js?
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:46
@RoniqueRicketts just dive in man!
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 12:46
I just want thieir values to change like
place them in order and ignroe the -1
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:47
@Lumexralph I have have to pause for a while and learn php and codeignighter my internship
Kelechi Chinaka
@ke1echi
Sep 06 2017 12:48
:smile: bro problem solving has been fun.. algorithm is key @Lumexralph
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:48
@RoniqueRicketts still learning NodeJS and it's concept but using it was right away for me, it's still JS just in different environment, if you know JS , NodeJS won't be daunting
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:49
Omg I just realize that w3schools.com now have a nodejs tutorial. Was this there all alomg?!?!
Kelechi Chinaka
@ke1echi
Sep 06 2017 12:49
op the day is goin well @Lumexralph
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 12:50
@Lumexralph I'm not the best at js but I know the basics and can read the documentation and get some intermediate apps built.
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:50
@RoniqueRicketts it's still same chrome V8 engine used for NodeJS, to be honest, React is what's bringing me back to the front side
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 12:51
to do frontend developemtn on a company what would be the things you woul need to baster beside html/css/js/jquery
do
Ogundele Olumide
@Lumexralph
Sep 06 2017 12:52
@kelechy day is going great, it's good to be able to use computer language to solve problems but what I have discovered so far, as you build projects you'll learn new algorithms
@tiagocorreiaalmeida still more to that I think.... there's the React bubble, there's Angular
@tiagocorreiaalmeida but i'll personally suggest knowing JS well, CSS and HTML, the rests are just libraries and frameworks that builds on that foundation
@tiagocorreiaalmeida knowing how the internet works, the communication protocols too I think
Kelechi Chinaka
@ke1echi
Sep 06 2017 12:58
if you know how to solve those problems u encounter when u build stuffs, then you can build @Lumexralph
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:01
so how would you sorte the array without moving the -1
Ogundele Olumide
@Lumexralph
Sep 06 2017 13:03
@kelechy :smile: ..... maybe when I'm done with my projects I'll go back to building my algorithm muscles, I just think the main thing is to have the ability to use the language to efficiently solve a problem but as you start learning you'll realize that algorithm is just part of the rooms that makes the whole app, once you're confident enough with your problem solving skills, there's a lot to be learned
Kelechi Chinaka
@ke1echi
Sep 06 2017 13:04
sure...always a lot to learn... remember everyday is a learning day :smile: @Lumexralph
Ogundele Olumide
@Lumexralph
Sep 06 2017 13:06
@kelechy yep, I'm enjoying it
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:08
can you guys point some frontend projects ideas?just to pratice, my trouble is always find a idea of what to do, that's why I make exercises on codefights :D
Ogundele Olumide
@Lumexralph
Sep 06 2017 13:09
@tiagocorreiaalmeida how about starting with FCC ?
studentzero
@studentzero
Sep 06 2017 13:09
Can I change this line so it capitalizes the first letter of every word but doesn't remove all non-first letters of the words?
x[i] = words[i].charAt(0).toUpperCase();
Kelechi Chinaka
@ke1echi
Sep 06 2017 13:12
why not follow fcc map @tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:12
allready eneded frontend fcc part
learning nodejs/express on a udemy course but would like some more frontend idea projects
Ogundele Olumide
@Lumexralph
Sep 06 2017 13:15
@studentzero yes, adding the substrings
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 13:17
@Lumexralph yes I know it's va engine. I am still getting better at react before I jump into nodejs.
Nothing better than modelling a tool
Ogundele Olumide
@Lumexralph
Sep 06 2017 13:27
@RoniqueRicketts cool..... let's keep learning
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:39
guys one question
sorted.splice(0,0,-1)
wouldnt this go to the array
first position
remove 0 elements
and add -1
to first postion?
Stephen James
@sjames1958gm
Sep 06 2017 13:43
@tiagocorreiaalmeida Yeah. seems so
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:44
for(let j = 0; j < tree.length; j++){
   sorted.slice(tree[j],0,-1);
        console.log(sorted);
}
doesnt seems to work hum
Stephen James
@sjames1958gm
Sep 06 2017 13:44
array = [1, 2, 3]
array.splice(0, 0, -1)
array
[-1, 1, 2, 3]
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:46
yeah that was the idea
gonna show you the full code and the exercise
function sortByHeight(a) {
    var tree = [];
    var sorted = [];
    for(let i = 0; i < a.length; i++){
        if(a[i] === -1){
           tree.push(i);
        }else{
            sorted.push(a[i]);
        }
    }
    sorted = sorted.sort((a,b)=>{
        return a - b;
    });
    for(let j = 0; j < tree.length; j++){
       sorted.slice(tree[j],0,-1);
    }
    return sorted;
}
For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be
sortByHeight(a) = [-1, 150, 160, 170, -1, -1, 180, 190].
-1 are the "trees" values the ones who can't be moved
Moisés Man
@moigithub
Sep 06 2017 13:48
@tiagocorreiaalmeida u can gooogle a random website print screen save on a file then try to make html+css+ some javascript layout (mobile + desktop version)
or find some free pdf/png/psd web templates
..and try to do without libraries pure css.. probably pick some framework like BEM (im learning this atm)
then make another version with libraries .. bootstrap, materialize, foundation, bulma
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:49
that's atually a good idea thanks mate
Stephen James
@sjames1958gm
Sep 06 2017 13:51
@tiagocorreiaalmeida Why are you calling slice when your example showed splice
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:53
...
my bad
no idea why I missed a p there
the idea was splice since the start
eyes closed, thanks @sjames1958gm
CamperBot
@camperbot
Sep 06 2017 13:53
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:53
is camper bot ok?
Diego Mayer
@Chrono79
Sep 06 2017 13:54
@kelechy thanks :+1:
CamperBot
@camperbot
Sep 06 2017 13:54
chrono79 sends brownie points to @kelechy :sparkles: :thumbsup: :sparkles:
api offline
Moisés Man
@moigithub
Sep 06 2017 13:54
botstatus
CamperBot
@camperbot
Sep 06 2017 13:54
All bot systems are go!
botVersion: 0.0.12
env: prod
botname: camperbot
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 13:54
no brownies
Diego Mayer
@Chrono79
Sep 06 2017 13:59
@tiagocorreiaalmeida about your sortByHeight code, you could use return a.map(h=>h === -1 ? -1 : sorted.shift());
that way, you only replace the trees that can be moved with the sorted values
Gokula Krishna
@AKX-X-32
Sep 06 2017 14:10
Guys I have restructured my game of life code. Can you please review it? https://codepen.io/gkrishna/full/NvBJXZ/
Diego Mayer
@Chrono79
Sep 06 2017 14:11
@AKX-X-32 I don't like the shakiness of the top "bar", try setting a fixed width there
and it seems to break when you hit clear and try to run it again (or when you choose a different board size)
Diego Mayer
@Chrono79
Sep 06 2017 14:31
when you use clear, you kill all the cells, unless you use spontaneus generation, the board will stay empty
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 14:41
@Lumexralph Yeah I will continue to learn man. Hopefully I will be doing nodejs by December
Brice Afonso
@Qazare
Sep 06 2017 14:45

Hey everyone. I'm doing the Weather App and I'd like to only use vanilla JS, no jQuery. I'm trying to do a very simple thing just to test out but I've been stuck on it for the past hour, it's driving me mad. I don't understand what I'm doing wrong with this simple code :

let title = document.getElementById("main");
       title.onclick(function() {
         title.innerHTML = "test";
       } )

I have a title and I'd like to change its text when I click on it. That's it. Any idea ?

Ogundele Olumide
@Lumexralph
Sep 06 2017 14:56
@Qazare tried using innerText ? or textContent ?
Brice Afonso
@Qazare
Sep 06 2017 14:57
Apparently it works with addEventListener method, not onclick.
Ogundele Olumide
@Lumexralph
Sep 06 2017 14:57
@Qazare cool, i prefer the latter
Brice Afonso
@Qazare
Sep 06 2017 14:58
I don't understand why though, shouldn't onclick work as well ?
LydaTech
@lydatech
Sep 06 2017 14:59
@Qazare
document.getElementById("main").addEventListener("click", myFunction);

function myFunction() {
    document.getElementById("main").innerHTML = "test!";
}
Brice Afonso
@Qazare
Sep 06 2017 15:01
this is from MDN about onclick : "Because it was essentially part of DOM 0, this technique for adding event listeners is very widely supported and requires no special cross–browser code. It is normally used to register event listeners dynamically unless the extra features of addEventListener() are needed."
LydaTech
@lydatech
Sep 06 2017 15:01
@Qazare
document.getElementById("main").onclick = function() {myFunction()};

function myFunction() {
    document.getElementById("main").innerHTML = "test";
}
Stephen James
@sjames1958gm
Sep 06 2017 15:02
@Qazare I believe that onclick is a property.
title.onclick = function() {
         title.innerHTML = "test";
       }
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:02
@Qazare i think this is what you might have done
let title = document.getElementById("main");
       title.onclick = function() {
         title.innerHTML = "test";
       } ;
@sjames1958gm you got there before me..... :smirk:
Stephen James
@sjames1958gm
Sep 06 2017 15:03
bwa ha ha :)
Diego Mayer
@Chrono79
Sep 06 2017 15:03
couldn't we use this there?
LydaTech
@lydatech
Sep 06 2017 15:03
you arent separating out your logic
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:03
@sjames1958gm ha ha
Brice Afonso
@Qazare
Sep 06 2017 15:03
Oh I missed this detail on the MDN page :worried:
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:03
@sjames1958gm how're you?
Stephen James
@sjames1958gm
Sep 06 2017 15:03
@Lumexralph Good, well not so good, the Chelsea game is behind a pay service this weekend :cry:
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:04
@sjames1958gm YouTube highlight :joy:
Brice Afonso
@Qazare
Sep 06 2017 15:04
well, thanks for your help @lydatech, @Lumexralph and @sjames1958gm !
CamperBot
@camperbot
Sep 06 2017 15:04
qazare sends brownie points to @lydatech and @lumexralph and @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
api offline
api offline
LydaTech
@lydatech
Sep 06 2017 15:04
sigh... back to working
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:04
@sjames1958gm Man Utd ain't going to find it easy in Stoke
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 15:05
@Qazare @camperbot has called in sick today
Stephen James
@sjames1958gm
Sep 06 2017 15:05
@Lumexralph Neeed them to drop points
Diego Mayer
@Chrono79
Sep 06 2017 15:05
let title = document.getElementById("main");
title.onclick = function() {
     this.innerHTML = "test"; //like this
};
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:05
@sjames1958gm :smirk: all the best
@sjames1958gm thinking City will drop points too
Stephen James
@sjames1958gm
Sep 06 2017 15:07
These are games where I root for a tie :)
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:08
@sjames1958gm City defence and attack is still sleeping, liverpool defence is asleep but attack is wide awake
Brice Afonso
@Qazare
Sep 06 2017 15:08
@Chrono79 you're right, I thought about that and tried it out but with the bad syntax, so I moved on. It works too !
Stephen James
@sjames1958gm
Sep 06 2017 15:08
@Lumexralph When LFC gets going their offense is thrilling.
Stuhl
@Stuhl
Sep 06 2017 15:09
hey guys I have a question about MVC
Diego Mayer
@Chrono79
Sep 06 2017 15:10
ask away, maybe someone can answer it
Stuhl
@Stuhl
Sep 06 2017 15:10
I tried to programm a bit and want to get some feedback if this is the right way to code it: http://playcode.io/mvc?tabs=console&script.js&output
Feels right to me but I think the part with the eventListener's is wrong
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:12
@sjames1958gm yes! their attack and they're able to keep Coutinho
Jason Luboff
@JLuboff
Sep 06 2017 15:13
Hmmm did camperbot die?
Diego Mayer
@Chrono79
Sep 06 2017 15:14
@Stuhl from the very little I know about MVC, I don't think the View should request data from the Model directly, the Controller should do that
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:15
@Stuhl what makes you think the part is wrong? you could cache the document.getElementById("inputText")
@JLuboff on vacation
Stuhl
@Stuhl
Sep 06 2017 15:15
@Chrono79 I'm not entirely sure, I also read that the View shouldn't know about the model or controller at all, but some examples I watched show otherwise
Diego Mayer
@Chrono79
Sep 06 2017 15:15
@JLuboff it's alive, but its cookie jar is empty
Stuhl
@Stuhl
Sep 06 2017 15:16
@Lumexralph I believe that the eventListener should'nt be outside but rather inside the Controller
Jason Luboff
@JLuboff
Sep 06 2017 15:16
@Lumexralph @Chrono79 Well he best be returning soon with more cookies otherwise...choas will ensue
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:18
@JLuboff :joy:
Jason Luboff
@JLuboff
Sep 06 2017 15:18
Whats everyone working on today?
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:19
@JLuboff a NodeJS project.... doing authentication and authorization, presently trying to use Twitter as another way to sign in to the app then branched by to solve an algorithm
@JLuboff you know when you see an algorithm and you're like piece of cake till you start solving then you realize it's a big deal
@JLuboff what's happening at your end?
Jason Luboff
@JLuboff
Sep 06 2017 15:23
@Lumexralph I just got my local authentication using passport and vanilla mongo working fully yesterday! I hate mongoose, and all the tutorials use mongoose so I made my own with vanilla! Excited that I got it working :joy:
I'm going to make a boilerplate for it
And ya, algorithms area love/hate thing for me
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:24
@JLuboff lol.... why the hate on mongoose :smile:
Jason Luboff
@JLuboff
Sep 06 2017 15:24
Mongoose just never works for me, and the documentation sucks. At least I understand how to use mongo
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:25
@JLuboff lol.... but ORM will help you eventually
@JLuboff tell me how you used Mongo and passport, did you apply it to any route in your app ?
Jason Luboff
@JLuboff
Sep 06 2017 15:28
@Lumexralph You can see in my repo: https://github.com/JLuboff/GameTrader (this is for local auth) you'll see code in app.js and routes\routes.js
Diego Mayer
@Chrono79
Sep 06 2017 15:28
Working with PHP and trying to do things I have no idea how to do (basically everyday work ;))
Jason Luboff
@JLuboff
Sep 06 2017 15:28
I don't have a lot done for the app yet, but you can see where I check auth, for example, the /profile route (isLogged is a function that checks if an user is logged in)
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:29
@JLuboff okay, just curious to see how easy it was without an ORM
Jason Luboff
@JLuboff
Sep 06 2017 15:29
@Chrono79 Psh.. PHP...ain't nobody got time for that
Stephen James
@sjames1958gm
Sep 06 2017 15:29
Trying to incorporate firebase messaging into our android app
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:29
@Chrono79 imagination
@sjames1958gm heard so much about google firebase
Diego Mayer
@Chrono79
Sep 06 2017 15:30
They change specifications whenever they feel like too, so once you modelled something, you have to rethink it again
Jason Luboff
@JLuboff
Sep 06 2017 15:30
@sjames1958gm Do or do not, there is no try
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:32
@JLuboff cool, seen..... been using vanilla Mongo for a while, presently using mongoskin
Jason Luboff
@JLuboff
Sep 06 2017 15:34
@Lumexralph Whats the advantage of mongoskin?
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:34
@JLuboff just like mongoose you hate it's an ORM too
Jason Luboff
@JLuboff
Sep 06 2017 15:35
Oh, ok
Daniel Romero
@Ranacode
Sep 06 2017 15:40
Hey guys I have one question working with gulp
I want to uglify all the js files inside my directory but I don't want to concat them, just output in separate files in another folder
how can I achieve this without make an individual task for each one?
Christopher McCormack
@cmccormack
Sep 06 2017 15:45
@Ranacode haven't used gulp, just webpack, can you just remove the concat method or is it default?
Ogundele Olumide
@Lumexralph
Sep 06 2017 15:47
@cmccormack hey man :wave:
Christopher McCormack
@cmccormack
Sep 06 2017 15:47
@Lumexralph hi!
Daniel Romero
@Ranacode
Sep 06 2017 15:47
Lol, the thing that I wanted, gulp did it by default jaja
thanks @cmccormack
CamperBot
@camperbot
Sep 06 2017 15:47
ranacode sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Sep 06 2017 15:47
@Ranacode :D
I might have to check out gulp, looks cleaner in some ways than webpack
Daniel Romero
@Ranacode
Sep 06 2017 15:48
For small projects I would choose gulp than webpack
The two are great
I think webpack It gives you a more complex customization
Christopher McCormack
@cmccormack
Sep 06 2017 15:49
I'll check it out. I am close to finished setting up my own webpack environment, even if a few things are still busted
Jason Luboff
@JLuboff
Sep 06 2017 15:52
@cmccormack You've been close for a week!
Christopher McCormack
@cmccormack
Sep 06 2017 15:52
@JLuboff haha I started actually working on a project along with my new setup, so I'm paying less attention. 80% working is still enough to build something I guess
Diego Mayer
@Chrono79
Sep 06 2017 15:52
@JLuboff it's still close ;)
Jason Luboff
@JLuboff
Sep 06 2017 15:52
:joy:
Christopher McCormack
@cmccormack
Sep 06 2017 15:53
I'll probably never finish, something shinier will come along to take my attention
Jason Luboff
@JLuboff
Sep 06 2017 15:53
Eh I find I complete one project only to start working on another and start thinking "huh.. I should go back and change XXX on last project now that I know how to do it this way"
Christopher McCormack
@cmccormack
Sep 06 2017 15:54
@JLuboff yeah totally - I have this urge to go back and turn all my early js projects into React projects, but there's no real benefit other than more practice
Diego Mayer
@Chrono79
Sep 06 2017 15:55

I'll probably never finish, something shinier will come along to take my attention

Until you find your precious, that is ;)

Christopher McCormack
@cmccormack
Sep 06 2017 15:55
haha
Diego Mayer
@Chrono79
Sep 06 2017 15:56
I know exactly how you feel, I start as many courses as I find, finishing them is another story
Jason Luboff
@JLuboff
Sep 06 2017 15:56
Ya, a lot of time its minor things for me but still would make sense. Like my voting app. For the results (donut chart) I have the colors chosen randomly for each selection, HOWEVER, each refresh change it since I have it occuring on the frontend. Well for the stock chart app, I stored the color in the database...so..why wouldn't I do that for my voting app? Just stupid things like that that make sense now but I didn't think of at the time
Christopher McCormack
@cmccormack
Sep 06 2017 15:56

Anyone know how to import all Components without having to specify? I currently have an index.js that looks like this:

import Header from './Header'
import Footer from './Footer'
import Title  from './Title'
import Tooltip  from './Title'

export {Header, Footer, Title, Tooltip}

And in my App.js I want to import them without doing it like this:

import { Header, Footer, Title } from '../components/Layout'

Rather something like this:

import '../components/Layout'

But that doesn't appear to work

@JLuboff I personally like a random color scheme :D
Diego Mayer
@Chrono79
Sep 06 2017 15:58
@cmccormack could you store them in an array before exporting them?
Jason Luboff
@JLuboff
Sep 06 2017 15:58
@cmccormack Well, it's random, but I believe it was @JohnnyBizzel that made a good point that the changing colors were confusing, as you would vote and it would then change all the colors and made it a bit hard to follow
Christopher McCormack
@cmccormack
Sep 06 2017 15:59
@Chrono79 Maybe, but would that help me import into App.js without having to specify each Component? As I add more I don't want to have to keep adding them (easy enough I know...)
Diego Mayer
@Chrono79
Sep 06 2017 16:00
just a theory, not proven, maybe you can import them doing {...array}
you would be importing them all (if it works)
Christopher McCormack
@cmccormack
Sep 06 2017 16:03
I'll give that a try. For some reason the import export logic doesn't seem as intuitive as it could
This stuff is like a reverse video game, the more you work on it, the harder it gets!
@JLuboff would it change while using it?
Diego Mayer
@Chrono79
Sep 06 2017 16:06
maybe it doesn't work at all, still doing the react course
later :wave:
Christopher McCormack
@cmccormack
Sep 06 2017 16:08
@Chrono79 see ya!
Jason Luboff
@JLuboff
Sep 06 2017 16:34
@cmccormack Check it out https://votingapp-jluboff.herokuapp.com/ I haven't changed it. So if you go to a poll and then vote, you'll see the current behavior
Christopher McCormack
@cmccormack
Sep 06 2017 16:37
@JLuboff yellow other is doing well!
for editors :)
Jason Luboff
@JLuboff
Sep 06 2017 16:38
...but which one is yellow? For me, Other is orange, blue or dirt green lol
Christopher McCormack
@cmccormack
Sep 06 2017 16:38
You tell me you didn't label them :)
Maybe do Other1, Other2, or something
until you fill in the data :)
Seems to work well though! Nice
Jason Luboff
@JLuboff
Sep 06 2017 16:39
I'm not the one who added them! I just didn't do any sort of validation to ensure an existing option can't be duplicated (oops!)
Christopher McCormack
@cmccormack
Sep 06 2017 16:42
ah ok
so your login uses github auth?
Jason Luboff
@JLuboff
Sep 06 2017 16:43
For that project, ya
I used Facebook for my nightlife app. And now for my book (game) trading app I'm using local auth
Christopher McCormack
@cmccormack
Sep 06 2017 16:53
@JLuboff That's pretty cool man! Some of the option displays overlap or are too close together, but otherwise the functionality seems to be all there!
Jason Luboff
@JLuboff
Sep 06 2017 16:54
@cmccormack Thanks. This was my first Dynamic Web app, so I'd like to think I've gotten better since lol
CamperBot
@camperbot
Sep 06 2017 16:54
jluboff sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Sep 06 2017 16:56
@JLuboff I dunno I feel like my projects have just gotten bigger and more complex lately without much additional functionality to justify it :D
Jason Luboff
@JLuboff
Sep 06 2017 16:57
Hehe that could be the case for me as well but I'd like to think of it as expanding my knowledge!
Christopher McCormack
@cmccormack
Sep 06 2017 17:00
Yeah that's true. In the long run it will hopefully all be beneficial
luccifer00
@luccifer00
Sep 06 2017 17:39
hi there!
return x[1] == /\b[A-Z]/g
i cant créate a boolean with regex??
Grigor Minasyan
@gogminsam
Sep 06 2017 17:40
can someone say why is this while loop infinite? this is the cash in drawer problem
      while (change>0 && cid[0][1]>0) {
        switch (true) {
          case (change >= 100):
            if (cid[8][1]>0) {
              change -=100;
              changearr[0][1] += 100;
              cid[8][1] -= 100;
              break;
            }
          case (change >= 20):
            if (cid[7][1]>0) {
              change -=20;
              changearr[1][1] += 20;
              cid[7][1] -= 20;
              break;
            }
          case (change >= 10):
            if (cid[6][1]>0) {
              change -=10;
              changearr[2][1] += 10;
              cid[6][1] -= 10;
            break;
            }
          case (change >= 5):
            if (cid[5][1]>0) {
              change -=5;
              changearr[3][1] += 5;
              cid[5][1] -= 5;
              break;
            }
          case (change >= 1):
            if (cid[4][1]>0) {
              change -=1;
              changearr[4][1] += 1;
              cid[4][1] -= 1;
              break;
            }
          case (change >= 0.25):
            if (cid[3][1]>0) {
              change -=0.25;
              changearr[5][1] += 0.25;
              cid[3][1] -= 0.25;
              break;
            }
          case (change >= 0.1):
            if (cid[2][1]>0) {
              change -=0.1;
              changearr[6][1] += 0.1;
              cid[2][1] -= 0.1;
              break;
            }
          case (change >= 0.05):
            if (cid[1][1]>0) {
              change -=0.05;
              changearr[7][1] += 0.05;
              cid[1][1] -= 0.05;
              break;
            }
          case (change >= 0.01):
            if (cid[0][1]>0) {
              change -=0.01;
              changearr[8][1] += 0.01;
              cid[0][1] -= 0.01;
              break;
            }
          default:
            break;
        }
      }
luccifer00
@luccifer00
Sep 06 2017 17:41
in that way i return false even the x[i] is an UpperCase letter
alpox
@alpox
Sep 06 2017 17:41

@luccifer00 A regex is an object. This means that it would return true only if both are the same instance of the object:

var regex = /abc/g;
return regex == regex;

And ONLY in this case

Grigor Minasyan
@gogminsam
Sep 06 2017 17:41
this big switch is decreasing change due, increasing change array, and decreasing cash in drawer
alpox
@alpox
Sep 06 2017 17:42
@luccifer00 If you want to test a string for matches of the regex you have to use /abc/g.test(str);
luccifer00
@luccifer00
Sep 06 2017 17:45
@alpox thanks! so ONLY booleans between regex, becouse they r objects, ... i dont need to test! but it is good to know it!MyRegexCode.test(str)`
CamperBot
@camperbot
Sep 06 2017 17:45
luccifer00 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
api offline
alpox
@alpox
Sep 06 2017 17:45
@gogminsam You can run into the case of that change < 0.01 but change > 0. Maybe with rounding problems. In that case, you loop infinite
Grigor Minasyan
@gogminsam
Sep 06 2017 17:49
@alpox so do you think change > 0.005 will work instead of change > 0?
alpox
@alpox
Sep 06 2017 17:49
@gogminsam go sure that there can be no case in which it even can loop infinite
The way of is maybe enough is never good enough
Grigor Minasyan
@gogminsam
Sep 06 2017 17:54
@alpox i put change = 0; inside default case, but i dont like this way, because it is assuming that change is between 0 and 0.005 and this way there is no infinite loop, but in this case change array contains one less penny
how do i make this clock rotate between my set colors that i want?
i'm a little confused on that part
Stephen James
@sjames1958gm
Sep 06 2017 18:01

@lawrencelee93 Create an index variable that loops over the array.
var index = 0;

then

index = (index + 1) % colorArray.length

lawrencelee93
@lawrencelee93
Sep 06 2017 18:03
i'm not sure where to go with that
Stephen James
@sjames1958gm
Sep 06 2017 18:07
@lawrencelee93 When you want to change colors you use index with your color array
I assume you meant you array at the top of the js?
lawrencelee93
@lawrencelee93
Sep 06 2017 18:07
yes that is correct
Stephen James
@sjames1958gm
Sep 06 2017 18:09

Right after your hexColor variable:

var hexColor = document.getElementById('hex-color');
var colorIndex = 0;

then when you set the color: (the % colors.length cause the index to loop back to zero at the end of the array)

document.body.style.backgroundColor = colors[colorIndex];
colorIndex = (colorIndex + 1) % colors.length
lawrencelee93
@lawrencelee93
Sep 06 2017 18:12
hmmm
it's still running the colors that i didn't set :/
lawrencelee93
@lawrencelee93
Sep 06 2017 18:33
thank you!
i got it too work @sjames1958gm
Stephen James
@sjames1958gm
Sep 06 2017 18:33
@lawrencelee93 :+1:
luccifer00
@luccifer00
Sep 06 2017 18:36
function spinalCase(str) {
 var x= str.split("");
  var test="";
  var rege=/\W/g;
  for(var i=0; i<x.length;i++){
if(x[0]==x[i].toUpperCase()){
  test += x[0];
}else if(x[i] == " " ||x[i] == "_" || x[i] == "-"){
     test+= x[i].replace(x[i], "-");
    }else if(x[i]==x[i].toUpperCase()){
        if(x[i-1] ==x[i-1].toLowerCase()&&x[i-1] !="-"&&x[i-1] !="_"&&x[i-1] !=" "){
       test+= "-"+x[i];
        } else{
         test+= x[i];

        }

    }else if(x[i]==x[i].toLowerCase()){
      test+=x[i];
    }
  }  
  return test.toLowerCase();
}

spinalCase('This Is Spinal Tap');
here is probably the worst way to complete the challenge Spinal Tap, or i think so.... i have to ask, is this the way to complete it?? using if eslewith .replace() ????
critics are wellcome! :smile:
Diego Mayer
@Chrono79
Sep 06 2017 19:25
@luccifer00 certainly there are better ways of doing it
With a better regex you could do it in one line I guess, look for grouping in regex
luccifer00
@luccifer00
Sep 06 2017 19:46
@Chrono79 i see the hint from freecodecamp, and the worst thing it when i started the code, i reach something similar , but not all the matches was correct...
str = str.replace(/([a-z])([A-Z])/g, '$1 $2');
anyways, i dont understand the $1$2part is that an jquery to call some point??
Diego Mayer
@Chrono79
Sep 06 2017 19:48
$1 and $2 match the content of the ([a-z]) for $1 and ([A-Z])for $2
luccifer00
@luccifer00
Sep 06 2017 19:48
ah! ok!
Diego Mayer
@Chrono79
Sep 06 2017 19:49
so basically, when it find something like this aT it adds a space between them
luccifer00
@luccifer00
Sep 06 2017 19:52
but, i still no understand... why add a space?? if replace() brackets means (something to change, new something)
so in the ie before, if $1 and $2 match the content of the ([a-z]) for $1 and ([A-Z])for $2.... the str replace should have $1 as ([a-z]) , and $2 as ([A-Z])
Diego Mayer
@Chrono79
Sep 06 2017 20:01
@luccifer00 you add the space there so you can then replace spaces for -
luccifer00
@luccifer00
Sep 06 2017 20:10
@Chrono79 that is the part i dont understand where is the space set there.... anyways Thank you. I will accept the answer when time permits me :worried:
CamperBot
@camperbot
Sep 06 2017 20:10
luccifer00 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
api offline
Stein-T Dale
@Lofthur
Sep 06 2017 20:10
Hi I'm on the Recipe Box project and I struggle with some code in react. This is the data I put into my state javascript const ingredients = this.props.recipe.ingr.map(key => { <li>{this.props.ingr[key]}</li> });
BAhh
I will type this again ;)
Hi I'm on the Recipe Box project and I struggle with some code in react. This is the data I put into my state javascript dish_1: { name: 'Bolognese', ingr: ["Garlic", "Onion", "Tomato", "Salt", "Pepper"], desc: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' }And when I try to access a part of the ingr array i get undefined. But I can console log the whole array, but it show's up like a long string. Can someone put me in the right direction to solve this problem?
Christopher McCormack
@cmccormack
Sep 06 2017 20:14
@Lofthur if you wrap your code in backticks it's much easier to read:
```
code
```
Stein-T Dale
@Lofthur
Sep 06 2017 20:14
Sure :D
dish_1: {
        name: 'Bolognese',
        ingr: ["Garlic", "Onion", "Tomato", "Salt", "Pepper"],
        desc: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
    },
Christopher McCormack
@cmccormack
Sep 06 2017 20:15
@Lofthur { <li>{this.props.ingr[key]} should probably just be {key}
@Lofthur three backticks, on their own lines
Stein-T Dale
@Lofthur
Sep 06 2017 20:15
ahh :D
Christopher McCormack
@cmccormack
Sep 06 2017 20:15
you can edit previous posts as well
key => key represents each item in your ingredient array
also when using arrow notation you need to either omit the curly braces to return something or add the return inside the braces.
{key => key} or {key => { return key; }
Stein-T Dale
@Lofthur
Sep 06 2017 20:19
@cmccormack Will check it out. But i think this is what i have done earlier
Christopher McCormack
@cmccormack
Sep 06 2017 20:19
Ah I see why you're trying to use key - when mapping you need to have a key so do something like this:
const ingredients = this.props.recipe.ingr.map(item => <li key={item}>{item}</li> );
item will have to be unique if you do it that way, else you can append something to it if you like
Stein-T Dale
@Lofthur
Sep 06 2017 20:20
@cmccormack Jupp
Stein-T Dale
@Lofthur
Sep 06 2017 20:29
@cmccormack I tried the code, but i still get the same error (Cannot read property 'map' of undefined)
The thing i do not understand is that i have already used map on the object earlier, to split it up into the different dishes. I can access the name and the descriptions, but the array just show this error. Hardcoding a console.log to show one item from the array works but i also get undefined (two times) in the console.
Christopher McCormack
@cmccormack
Sep 06 2017 20:31
@Lofthur is it possible that it's only undefined the first time React renders your component, prior to loading the recipe?
Stein-T Dale
@Lofthur
Sep 06 2017 20:32
@cmccormack Tried another console with the code you showed me, and the undefined is gone. Sorry for not trying that before...
Christopher McCormack
@cmccormack
Sep 06 2017 20:33
@Lofthur in your first code I don't believe your array had anything in each position, as you had not returned anything within the map
> var arr = [1,2,3]
> arr.map(key=>{key})
[ undefined, undefined, undefined ]
> arr.map(key=> key )
[ 1, 2, 3 ]
Stein-T Dale
@Lofthur
Sep 06 2017 20:34
@cmccormack Yeah that could be. ;)
@cmccormack I see that you told me about the return statement and the curly braces.
@cmccormack Thanks for the help. You got me a bit further. Have to dig into it a bit more :D
CamperBot
@camperbot
Sep 06 2017 20:36
lofthur sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Sep 06 2017 20:36
yup np
Jason Luboff
@JLuboff
Sep 06 2017 20:38
I wonder if they officially killed camperbot..
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 20:42
https://codepen.io/tiagocorreia/full/JyqOQm/ can someone help me? no idea why the hover on the contact button doesnt work got a nimation there
piteto
@piteto
Sep 06 2017 20:49
@tiagocorreiaalmeida <a> elements are inline, so they don't have height/width, so scale() won't work. make it display: inline-block on hover as well and your scale transform should work.
actually, make it inline-block in the non-hover section...then the content next to it won't move around on hover
Stein-T Dale
@Lofthur
Sep 06 2017 20:52
@cmccormack Got it to work. The thing was that i did not have the ingredients array in the other dishes. When the map function tried to go over those it returned with undefined :D
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 20:52
@piteto solved thanks
CamperBot
@camperbot
Sep 06 2017 20:52
tiagocorreiaalmeida sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
api offline
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 20:52
no brownies for oyu
Christopher McCormack
@cmccormack
Sep 06 2017 20:53
@Lofthur ahh consistency :D glad you found it
Andrew Knox
@iamknox
Sep 06 2017 20:58
Screen Shot 2017-09-06 at 1.56.01 PM.png
Screen Shot 2017-09-06 at 1.57.08 PM.png
Can anyone tell me why the arrow function will leave 0 (zero the number) in the arrow but the second function takes 0 (zero) out of the array?
leave zero in the array**
Diego Mayer
@Chrono79
Sep 06 2017 21:06
@iamknox
"0" == 0 //true
"0" === 0 //false
Randell Dawson
@RandellDawson
Sep 06 2017 21:25
@iamknox - Because filter expects a boolean to be returned. When you return 0 in the non-arrow function version, that evaluates to false, so it is excluded.
Bryan Reese
@breese8009
Sep 06 2017 21:40

Guys im trying to pull the data-styleid attribute value but having trouble...
here is the var an code im trying to get it with but gettin undefined.

let styleId = $(this).parents('.styleClass').data('styleid');

function renderStyles(style) {


    let styleHtml = `
    <!-- Style information -->

    <div class="card-header styleClass" data-styleid="${style._id}"><h1>${style.type} ${style._id}</h1></div>
        <div class="card-body">
            <p class="card-title">Description: ${style.description}</p>
            <p class="card-text">Comments: ${style.comments}</p>
            <p class="card-text"><a href="${style.link}">Wiki link</a></p>
            <div class="row">
                <div class="col-sm-2">
                    <button class="btn-danger delete-style">Delete</button>
                </div>
                <div class="col-sm-2">
                    <button class="btn-info">edit</button>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">Add school</button>
    </div>

    `

    $('.styleDisplay').prepend(styleHtml);
}

```

so on click of a button, i want to console.log() the data-styleid attributes value
u would think $(this).data('styleid') would do the trick but it doesnt
piteto
@piteto
Sep 06 2017 21:44
because it isn't an object @breese8009 it's a text string, so you have to use .attr()
let styleId = $(this).parents('.styleClass').attr('data-styleid');
Bryan Reese
@breese8009
Sep 06 2017 21:45
@piteto still gettin undefined :(
piteto
@piteto
Sep 06 2017 21:46
I think we need to see more code then to make sure this part is correct: $(this).parents('.styleClass')
Christopher McCormack
@cmccormack
Sep 06 2017 21:49
@breese8009 is data-styleid="${style._id}" supposed to be a template literal? Those should use grave accents right? Or are you passing the string to use later?
Jason Luboff
@JLuboff
Sep 06 2017 21:50
@cmccormack The entire thing is a template literal
so the quotes are okay
Christopher McCormack
@cmccormack
Sep 06 2017 21:50
@JLuboff ah didn't see thanks
CamperBot
@camperbot
Sep 06 2017 21:50
cmccormack sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
api offline
Jason Luboff
@JLuboff
Sep 06 2017 21:50
I had to go double check lol
Bryan Reese
@breese8009
Sep 06 2017 21:52
@cmccormack yea its a full temp literal
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 21:55
need a little help guys
$( document ).ready(function() {
    var percentage = $(".progress").attr("progress");
    console.log(percentage);
});
got this
<span><a class="progress" progress="75"></a></span>
<span><a class="progress" progress="65"></a></span>
<span><a class="progress" progress="75"></a></span>
how can I loop all that spans
and get the value of every one of them 1 by 1?
the code I have only runs the first 1
Diego Mayer
@Chrono79
Sep 06 2017 21:57
@tiagocorreiaalmeida try storing all the class progress anchors in an array and then use a loop
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 21:58
yeah my problem is how can I store everyone of them?
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 21:58
that's the problem I would have to name 1 by one?
class
per each
?
Ronique Ricketts
@RoniqueRicketts
Sep 06 2017 21:59
I just found out w3schools has a nodejs class. :O
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 21:59
To search for multiple class names, separate them with spaces, like "test demo".
nm
Diego Mayer
@Chrono79
Sep 06 2017 21:59
use map or forEach @tiagocorreiaalmeida
Adel
@AdelMahjoub
Sep 06 2017 22:01
@tiagocorreiaalmeida
window.addEventListener('DOMContentLoaded', function() {
  var progress = document.querySelectorAll('.progress');

  progress.forEach(function(percentage) {
    console.log(percentage.getAttribute('progress'))
  });
});
Jason Luboff
@JLuboff
Sep 06 2017 22:01
@AdelMahjoub Coming out of the shadows of backend eh?
Adel
@AdelMahjoub
Sep 06 2017 22:02
@JLuboff lol
@JLuboff got me :smile:
Jason Luboff
@JLuboff
Sep 06 2017 22:02
:D
Adel
@AdelMahjoub
Sep 06 2017 22:04
I 'm sneaking in all the fcc gitter channels
this one is the most active, after the main channel
Jason Luboff
@JLuboff
Sep 06 2017 22:05
I can't stand the main channel
Adel
@AdelMahjoub
Sep 06 2017 22:05
yeah hard to follow
Adel
@AdelMahjoub
Sep 06 2017 22:11
@tiagocorreiaalmeida
$(document ).ready(function() {
  var progress = $(".progress");
  progress.each(function() {
    console.log($(this).attr("progress"))
  })
});
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 22:11
    var percentage = document.getElementsByClassName("progress")
    for(var i = 0; i<percentage.length; i++){
      $("."+percentage[i].getAttribute('class')).css("width",percentage[i].getAttribute('progress')+"%");
    }
shouldnt this work?
Adel
@AdelMahjoub
Sep 06 2017 22:12
@tiagocorreiaalmeida what do you want to do ?
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 22:13
I have like 3 or 4 spans
and their width
will grow based
on a attribute
that called progress
so if progress 75 width of the div will be 75
Adel
@AdelMahjoub
Sep 06 2017 22:14
@tiagocorreiaalmeida ah you want a progress bar based on theese value
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 22:14
yeah that's it
since I can use the width for it
I do .css width
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 22:21
@AdelMahjoub any idea?
Adel
@AdelMahjoub
Sep 06 2017 22:22
@tiagocorreiaalmeida you want those same spans to get a width or you want a real progress bar ?
@tiagocorreiaalmeida first you need a height for those spans, span is an inline element,
@tiagocorreiaalmeida or set them to display block, in any case they need a height and a background color
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 22:28
that's all defined mate
I only need to pick the attribute progress
and set the width of each span to that the progress value
Adel
@AdelMahjoub
Sep 06 2017 22:28
@tiagocorreiaalmeida idk if this fits what you need https://jsbin.com/jexehuxize/edit?html,css,js,output
@tiagocorreiaalmeida the width of each span is set equal to that progress value
Tiago Correia
@tiagocorreiaalmeida
Sep 06 2017 22:30
exactly big thanks mate
Adel
@AdelMahjoub
Sep 06 2017 22:35
@tiagocorreiaalmeida
/*
CSS
*/
.progress {
    height: 20px;
    width: 0;
    margin-bottom: 5px;
    background-color: brown;
    display: block;
    transition: width 1s;
  }
/*
JS
*/
window.addEventListener('DOMContentLoaded', function() {
  var progress = document.querySelectorAll('.progress');

  progress.forEach(function(element) {
    var percentage = element.getAttribute('progress')
    element.style.width = percentage + 'px';
  });
});
intcreate
@intcreate
Sep 06 2017 22:40
How can i make the earth spin/rotate? https://jsfiddle.net/La3qbr0v/
Diego Mayer
@Chrono79
Sep 06 2017 22:46
animated gif? http://jsfiddle.net/LwwfG/ <- but the earth doesn't rotate like that
Bryan Reese
@breese8009
Sep 06 2017 22:47
thanks guys i solved
Randell Dawson
@RandellDawson
Sep 06 2017 22:53
@intcreate - Close as you can get with that image -
https://jsfiddle.net/6y9bkLdr/
Jason Luboff
@JLuboff
Sep 06 2017 22:53
@rmdawson71 The earth is flat?!
:joy:
Diego Mayer
@Chrono79
Sep 06 2017 22:54
The anticonspirancy were right!
I'm selling these fine aluminium-foil hats btw
Randell Dawson
@RandellDawson
Sep 06 2017 22:55
@JLuboff - That photo was taken in the 1600s by an alien.
Jason Luboff
@JLuboff
Sep 06 2017 22:56
No wonder!
Jason Luboff
@JLuboff
Sep 06 2017 23:01
Ugh... the igdb api is such a pain to work with
juni
@junipberry
Sep 06 2017 23:01
hey guys, is it wrong for me to combine the conditionals like this.. How can I get it work in the same line?
function isEitherEvenOrAreBoth7(num1, num2) {
  if (num1%0 || num2%0) || (num1 && num2 = 7){
    console.log("true");
  } else {
    console.log("false");
  }
}
actually, its
console.log(true) and console.log(false)
Diego Mayer
@Chrono79
Sep 06 2017 23:04
@junipberry = is used to assign, not to compare
use === or == instead
Jason Luboff
@JLuboff
Sep 06 2017 23:04
As well as you would need num1 === 7 && num2 ===7
Diego Mayer
@Chrono79
Sep 06 2017 23:04
and you should repeat the seven there too
Christopher McCormack
@cmccormack
Sep 06 2017 23:06
@junipberry anything mod 0 will be NaN
You'll want to do num%2, and check if the result is === 0 for it to be true
juni
@junipberry
Sep 06 2017 23:10
ahh right, ty @Chrono79 and ty @cmccormack
CamperBot
@camperbot
Sep 06 2017 23:10
junipberry sends brownie points to @chrono79 and @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
api offline
juni
@junipberry
Sep 06 2017 23:18
ty @JLuboff
Jason Luboff
@JLuboff
Sep 06 2017 23:19
:+1:
dyon3334
@dyon3334
Sep 06 2017 23:56
$` Inserts the portion of the string that precedes the matched substring.
$' Inserts the portion of the string that follows the matched substring.
replace()
what do they mean ?