These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Sep 2017
surferpilgrim
@surferpilgrim
Sep 12 2017 01:20
does anyone know what algorithmic concept the lcm challenege in freecodecamp is trying to teach
Gersho
@Gersho
Sep 12 2017 01:21
what is this one again ? name of challenge please :)
Gersho
@Gersho
Sep 12 2017 01:25
oh i remember that one
the main problem is that the link they provide explains what lcm is, but not how to find it (no math proof), try this link
http://www.math.com/school/subject1/lessons/S1U3L3DP.html
it explains no code, but explains how you do it "the math way"
korzo
@korzo
Sep 12 2017 01:25
It was hardest for me as I did math 30 years ago :)
Gersho
@Gersho
Sep 12 2017 01:26
look at the link i provided, it has a math proof easy to use even for people like us
surferpilgrim
@surferpilgrim
Sep 12 2017 01:26
@Gersho the math isn't hard for me, I'm trying to solve it building arrays the only problem is my arrays get too big. So I figured I would need to apply a different data structure
Gersho
@Gersho
Sep 12 2017 01:27
it gets too big ? what do you mean, as long as the computer doesn't explode it's ok
surferpilgrim
@surferpilgrim
Sep 12 2017 01:28
@Gersho I've crashed the website a couple times,
Bhoomi Khanderia
@bhoomikhanderia
Sep 12 2017 01:28
Hello Everyone! I have an assignment to do on geoJSON. Can any one please suggest where to begin with?
Gersho
@Gersho
Sep 12 2017 01:29
@surferpilgrim then it's not because it's too big, you probably have some infinite loop somewhere
Vikrant Singh
@VikrantSingh13
Sep 12 2017 01:35
hello
surferpilgrim
@surferpilgrim
Sep 12 2017 01:35
@Gersho is there another approach beside making arrays?(I'm only asking for something to google not the answer)
Vikrant Singh
@VikrantSingh13
Sep 12 2017 01:35
good resources to learn d3? pl0x
korzo
@korzo
Sep 12 2017 01:36
@surferpilgrim for Loop. But arrays are easier
Gersho
@Gersho
Sep 12 2017 01:36
@surferpilgrim i used a mix of arrays and objects, following the math proof in the link i made earlier, if you have infinity loop the problem is with the loop, not the array
surferpilgrim
@surferpilgrim
Sep 12 2017 01:37
@Gersho ok
Gersho
@Gersho
Sep 12 2017 01:38
there's 8 loops in mine...D:
korzo
@korzo
Sep 12 2017 01:40
@Gersho That's the number of lines my math solution has
non math is longer
John Otu
@johnotu
Sep 12 2017 02:15

Thank you @sjames1958gm Will try it out and see how it looks.

@johnotu
You could clear the input after selection
Maybe a little more hover contrast it is hard to see the change when you hover
The same with the item borders

CamperBot
@camperbot
Sep 12 2017 02:15
johnotu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8458 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
surferpilgrim
@surferpilgrim
Sep 12 2017 03:23
does anyone know how to have automatically convert a number array to scientific notation, for every new number array you create

var arr=[10e+1,50e+1,10e+2,10e+3]
Zhang LIn
@zl-cheetah
Sep 12 2017 03:32
image.png
image.png
image.png
piteto
@piteto
Sep 12 2017 03:38
@surferpilgrim You can use .toExponential() to convert numbers to scientific notation
surferpilgrim
@surferpilgrim
Sep 12 2017 04:38
@piteto is there a way where whenever you write a number it automatically converts it to scientific notation?
piteto
@piteto
Sep 12 2017 04:41
@surferpilgrim I'm not sure I understand.
var number = 1000;
var scientificNotation = number.toExponential();
console.log(scientificNotation); // 1e+3
or...
var arr= [100, 500, 1000, 10000];
console.log(arr.map(number => number.toExponential())); // ["1e+2", "5e+2", "1e+3", "1e+4"]
Gersho
@Gersho
Sep 12 2017 04:44
you can give toExponential() an argument to set the number of digits displayed
Claudio Restifo
@Marmiz
Sep 12 2017 04:45
@zl-cheetah try resetting the challenge, or reload the page without the chache
RakeshNerkar
@Rakesh18754
Sep 12 2017 06:15
is sessions storage tab specific?
can access value stored for one tab in other tab?
xiaming
@xiaming5368
Sep 12 2017 07:08
myStr 应该包含被转义的字符, 并且按照 反斜杠 制表符 退格符 回车符 换行符 的顺序用空格分开,这个怎么写?
Claudio Restifo
@Marmiz
Sep 12 2017 07:08
@Rakesh18754 is specific for the protocol of origin... to put it easy for the domain
You cannot access new session storage since, by definition, the session initiate new for every new tab or instance open.
You can however use localStorage for that since persist
xiaming
@xiaming5368
Sep 12 2017 07:11
myStr should contain the escaped characters, and follow the backslash tab backlit character carriage return line characters in the order of space, how to write this?
Claudio Restifo
@Marmiz
Sep 12 2017 07:12
@xiaming5368 there should be a "example string" with words instead of code on the page... simply "convert" that
Gersho
@Gersho
Sep 12 2017 07:13
you understood that sentence ? wow
xiaming
@xiaming5368
Sep 12 2017 07:14
no
sorry
Claudio Restifo
@Marmiz
Sep 12 2017 07:15

@xiaming5368 there's a chinese room:
https://gitter.im/FreeCodeCamp/chinese

maybe better luck there?

(also hope was chinese what you wrote :) )
Gersho
@Gersho
Sep 12 2017 07:15
i can at least say it's neither japanese nor korean
and it does look like chinese
xiaming
@xiaming5368
Sep 12 2017 07:16
ok, Thank you!
Gersho
@Gersho
Sep 12 2017 07:16
korean has a lot of circles and bars
xiaming
@xiaming5368
Sep 12 2017 07:22
@Marmiz Just solved the problem, Thank you!
CamperBot
@camperbot
Sep 12 2017 07:22
xiaming5368 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1041 | @marmiz |http://www.freecodecamp.com/marmiz
vishalsoni365
@vishalsoni365
Sep 12 2017 07:44
hello folks
Claudio Restifo
@Marmiz
Sep 12 2017 08:00
@vishalsoni365 :wave:
Serhii Borovskyi
@serhiicss
Sep 12 2017 08:13
var surgeons = [];

The output for

console.log(surgeons);

and

console.log('An array of surgeons: ' + surgeons);

is different. Why is that? Here is the complete code: https://repl.it/JSvs/21

Jon
@jonandrepedersen
Sep 12 2017 08:27
Hehe it was Chinese (mandarin) :p
Claudio Restifo
@Marmiz
Sep 12 2017 08:28
@serhiicss in the second case you are simply try to read the string representation of the object.
You could simply parse it to have it available with other string:
console.log('An array of surgeons: ' + JSON.stringify(surgeons));
Blauelf
@Blauelf
Sep 12 2017 08:31
@serhiicss Using + operator, you turn the array into a string. Passing it directly to console.log uses different rendering that's often more useful, and on the browser console is even browsable (doesn't work for repl.it with its text-only console)
Serhii Borovskyi
@serhiicss
Sep 12 2017 08:31
@Marmiz @Blauelf Thanks!
CamperBot
@camperbot
Sep 12 2017 08:31
serhiicss sends brownie points to @marmiz and @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1042 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 4600 | @blauelf |http://www.freecodecamp.com/blauelf
Daniel Romero
@Ranacode
Sep 12 2017 08:38
Hi
One question, it is possible rewrite the local strategy from passport to check email instead of username?
I tried but is not working

        passport.use(new LocalStrategy(
            function(email, password, done) {
                User.findOne({
                    profile: {
                        email: email
                    }
                }, function(err, user) {
                    if (err) { return done(err); }
                    if (!user) {
                        return done(null, false, { message: 'Incorrect email.' });
                    }
                    if (!user.validPassword(password)) {
                        return done(null, false, { message: 'Incorrect password.' });
                    }
                    return done(null, user);
                });
            }
        ));
moca_tao7
@taotao7
Sep 12 2017 09:05
Write a function queue, with an array arr and a numeric item as arguments. The numeric item is added to the end of the array, and then removed from the first element of the array, and finally the queue function should return the deleted element.
function queue(arr, item) {
  // 请把你的代码写在这里

  return item;  // 请修改这一行
}

// 初始化测试数据
var testArr = [1,2,3,4,5];

// 控制台输出
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // 你可以修改这一行来测试你的代码
console.log("After: " + JSON.stringify(testArr));
who can help me ?
Markus Kiili
@Masd925
Sep 12 2017 09:07
@taotao7 You need to find two array methods that do those two things asked, and then use them on arr and item.
Claudio Restifo
@Marmiz
Sep 12 2017 09:10

@Ranacode Haven't worked much with Passport but I remember you can pass option to override the default behaviour.
something like:

passport.use(new LocalStrategy({
    usernameField: 'email',
    passwordField: 'passwd'
  },
function(....)

But probably the documentation has a better docs for it :)

Brice Afonso
@Qazare
Sep 12 2017 09:11
@taotao7 take a look at this MDN's page for the Array object, on the left you'll find some methods that will help you with what you need to do :)
(edited the link, had the prototype page instead of the object page)
Claudio Restifo
@Marmiz
Sep 12 2017 09:12

@Ranacode found the docs:
http://passportjs.org/docs/username-password

You can override the default pretty much as I showed you :)

Markus Kiili
@Masd925
Sep 12 2017 09:14
@Qazare Just to clarify that the Array.prototype is the object that holds all the array methods. Array is the constructor function of arrays.
Both are found on the Array link there.
Blauelf
@Blauelf
Sep 12 2017 09:15
Array has own methods, which could be interpreted as static methods (attached to the "class"/constructor rather than prototype), for example isArray or with ES6 from.
Markus Kiili
@Masd925
Sep 12 2017 09:16
Mostly methods that have something to do with arrays, but are not necessarily called upon an array.
Brice Afonso
@Qazare
Sep 12 2017 09:18
Hmm @Masd925 I have question about that: when you declare an array in a variable like var = [1, 2], JavaScript automatically detects that it's an array and attaches to it the methods from the array.prototype ? Because if not, how does it get its methods from ? But then, why is there an Array constructor ?
Blauelf
@Blauelf
Sep 12 2017 09:19
@Qazare The interpreter creates a new array with the elements you mentioned.
And arrays have Array.prototype in their prototype chain.
Markus Kiili
@Masd925
Sep 12 2017 09:20
@Qazare In JS values have types but variables don't. When you call a method on an array, it is not found there. After that the engine looks up the prototype chain using the prototype reference and finds the method on Array.prototype. Array constructor is used when the array object is created.
All objects have a reference to a prototype object (can be null). That way a prototype chain forms.
Blauelf
@Blauelf
Sep 12 2017 09:22
@Masd925 Would changing global variable Array also affect array literals? I attached properties, but never replaced Array itself.
Markus Kiili
@Masd925
Sep 12 2017 09:24
@Qazare You can check the prototype chain for example like this:
var obj = [1,2];
var proto1 = Object.getPrototypeOf(obj);
var proto2 = Object.getPrototypeOf(proto1);
var proto3 = Object.getPrototypeOf(proto2);

proto1 === Array.prototype;  // true
proto2 === Object.prototype; // true
proto3 === null;             // true
Or more elegantly with a function that prints it.
moca_tao7
@taotao7
Sep 12 2017 09:25
@Qazare thank u
CamperBot
@camperbot
Sep 12 2017 09:25
taotao7 sends brownie points to @qazare :sparkles: :thumbsup: :sparkles:
:cookie: 262 | @qazare |http://www.freecodecamp.com/qazare
Brice Afonso
@Qazare
Sep 12 2017 09:26
Thanks a lot @Masd925 ! I need to re-read this a couple of times...
CamperBot
@camperbot
Sep 12 2017 09:26
qazare sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4480 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Sep 12 2017 09:30
@Blauelf Seems that you can overwrite Array and use literals but not new Array() anymore.
Brice Afonso
@Qazare
Sep 12 2017 09:30
So doing var arr = [0, 1] is the same thing as doing var arr = new Array(0, 1) ? The brackets are a shortcut ?
Markus Kiili
@Masd925
Sep 12 2017 09:31
@Qazare Rule of thumb is not to use new when possible. So literals are better.
@Qazare Using the array constructor leads to misunderstandings because what does Array(3) do?
[element0, element1, ..., elementN]
new Array(element0, element1[, ...[, elementN]])
new Array(arrayLength)
Brice Afonso
@Qazare
Sep 12 2017 09:34
@Masd925 I was just about to ask you why it's better not to use it. Your explanation makes perfect sense !
Blauelf
@Blauelf
Sep 12 2017 09:35

I used to abuse the array constructor that way. Before there was String.prototype.repeat, I'd do

new Array(n+1).join(str)

Creates an array of n+1 elements, or rather n+1 holes, and joins them, leaving n times str.

Brice Afonso
@Qazare
Sep 12 2017 09:36
@Masd925 but then if I do var arr = [0], what does the engine interpret ? There's a rule or something that states that with this syntax, it's an element in the array, not the array length ? This is probably said in a very confusing way...
Markus Kiili
@Masd925
Sep 12 2017 09:36
@Qazare Array literal just states the elements.
I posted the different ways to make an array above.
Brice Afonso
@Qazare
Sep 12 2017 09:40
It's clearer, thanks @Masd925 :smile:
CamperBot
@camperbot
Sep 12 2017 09:40
qazare sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
api offline
Blauelf
@Blauelf
Sep 12 2017 09:41
api online. But cannot parse error message it seems.
Daniel Romero
@Ranacode
Sep 12 2017 09:48
Thanks @Marmiz I appreciate it
CamperBot
@camperbot
Sep 12 2017 09:48
ranacode sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1043 | @marmiz |http://www.freecodecamp.com/marmiz
Nitin
@thenm
Sep 12 2017 10:04
How to find whether object have the key which I am looking for?
Markus Kiili
@Masd925
Sep 12 2017 10:07
@thenm You can use the obj.hasOwnProperty(key) method.
key in obj does the same but looks up the prototype chain too, and also finds the non-enumerable properties (~built-in ones like .toString).
Daniel Romero
@Ranacode
Sep 12 2017 10:15
Hey guys
One question about connect-flash
How can I show messages on another route?
All the examples I see are made in the same route
I mean, I have the signup/login forms in the same route
And all I want to know is, when I post the data on '/login' for example, show the flash messages on '/' route
Johnny
@JohnnyBizzel
Sep 12 2017 12:03
@Ranacode res.redirect('/') ?
Daniel Romero
@Ranacode
Sep 12 2017 12:10
II'll try later
Bhoomi Khanderia
@bhoomikhanderia
Sep 12 2017 12:10
Hello! I am working on this: I need to create a mobile responsive web page to display locations of earthquake around the world on a map. The actual API: https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson
Please let me know if anyone know anything that would help me! TIA
Daniel Romero
@Ranacode
Sep 12 2017 12:10
I don't know how to show the messages inside the strategy of passport :S
     function(email, password, done) {
                User.findOne({
                    'profile.email': email
                }, function(err, user) {
                    console.log(user.comparePassword(password))
                    if (err) { return done(err); }
                    if (!user) {
                        return done(null, false, { message: 'Ese email no existe en nuestra base de datos' });
                    }
                    if (!user.comparePassword(password)) {
                        return done(null, false, { message: 'Esa no es la contraseña correcta' });
                    }
                    return done(null, user);

                });
            }
        ));
That message object how can I pass to my template?
flash is needed to do this?
Adel
@AdelMahjoub
Sep 12 2017 13:02

cookie-parser is required to use
connect-flash

const express      = require('express'); 
const cookieParser = require('cookie-parser');
const flash        = require('connect-flash');

const app = express();

app
  .use(cookieParser('SECRET_PHRASE'))
  .use(flash())
  .use(passport.initialize())
  .use(passport.session())

  // errors and infos context variables refers to req.flash('error') and req.flash('info')
  // errors and infos will be available inside the views 
  .use((req, res, next) => {
    app.locals.errors = req.flash('error');
    app.locals.infos = req.flash('info');
    next()
  })

  /*
   ...
  */

usage with passport.authenticate

passport.authenticate('local', {
    failureRedirect: 'path',
    successRedirect: 'path',
    failureFlash: 'error message to flash'
 })

inside a view

<!-- Render errors to the user -->
<% if(errors.length) { %>
    <% errors.forEach(function(error) { %>
      <p><b><%= error %></b></p>
    <% }); %>
<% } %>
@Ranacode
if the express app is running behind a proxy set trust proxy to true in order for connect-flash to work as expected :
app.enable('trust proxy')
Diego Mayer
@Chrono79
Sep 12 2017 14:08
@Bhoomi-Github this codepen does pretty much that: https://codepen.io/vanwars/pres/KgAkrb
You can try using Google Maps Api
Sandip Shrestha
@saninmersion
Sep 12 2017 15:53
https://codepen.io/saninmersion/pen/QqWNvv?editors=1010
typeahead project, where is this , after every list element it produces as a result coming from?
Christopher McCormack
@cmccormack
Sep 12 2017 15:54
@saninmersion looks like it's when there is no city and state
Jason Luboff
@JLuboff
Sep 12 2017 15:55
@cmccormack :wave:
Christopher McCormack
@cmccormack
Sep 12 2017 15:55
@JLuboff morning!
Jason Luboff
@JLuboff
Sep 12 2017 15:55
How goes it?
Christopher McCormack
@cmccormack
Sep 12 2017 15:56
@saninmersion you're not closing your li properly
Sandip Shrestha
@saninmersion
Sep 12 2017 15:57
@cmccormack if so would it not create a separt li around it ( the ,)? I mean it's just there in between li's
Christopher McCormack
@cmccormack
Sep 12 2017 15:57
@JLuboff goes well, reading up on functional programming
@saninmersion still looking at the main reason why, doesn't look like your object has empty entries
Jason Luboff
@JLuboff
Sep 12 2017 15:57
Neat
I'm being slightly less lazy and finally uninstalling/reinstalling firefox :joy:
Sandip Shrestha
@saninmersion
Sep 12 2017 15:58
@cmccormack closed li correctly now. Noticed after I posted.
Christopher McCormack
@cmccormack
Sep 12 2017 16:00
@saninmersion ah this is an array, turn it into a string first
suggestions.innerHTML = html.join('');
also html += match.map(match => { should probably just be html = match.map(match => { but I don't think it hurts anything
Sandip Shrestha
@saninmersion
Sep 12 2017 16:03
@cmccormack ofc .map returns an array :D silly of me. Thanks for pointing that out making it clear.
CamperBot
@camperbot
Sep 12 2017 16:03
saninmersion sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1204 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 16:03
@saninmersion You could simplify that whole function to something like this if you wanted to make it more succinct:
function displayMatch(){
  suggestions.innerHTML = findMatch(this.value).map(match =>
    `<li>${match.city}, ${match.state}</li>`).join('');
}
@JLuboff haha man that is lazy, 24 hours to make that decision?
Jason Luboff
@JLuboff
Sep 12 2017 16:04
@cmccormack Psh...not all of us work from home ;) So really it was only a couple hours
Christopher McCormack
@cmccormack
Sep 12 2017 16:07
You don't all work at home? What do you get in a car and drive to an office everyday or something?
@JLuboff Have you had the chance to listen to this podcast yet? https://syntax.fm/
Jason Luboff
@JLuboff
Sep 12 2017 16:08
I have not. I've never really been into podcasts. What is this one about?
Christopher McCormack
@cmccormack
Sep 12 2017 16:08
It's Wes Bos and Scott Tolinksi talking about different aspects of web design
It's fairly new, but I like it. They talk about a lot of tools they use and it's been pretty helpful in at least making me aware of what else is out there
Jason Luboff
@JLuboff
Sep 12 2017 16:09
I'll have to check it out
Christopher McCormack
@cmccormack
Sep 12 2017 16:09
the last one I listened to was pretty interesting, discussing some details about freelancing
Jason Luboff
@JLuboff
Sep 12 2017 16:11
I'll give it a try. My interest today is the new iPhones. (I upgrade every two years...so..its been two years)
Christopher McCormack
@cmccormack
Sep 12 2017 16:12
Is that today?
Jason Luboff
@JLuboff
Sep 12 2017 16:12
Ya, probably starts at 10 (I haven't looked but thats usually the time their events start)
Christopher McCormack
@cmccormack
Sep 12 2017 16:13
Great, now I have to skip large chunks of my tech podcasts for the next week haha
Jason Luboff
@JLuboff
Sep 12 2017 16:13
:D
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 16:13
Sup peeps
Christopher McCormack
@cmccormack
Sep 12 2017 16:14
@RoniqueRicketts heya
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 16:14
@cmccormack How's it going? My computer died at home. :'(
Marc
@MWBauer
Sep 12 2017 16:14
Morning everyone!
Jason Luboff
@JLuboff
Sep 12 2017 16:14
Oh man... I used to really like engadget...but holy hell are they full of ads now
Christopher McCormack
@cmccormack
Sep 12 2017 16:17
@JLuboff ublock origin
Jason Luboff
@JLuboff
Sep 12 2017 16:18
Downloading
Christopher McCormack
@cmccormack
Sep 12 2017 16:19
For a while I just though the web was becoming a nicer place, forgetting I had that enabled :D
Jason Luboff
@JLuboff
Sep 12 2017 16:20
Hmmm...didn't seem to block anything.. (This is in Edge)
Christopher McCormack
@cmccormack
Sep 12 2017 16:21
Does Edge even allow extensions?
Jason Luboff
@JLuboff
Sep 12 2017 16:21
Yes
Don't be hating on Edge :joy:
Christopher McCormack
@cmccormack
Sep 12 2017 16:23
Why not?
They should call it Marginal
it's like 4% of the market :D
Gersho
@Gersho
Sep 12 2017 16:24
well they're at the edge of the market then
Jason Luboff
@JLuboff
Sep 12 2017 16:25
You know, it's actually not that bad. My main browser is Firefox..but I use Edge for searches (due to Microsoft Rewards). I really don't have any complaints about it, I just like FF as my main. I rarely use Chrome (albeit Chrome has probably the best Dev tools)
Christopher McCormack
@cmccormack
Sep 12 2017 16:26
I didn't use Edge from the start because I couldn't install extensions, that's a game breaker to me
"It's the fastests browser..." yeah because it doesn't do anything yet
Jason Luboff
@JLuboff
Sep 12 2017 16:27
I don't really use extensions all that much so doesn't change anything
Christopher McCormack
@cmccormack
Sep 12 2017 16:27
But I agree it's not that bad, it renders sites just fine.
Gersho
@Gersho
Sep 12 2017 16:27
i use firefox as main and vivaldi for my coding lessons (but mostly to have 2 set of booksmarks)
Christopher McCormack
@cmccormack
Sep 12 2017 16:28
I use xmarks for bookmarks and just use profiles for my bookmarks bar, been working pretty well for several years now
I've been meaning to try vivaldi
Jason Luboff
@JLuboff
Sep 12 2017 16:36
Never heard of it..but downloading now
Christopher McCormack
@cmccormack
Sep 12 2017 16:37
Appears to be Chrome but with a nicer look, and you can put tabs on the sides which is really nice
Elizabeth Paul
@Kowalatam
Sep 12 2017 16:37

for some reason i found this funny

Never heard of it..but downloading now

Jason Luboff
@JLuboff
Sep 12 2017 16:38
lol I went to its website and it looked interesting
Unlike that VSCode that some guy keeps trying to get everyone to download and use ;P
Christopher McCormack
@cmccormack
Sep 12 2017 16:39
@JLuboff Haha everyone is using it and loving it sir
I'm actually using VS Code as my text editor for work these days
Gersho
@Gersho
Sep 12 2017 16:39
atom <3
Jason Luboff
@JLuboff
Sep 12 2017 16:39

Quoted for truth

atom <3

Christopher McCormack
@cmccormack
Sep 12 2017 16:39
atom isn't even on the same level
Jason Luboff
@JLuboff
Sep 12 2017 16:40
OH NO YOU DIDN'T!
Christopher McCormack
@cmccormack
Sep 12 2017 16:40
atom cannot compare to sublime text, let alone VS Code
Gersho
@Gersho
Sep 12 2017 16:40
i do have VSC too, but i never use it (i planned to use it for C# in Unity3D but i kinda dropped working on that)
Jason Luboff
@JLuboff
Sep 12 2017 16:40
:worried:
Christopher McCormack
@cmccormack
Sep 12 2017 16:41
It's so great for web stuff, especially when you're dealing with npm as there is a terminal built right in
Jason Luboff
@JLuboff
Sep 12 2017 16:43
I like my seperate terminal
Christopher McCormack
@cmccormack
Sep 12 2017 16:45
I'm just suggesting you give it a try :) if you don't like it, you still have lots of other great tools
Jason Luboff
@JLuboff
Sep 12 2017 16:46
I do have it installed and I think tried it for 5 minutes
Gersho
@Gersho
Sep 12 2017 16:46
i'm a bit lost on terminology here, are we talking about stuff we can do on a normal terminal ?
Christopher McCormack
@cmccormack
Sep 12 2017 16:47
yes. in Windows I believe it uses git bash but I'm not 100%, maybe only if you have that installed. on mac it uses your terminal. Nice to have it all integrated instead of tabbing over to a separate terminal window, and you can have several instances at once
Gersho
@Gersho
Sep 12 2017 16:47
oh it's only a terminal
Christopher McCormack
@cmccormack
Sep 12 2017 16:48
VS Code?
Gersho
@Gersho
Sep 12 2017 16:49
i'm fine with using terminal as usual, i wouldn't want it built in something else
Christopher McCormack
@cmccormack
Sep 12 2017 16:49
your choice, just one of the benefits
Gersho
@Gersho
Sep 12 2017 16:50
but for the moment the most important tool for me isn't my editor, it's Zeal D:
Christopher McCormack
@cmccormack
Sep 12 2017 16:51
@Gersho what are you working on now?
Gersho
@Gersho
Sep 12 2017 16:52
trying to learn too many things at once :P (react, <canvas>, python)
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 16:53
think your right
Christopher McCormack
@cmccormack
Sep 12 2017 16:54
Yeah, just do one at a time, or combine stuff like React and canvas
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 16:59
doing react too myself
Gersho
@Gersho
Sep 12 2017 17:00
i'm almost done with react part 1 on codeacademy
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:02
oh im gonna try it on codecamy i forgot about it
Gersho
@Gersho
Sep 12 2017 17:02
i can't really compare with other lessons, but it felt very instructive
Stuhl
@Stuhl
Sep 12 2017 17:31
Try learning vanilla js
Its very powerful
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:41
@Gersho it very simple i presume.
@Stuhl Yes it is and once you have a solid handle on vanillajs you will do well learning any js framework :)
Jason Luboff
@JLuboff
Sep 12 2017 17:45
@cmccormack Reinstall didn't fix the crashing issue! And I had even gone from 32 to 64 bit version...
Christopher McCormack
@cmccormack
Sep 12 2017 17:45
and no extensions?
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:46
I am getting a mac :) my first ever Official Mac.
Christopher McCormack
@cmccormack
Sep 12 2017 17:46
@RoniqueRicketts nice! Which one?
Jason Luboff
@JLuboff
Sep 12 2017 17:46
Only one is enabled which is JSONView, I disabled Wappalyzer. Guess I'll try disabled JSONView and then try uninstalling and reinstalling Flash as well
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:47
@cmccormack lol second hand mac mini 2014. I wonder if its expandable
Christopher McCormack
@cmccormack
Sep 12 2017 17:47
@RoniqueRicketts that's great! Are you familiar with shells at all?
Jason Luboff
@JLuboff
Sep 12 2017 17:48
@RoniqueRicketts You maybe able to upgrade the ram depending on whats in it as well as change out the HD for an SSD but otherwise, thats about it
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:49
@cmccormack NOPE! but I am looking forward to the learning curve. Plus if old people can learn how to use a mac why can't I use it. :) Heard mac os is for the lazy and the spoilt. :trollface:
@JLuboff oh cool. Well I have a nice 16 waiting to go in that mac. I just had some RAM sitting in my toolbox
Jason Luboff
@JLuboff
Sep 12 2017 17:50
But is it the right type of ram?
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:50
@JLuboff I have various types that's the thing. I wanna check it out when it comes
Christopher McCormack
@cmccormack
Sep 12 2017 17:50
@RoniqueRicketts Well there are two types of mac users, those that just use them for whatever, and power users that want to get the most out of it. Mac OS is built on Darwin OS, which for techies is great because you get lots of linux/unix functionality underneath
Jason Luboff
@JLuboff
Sep 12 2017 17:51
Ugh...this event is taking too long to get to iPhones lol
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:52
@cmccormack oh so thats the hype i've been missing out on. Well I am going to use the mac until I can build up my LINUX! :) excited. I'm building it from ordering parts and loading on the OS :)
Christopher McCormack
@cmccormack
Sep 12 2017 17:54
You can run linux whenever you want on a VM for free!
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:55
@cmccormack Yeah I know but I am building up a machine for each OS. Just being a geeky nerd. Virtual Machine is nice and all but I want a full LINUX OS. Plus I could use the terminal practice :)
Jason Luboff
@JLuboff
Sep 12 2017 17:55
Why build multiple machines though?
Build one that can run all without having to switch
Alright....finally talking iPhone
Gersho
@Gersho
Sep 12 2017 17:57
i'm running Mint ever since they released Windows 10, i'm never going back (i kept a W7 install to play games, but it's offline)
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:57
I want more than one machine because I don't want what happened to me last month happen again. My 1 laptop died and now I feel like I am a caveman. I have to code at work on their system that I can't download anything on. Every now and then they remotely connect to my screen and If I block them from remotely connect they call my phone. So Yeah I want more than one machines
win 10 is cool I like it. The old win 7 look and feel was boring.
Gersho
@Gersho
Sep 12 2017 17:58
i'm a win10 hater
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 17:59
I find win 10 easier than win7 one draw back for win10 is the update that removed control panel from the start menu but other than that i love it
Christopher McCormack
@cmccormack
Sep 12 2017 18:00
@RoniqueRicketts it's still there, just right click the "Start" button
They're all fine in their own way, no reason to hate haha
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:01
@cmccormack nope its not. And I've seen it a lot on customer's computers daily
Christopher McCormack
@cmccormack
Sep 12 2017 18:01
@RoniqueRicketts I'm looking at it right now, did you try right clicking the button?
Gersho
@Gersho
Sep 12 2017 18:01
maybe you don't have the same version ?
Christopher McCormack
@cmccormack
Sep 12 2017 18:01
Maybe
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:01
Not every win10 has control panel when you right click on the menu
Gersho
@Gersho
Sep 12 2017 18:01
and if you're in a domain, your admin might have removed it
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:02
:wave: guys
Christopher McCormack
@cmccormack
Sep 12 2017 18:02
@kelechy hi!
Gersho
@Gersho
Sep 12 2017 18:02
:wave:
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:02
for quick access I have "control panel" in my run app
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:02
function stringChunk(str, n) {
  if (n <= 0 || n === undefined) return [];
  if (n > str.length) return [str];
  let arr = [];
  for (var i = 0; i < str.length; i += n) {
    arr.push(str.slice(i, i + n));
  }
  return arr;
}
Expected: '[]', instead got: '[\'\']'
when called this way stringChunk('sunny day')
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:03
@Gersho nope. I do tech support I have full access to the control panel and services but I just can't install anything much without them knowing and reaching out to me.
Gersho
@Gersho
Sep 12 2017 18:05
so they let you install stuff, but ask you about it later ? weird
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:05
@Gersho example I wanna install nodejs but I know they will ask why I install it and how will it make my job better :)
Gersho
@Gersho
Sep 12 2017 18:06
is that their computer or yours ?
Christopher McCormack
@cmccormack
Sep 12 2017 18:06
I do have to agree though, Control Panel on Win10 is probably my pet peeve - why did they think it would be good to use those Metro style minimalist panes??? This is the control panel!
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:06
i think one of the test case for that kata is wrong @JLuboff @cmccormack https://www.codewars.com/kata/string-chunks/train/javascript
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:06
@Gersho their computer :trollface:
Gersho
@Gersho
Sep 12 2017 18:06
it's 1years old+ so it's unlikely
@kelechy
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:07
@cmccormack i have no clue why they did that.
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:08
time doesnt play a factor @Gersho
Jason Luboff
@JLuboff
Sep 12 2017 18:08
Its pretty easy to click the start menu then just start typing control panel to get to it..
Gersho
@Gersho
Sep 12 2017 18:09
@JLuboff it's even easier to remove windows :P
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:09
@JLuboff ya cortana works. btw my cortana is not so smart she doesn't understand voice command.
Christopher McCormack
@cmccormack
Sep 12 2017 18:10

@kelechy that's strange maybe try reloading: that single task passed for me:

function stringChunk(str, n) {
  if (n <= 0 || n === undefined) return [];
}

Test Passed: Value == '[]'

Jason Luboff
@JLuboff
Sep 12 2017 18:10
Windows is not bad at all. Would I prefer OS X? Sure. Would I prefer Linux, Nope. Not to mention being in a business, Windows rules all.
Christopher McCormack
@cmccormack
Sep 12 2017 18:11
I actually do prefer windows for file management, I feel like there is a lot of friction when I actually have to use finder on mac
but I also hate windows file structure vs Linux
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:11
@JLuboff lol, well I wanna get my feet wet in all 3. They are all nice OS.
Gersho
@Gersho
Sep 12 2017 18:11
@cmccormack sure is easy to find file when it makes 10+GB index files >.>
Jason Luboff
@JLuboff
Sep 12 2017 18:12
@cmccormack Yes Windows handles file management much better but file system structure is lacking.
Christopher McCormack
@cmccormack
Sep 12 2017 18:12
@Gersho I didn't say anything about finding files
Gersho
@Gersho
Sep 12 2017 18:12
i don't know mac, i assumed finder was some kind of search thing
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:13
there is a last [] it did nt pass @cmccormack
Jason Luboff
@JLuboff
Sep 12 2017 18:13
Finder is used to search the system, whether that be for files, folders, applications, etc
Gersho
@Gersho
Sep 12 2017 18:13
so it is to find files then ?
Jason Luboff
@JLuboff
Sep 12 2017 18:13
It does use an Index but I never recall seeing a large index like that
Christopher McCormack
@cmccormack
Sep 12 2017 18:14
@kelechy stringChunk('sunny day') was this your test or codewars test?
Gersho
@Gersho
Sep 12 2017 18:14
maybe they fixed it in w10, but w7 generated some crazy index if you let it do it's indexation thing
Jason Luboff
@JLuboff
Sep 12 2017 18:14
Sweeeeettt wireless charging for new iphone's
Gersho
@Gersho
Sep 12 2017 18:15
oh the keynote is out ?
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:15
Finder is ok but navigating files is best with windows
Jason Luboff
@JLuboff
Sep 12 2017 18:15
@Gersho It's on going.
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:15
CW @cmccormack
Jason Luboff
@JLuboff
Sep 12 2017 18:15
@RoniqueRicketts I strongly disagree
Christopher McCormack
@cmccormack
Sep 12 2017 18:15
@JLuboff Good, Android had that for many years but not many used it because they didn't know, maybe it will become popular again
Gersho
@Gersho
Sep 12 2017 18:16
i'll read a report later then ^^not like i was plannnig to buy anyway
Christopher McCormack
@cmccormack
Sep 12 2017 18:16
@kelechy like I showed above that test works fine, maybe reload
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:16
reload works nothing
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:16
well to everyone his own. Based on usage I find win10 file architecture to be better.
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:16
this is the very call for that test stringChunk('bizarre love 3angle') @cmccormack
Jason Luboff
@JLuboff
Sep 12 2017 18:16
Oh and I was thinking of spotlight before not finder. Oops. Finder is the OS X equivelent of Windows Explorer. Spotlight is the search functionality (which would be what creates an index)
And the new base models are 64 GB... thank god I'm so tired of my shitty 16 gb
Pre-order on my birthday oh fun
Gersho
@Gersho
Sep 12 2017 18:18
was about time they added some storage
Jason Luboff
@JLuboff
Sep 12 2017 18:18
I know the 7 started at 32 but I think 64 is really a base minimum now
Gersho
@Gersho
Sep 12 2017 18:19
what about sd cards ?
Christopher McCormack
@cmccormack
Sep 12 2017 18:19
I can't believe they still had that little storage, it was one of the reasons I moved away from iPhone after the iPhone 4. I had all versions prior but storage and lack of any kind of customization or file access was too shitty
Jason Luboff
@JLuboff
Sep 12 2017 18:19
No, apple will never have SD cards for the iphone
Gersho
@Gersho
Sep 12 2017 18:19
still not ? lol
Jason Luboff
@JLuboff
Sep 12 2017 18:19
And now introducing the iphone X
Gersho
@Gersho
Sep 12 2017 18:20
iPhone4 is the last time they were really in the game
Jason Luboff
@JLuboff
Sep 12 2017 18:20
@cmccormack I've had an iphone since the original and upgraded every year... so Original, 3gs, 4s, 5s and currently 6s
I'm really disappointed that all models have a glass back. That really is an awful decision IMO
Christopher McCormack
@cmccormack
Sep 12 2017 18:21
@kelechy what was n?
Jason Luboff
@JLuboff
Sep 12 2017 18:21
Jesus... 2436 x 1125 resolution
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:21
undefined @cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 18:21
@JLuboff I just assume I'm going to put a case on it anyhow
Jason Luboff
@JLuboff
Sep 12 2017 18:22
@cmccormack Well.. I do always use a case. But still. Didn't they learn their lesson from the 4/4S?
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:23
that kata is sick @cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 18:23
@JLuboff that resolution isn't even as high as the Pixel XL, FYI - 1440 x 2560 pixels (~534 ppi pixel density)
Ronique Ricketts
@RoniqueRicketts
Sep 12 2017 18:23
I wonder how long it would take to make an operating system for a device. I'd love to build something that big
Jason Luboff
@JLuboff
Sep 12 2017 18:23
@cmccormack Whats the screen size for that? This is 5.8
Christopher McCormack
@cmccormack
Sep 12 2017 18:24
5.5 inches
Jason Luboff
@JLuboff
Sep 12 2017 18:24
Impressive
Gersho
@Gersho
Sep 12 2017 18:24
more importantly, does the new phone mean you have to get a new charger and new ear buds ? did they remove another important connectivity this time ?
Christopher McCormack
@cmccormack
Sep 12 2017 18:24
My Nexus 6P has
Size 5.7 inches (~71.4% screen-to-body ratio)
Resolution 1440 x 2560 pixels (~518 ppi pixel density)
Gersho
@Gersho
Sep 12 2017 18:25
i have a potato running android 4
Jason Luboff
@JLuboff
Sep 12 2017 18:25
@Gersho They haven't mentioned anything otherwise
@cmccormack Well. I obiviousily haven't kept up with phone resolutions :D
Christopher McCormack
@cmccormack
Sep 12 2017 18:25
@JLuboff haha np I"m secretly trying to get you to convert to Android anyhow
Whoops cat's out of the bag!
Gersho
@Gersho
Sep 12 2017 18:26
in term of not keeping up with resolution i think i'll win: i am using 1280*1024 on my main screen
Jason Luboff
@JLuboff
Sep 12 2017 18:26
Ugh. No home buttons which means no touchid, instead uses Face ID (facial recognization)...
Christopher McCormack
@cmccormack
Sep 12 2017 18:28
@JLuboff yeah that was the rumor for a while now
face id is not very secure at all
@Gersho on your phone?
Gersho
@Gersho
Sep 12 2017 18:29
oh did they introduce the 3d face id or not yet ?
Christopher McCormack
@cmccormack
Sep 12 2017 18:29
That's a 4:3 isn't it?
Gersho
@Gersho
Sep 12 2017 18:29
no, my computer ;)
and yes it's 4:3
Jason Luboff
@JLuboff
Sep 12 2017 18:30
@cmccormack Ya I know its been rumored. But they claim it can't be fooled by a picture. I have my doubts. Not only that, but now you actually have to be looking at your phone to unlock it...thats lame
Christopher McCormack
@cmccormack
Sep 12 2017 18:30
@JLuboff if they added infrared to the front facing camera then I can see how it may be more secure
Gersho
@Gersho
Sep 12 2017 18:30
my phone protection is keeping it in my pocked xD
Christopher McCormack
@cmccormack
Sep 12 2017 18:30
what you should really worry about is someone taking your phone then just pointing it at you then running
stupidest protection ever
Gersho
@Gersho
Sep 12 2017 18:31
wouldn't using the camera everytime you want to unlock it be a drain on the battery anyway ?
Jason Luboff
@JLuboff
Sep 12 2017 18:31
They claim TouchID there is 1 in 50,000 chance for someone to steal access...with FaceID it drops to 1 in a Million..
Christopher McCormack
@cmccormack
Sep 12 2017 18:31
What's great about most Android fingerprint readers is they're on the back, so it's the natural position of your hand when you pick it up.
Jason Luboff
@JLuboff
Sep 12 2017 18:32
@Gersho Eh..yes and no. I imagine its optimized but also I don't believe it shows you on screen so less processing power there too
Gersho
@Gersho
Sep 12 2017 18:32
btw i've never tried it but, does it work if you have a cut on your finger ?
Jason Luboff
@JLuboff
Sep 12 2017 18:32
Yes
Gersho
@Gersho
Sep 12 2017 18:33
cool
Christopher McCormack
@cmccormack
Sep 12 2017 18:35
Hah
Gersho
@Gersho
Sep 12 2017 18:39
so was there a "one more thing" this time ?
Christopher McCormack
@cmccormack
Sep 12 2017 18:49
@kelechy this is the best I could do so far, trying to figure out how to do it functionally (doesn't pass all tests, but does pass all samples):
function stringChunk(str, n) {
  if (!n) return []
  var newStr = []
  for (var i = 0; i < str.length; i+=n){
    newStr.push(str.slice(i, i+n))
  }
  return (newStr) 
}
Gersho
@Gersho
Sep 12 2017 18:50
can you link the challenge ? i kinda want to try it
Pagnito
@Pagnito
Sep 12 2017 18:51
anyone use css grid yet?
Christopher McCormack
@cmccormack
Sep 12 2017 18:52
@kelechy ah I see the problem, didn't realize the n was a string in that case. This should work:
function stringChunk(str, n) {
  if (n <=0 || isNaN(n)) return []
  var newStr = []
  for (var i = 0; i < str.length; i+=n){
    newStr.push(str.slice(i, i+n))
  }
  return (newStr) 
}
Gersho
@Gersho
Sep 12 2017 18:52
thanks @cmccormack
CamperBot
@camperbot
Sep 12 2017 18:52
:star2: 1207 | @cmccormack |http://www.freecodecamp.com/cmccormack
gersho sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:54
oh nice @cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 18:55
The most clever solutions used regex
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:55
oh thats true @cmccormack
Pieter Stokkink
@forkerino
Sep 12 2017 18:55
Hello
I was gonna say Regex too
@cmccormack
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:55
those regex guys :smile:
Pieter Stokkink
@forkerino
Sep 12 2017 18:56
something like /.../g ?
Christopher McCormack
@cmccormack
Sep 12 2017 18:56
str.match(RegExp(`.{1,${n/n*n}}`, 'g')) || [];
Pieter Stokkink
@forkerino
Sep 12 2017 18:56
and .match?
ah yes
Christopher McCormack
@cmccormack
Sep 12 2017 18:56
@forkerino hiya
Pieter Stokkink
@forkerino
Sep 12 2017 18:56
@cmccormack what's up?
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:57
:wave: @forkerino
Christopher McCormack
@cmccormack
Sep 12 2017 18:57
@forkerino been working on my personal webpack/react setup lately, tons of work to get it right apparently
Pieter Stokkink
@forkerino
Sep 12 2017 18:57
Guess so
:)
I'm learning Elm now
Good stuff
Christopher McCormack
@cmccormack
Sep 12 2017 18:57
learned so much along the way though, best thing I learned was that I should probably just use create-react-app :D
Pieter Stokkink
@forkerino
Sep 12 2017 18:57
hahaha
Kelechi Chinaka
@ke1echi
Sep 12 2017 18:58
how did you realise that n was i string, i saw it as a number when i consoled it @cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 18:58
@kelechy 3angle was n
I just logged both parameters separately - don't forget a comma in a single console.log will just separate with a space
Kelechi Chinaka
@ke1echi
Sep 12 2017 19:00
ooooh :smile: @cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 19:00
@forkerino that looks pretty neat - I'm guessing you need to use babel though?
Or does it have it's own compiler? That syntax doesn't looks like something the browser would understand
Pieter Stokkink
@forkerino
Sep 12 2017 19:02
@cmccormack It compiles to JS
so yeah, you compile it and include the resulting js in your html.
Jason Luboff
@JLuboff
Sep 12 2017 19:04
@forkerino :wave:
Christopher McCormack
@cmccormack
Sep 12 2017 19:07
@forkerino what CSS preprocessors do you guys use?
Pieter Stokkink
@forkerino
Sep 12 2017 19:07
! @JLuboff
Gersho
@Gersho
Sep 12 2017 19:08
@kelechy @cmccormack we ended up with almost the same solution
Pieter Stokkink
@forkerino
Sep 12 2017 19:08
what's up? @JLuboff
@cmccormack SCSS
Christopher McCormack
@cmccormack
Sep 12 2017 19:09
@forkerino he's rushing with a stack of cash to get the new iPhone atm
Marc
@MWBauer
Sep 12 2017 19:09

function chunkArrayInGroups(arr, size) {
  var brArr = [];
  for (i = 0; i < 2; i++) {
    brArr.push(arr.slice(0, 2));
  } return brArr;  
}
I'm coming back with 2 arrays of a and b.
How can I make the second array c and d
?
Christopher McCormack
@cmccormack
Sep 12 2017 19:10
@MWBauer you're using 0 and 2 but you aren't changing arr
Gersho
@Gersho
Sep 12 2017 19:10
or size
Christopher McCormack
@cmccormack
Sep 12 2017 19:10
@MWBauer why i < 2?
Marc
@MWBauer
Sep 12 2017 19:10
Because there should only be 2 elements in each array
Christopher McCormack
@cmccormack
Sep 12 2017 19:11
maybe do something like arr.length/size and use splice instead, up to you
Marc
@MWBauer
Sep 12 2017 19:11
/size?
I was originally trying to use splice but someone said to use slice
Christopher McCormack
@cmccormack
Sep 12 2017 19:12
divided by
Jason Luboff
@JLuboff
Sep 12 2017 19:12
@forkerino Same ol' same ol. Been working on my Game (book) trading app and studying Microsoft SQL. You?
Christopher McCormack
@cmccormack
Sep 12 2017 19:12
there are several ways to do this problem
Marc
@MWBauer
Sep 12 2017 19:12
I'm sure there are.
I'm just trying to figure one of them out.
Christopher McCormack
@cmccormack
Sep 12 2017 19:13

@MWBauer if you want to use slice, then you need to somehow increment your slice arguments. You can multiple your index by size and use that:

...slice(i*size, i*size + size)

but make sure your conditional in your for loop is also correct

Marc
@MWBauer
Sep 12 2017 19:14
LOLOL I love how you say this. I just wish I understood the jargon better.
Pieter Stokkink
@forkerino
Sep 12 2017 19:14
@JLuboff besides work and family I have very little time. So it's a little hectic. Still learning some stuff in my free time whenever I get the chance, but no bigger projects.
Marc
@MWBauer
Sep 12 2017 19:14
Maybe dumb it down a little?
Christopher McCormack
@cmccormack
Sep 12 2017 19:14
@MWBauer what jargon?
Marc
@MWBauer
Sep 12 2017 19:14
programming jargon
Jason Luboff
@JLuboff
Sep 12 2017 19:14
@forkerino Ya... baby's coming soon so we've been busy prepping
Gersho
@Gersho
Sep 12 2017 19:14
first one ? @JLuboff
Jason Luboff
@JLuboff
Sep 12 2017 19:15
@Gersho Yup!
Christopher McCormack
@cmccormack
Sep 12 2017 19:15
all of this jargon is explained in the exercises, make sure you read them through. It helps to better understand what to search for later when you hit a roadblock
Gersho
@Gersho
Sep 12 2017 19:15
well, it's been nice knowing you
Jason Luboff
@JLuboff
Sep 12 2017 19:15
Most likely only one as well lol
@Gersho lol, don't worry, I'm usually only on here during work
Marc
@MWBauer
Sep 12 2017 19:15
In your example, I is the iteration then you multiply by size?
Christopher McCormack
@cmccormack
Sep 12 2017 19:15
@MWBauer yes
those are both variables already in your code, I didn't make them up
Marc
@MWBauer
Sep 12 2017 19:16
I'm just trying to follow
Christopher McCormack
@cmccormack
Sep 12 2017 19:16
np
Ooops I guess I did use the wrong term, i is your index, not iterator
Pieter Stokkink
@forkerino
Sep 12 2017 19:17
@JLuboff two months-ish left right?
Marc
@MWBauer
Sep 12 2017 19:17
Can you put into English what the ...slice(I*size...) is doing?
Jake
@JakeDVirus
Sep 12 2017 19:18
can i clone a DOM element only once using jquery .clone() method and then add it to several different section of the page?? or shall i have to clone each time i have to add?
Gersho
@Gersho
Sep 12 2017 19:22
i haven't tested, but there's
$clone = $elem.clone( true )
in the doc, so i suppose you can store it in a variable that way
Christopher McCormack
@cmccormack
Sep 12 2017 19:23
@NeelDVirus you'll have to clone each time
Gersho
@Gersho
Sep 12 2017 19:23
and i sounded smart for about 4 seconds here
Jake
@JakeDVirus
Sep 12 2017 19:24
@cmccormack is there any other way or any substitute?
Christopher McCormack
@cmccormack
Sep 12 2017 19:24
@NeelDVirus what's wrong with cloning?
Jake
@JakeDVirus
Sep 12 2017 19:25
@Gersho hehe
Gersho
@Gersho
Sep 12 2017 19:25
he's probably trying to avoid redundance ?
Jake
@JakeDVirus
Sep 12 2017 19:26
@cmccormack i was wondering if cloning has a performance impact and by repetition of it the impact might get repeated. i am being blunt here
Jason Luboff
@JLuboff
Sep 12 2017 19:26
@forkerino Roughly. November 13, but at the last doctors visit..the doctor said he could come as early as middle of October!
Christopher McCormack
@cmccormack
Sep 12 2017 19:27
@NeelDVirus nope cloning is probably the best way to do it, storing the cloned item in memory has very little impact, it's only when you add to the DOM that you're going to experience the performance issues. Better to append a clone into to a virtual element first then append that container element to the DOM
Gersho
@Gersho
Sep 12 2017 19:28

@forkerino Roughly. November 13, but at the last doctors visit..the doctor said he could come as early as middle of October!

about as accurate as the utilities giving you a window for their technician to come

Jason Luboff
@JLuboff
Sep 12 2017 19:28
Lol pretty much
Jake
@JakeDVirus
Sep 12 2017 19:29
@cmccormack can you please elaborate this a bit more "Better to append a clone into to a virtual element first then append that container element to the DOM"
Gersho
@Gersho
Sep 12 2017 19:29
wouldn't that be react ?
Jake
@JakeDVirus
Sep 12 2017 19:29
what's virtual element?
Christopher McCormack
@cmccormack
Sep 12 2017 19:30
@NeelDVirus here is a really crappy example - https://codepen.io/cmccormack/pen/WZNjQG
Pieter Stokkink
@forkerino
Sep 12 2017 19:31
@JLuboff awesome. Exciting times ahead with a lot of firsts!
Jason Luboff
@JLuboff
Sep 12 2017 19:32
@forkerino Oh ya! The baby class we did over the weekend gave some insights into it all. Don't think I'm prepared, but who ever is?
Gersho
@Gersho
Sep 12 2017 19:32
as long as you don't drop it you should be fine
Christopher McCormack
@cmccormack
Sep 12 2017 19:32
@NeelDVirus just an element that's been created but not added to the DOM. I may not be using the correct terms for this, but that's what I call it
Jason Luboff
@JLuboff
Sep 12 2017 19:32
I think I can manage to not do that :D
Gersho
@Gersho
Sep 12 2017 19:33
@cmccormack virtual DOM is the term used by react to allow itself to modify only part of the page (don't ask me specifics i'm new to react)
Jake
@JakeDVirus
Sep 12 2017 19:33
@cmccormack oh i got it, Thanks for the effort man
CamperBot
@camperbot
Sep 12 2017 19:33
neeldvirus sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1208 | @cmccormack |http://www.freecodecamp.com/cmccormack
Jake
@JakeDVirus
Sep 12 2017 19:34
@Gersho i also heard the term virtual DOM related to react. i haven't started react yet
Gersho
@Gersho
Sep 12 2017 19:35
https://www.codecademy.com/articles/react-virtual-dom
scroll down to bottom for the tl;dr
Christopher McCormack
@cmccormack
Sep 12 2017 19:35
Virtual DOM is different, when I'm referring to virtual elements I'm only describing a jQuery element that may have been created or cloned from jQuery but not appended to the DOM
Virtual DOM is what React uses to determine what has changed so it only changes the actual DOM where needed
Gersho
@Gersho
Sep 12 2017 19:36
you should find another term for it when you talk about it to other people i think :P you might end up confusing them
by the way, you use $box as your variable name, is the $ mandatory or is it some coding convention ?
Jake
@JakeDVirus
Sep 12 2017 19:38
@cmccormack i am still trying to understand the logics behind your code. i am feelilng stupid for myself atm :D
@cmccormack you told "element that's been created but not added to the DOM". But i see in the code that $box is added to the body before the loop started.
Gersho
@Gersho
Sep 12 2017 19:40
only one
Pieter Stokkink
@forkerino
Sep 12 2017 19:41
@JLuboff You cannot prepare for everything. I know I didn't feel ready when the water broke, but everything came naturally afterwards.
Jake
@JakeDVirus
Sep 12 2017 19:41
@Gersho using $ is just a naming convention in jquery. it helps to identify that's jquery variable
Gersho
@Gersho
Sep 12 2017 19:42
@NeelDVirus thanks
CamperBot
@camperbot
Sep 12 2017 19:42
gersho sends brownie points to @neeldvirus :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @neeldvirus |http://www.freecodecamp.com/neeldvirus
Jason Luboff
@JLuboff
Sep 12 2017 19:43
@forkerino Ya I know. I'm just trying to roll with the punches. My wife is a bit worried but I'm doing my best to reassure her
Christopher McCormack
@cmccormack
Sep 12 2017 19:44
Yes sorry I grabbed some lunch real quick - that first one was a test for myself and can probably be ignored
Jake
@JakeDVirus
Sep 12 2017 19:45
@cmccormack hey man i got it. smart move i must say.
Christopher McCormack
@cmccormack
Sep 12 2017 19:45
@NeelDVirus I changed it to show my test - notice how test-1 disappears
@NeelDVirus hope it helps!
Jake
@JakeDVirus
Sep 12 2017 19:46
so the whole point of this is "decreasing the appeding process to the lowest" which i see only twice. isn't it?
Christopher McCormack
@cmccormack
Sep 12 2017 19:47
@NeelDVirus in the current state, 3 times, but yes, if you can bundle all of your entries you should. Sometimes you cannot, as they are under different parents, but that's fine, in the end it won't be THAT slow unless you're really adding a lot
@NeelDVirus like for this project - https://codepen.io/cmccormack/pen/QMeXvo if you were to add each path to the DOM individually it would be really slow I imagine
Jake
@JakeDVirus
Sep 12 2017 19:48
@cmccormack i am checking out the updated code now. was delving in the previous-state one
Jake
@JakeDVirus
Sep 12 2017 19:54
@cmccormack test-1 disappeared because the element was moved from the earlier position to new position(though it is the same position in this instance) without cloning it again. i guess i am correct here
Mark Kubik
@KUBIX90
Sep 12 2017 19:54
$(document).ready(function(){

    $("#get-quote").on("click", function(){

        var API_URL = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1";
        //Pull quote from API
        $.ajax({
            url: API_URL,    
            success: function(post){
                post = post[0];
                tweet = "https://twitter.com/intent/tweet?text=" + encodeURI(post.title + post.content);
                $("#quote-author").html(post.title);
                $("#quote-content").html(post.content);
                $("#tweetButton").attr("href", tweet);
            },
            cache:false
        });
    });
});
Finishing off the quote generator , I've got <p> tags showing up in the quote when I press the twitter button any idea how to get rid of them? I've tried to use the replace method but not getting anywhere.
Christopher McCormack
@cmccormack
Sep 12 2017 19:55
@NeelDVirus test-1 is actually being changed in place to test-2, otherwise you would see two boxes added
you're still referencing the same box when you change the text
that's why cloning would be required
@KUBIX90 you can use a regex to get rid of them if you want
Jake
@JakeDVirus
Sep 12 2017 19:57
@cmccormack yeah i got the whole plot now. nice presentation btw
Christopher McCormack
@cmccormack
Sep 12 2017 19:57
@NeelDVirus haha thanks
CamperBot
@camperbot
Sep 12 2017 19:57
cmccormack sends brownie points to @neeldvirus :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @neeldvirus |http://www.freecodecamp.com/neeldvirus
Christopher McCormack
@cmccormack
Sep 12 2017 19:58
@KUBIX90 this seems to work for me:
> '<p>this is a test</p>'.replace(/<\/?p>/g, '')
'this is a test'
@KUBIX90 you could also pull the text from your $("#quote-content") selector, something like encodeURI(post.title + $("#quote-content").text()) Of course you would have to move your tweet below your quote-content processing
Kelechi Chinaka
@ke1echi
Sep 12 2017 20:01
is it important to understand the workings of the dom before learning react @cmccormack
Gersho
@Gersho
Sep 12 2017 20:02
not really, but you need to understand it exists and what's the point
codeAcademy lesson on react is nice
Mark Kubik
@KUBIX90
Sep 12 2017 20:05
@cmccormack I've tried the regex but I'm getting nothing
$(document).ready(function(){

    $("#get-quote").on("click", function(){

        var API_URL = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1";
        //Pull quote from API
        $.ajax({
            url: API_URL,    
            success: function(post){
                post = post[0];
                tweet = "https://twitter.com/intent/tweet?text=" + encodeURI(post.title + post.content).replace(/<\/?p>/g, ' ');
                $("#quote-author").html(post.title);
                $("#quote-content").html(post.content);
                $("#tweetButton").attr("href", tweet);
            },
            cache:false
        });
    });
});
Christopher McCormack
@cmccormack
Sep 12 2017 20:05
@kelechy what's great about React is it handles all that for you, but it's important to know about the DOM if you're going to code for the web :)
@KUBIX90 try post.content.replace(/<\/?p>/g, ' '))
Gersho
@Gersho
Sep 12 2017 20:06
and if you hate regex that much remove first 3 and 4 lasts chars from string [lamecode inc]
Mark Kubik
@KUBIX90
Sep 12 2017 20:07
@cmccormack Seems to have done the trick, thanks very much!! Tried it on post.title but forgot to do it on the post.content!
CamperBot
@camperbot
Sep 12 2017 20:07
:star2: 1209 | @cmccormack |http://www.freecodecamp.com/cmccormack
kubix90 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Sep 12 2017 20:07

I feel like that could lead to logic errors (potentially)

Though I'm jumping in on the middle of discussion so :p

Kelechi Chinaka
@ke1echi
Sep 12 2017 20:08
then i need to up my DOM game :smile: @cmccormack
Gersho
@Gersho
Sep 12 2017 20:08
@kumquatfelafel nono you're right my "solution" was here for comic relief
Christopher McCormack
@cmccormack
Sep 12 2017 20:09
@kelechy I think if you keep in mind that updating the DOM is an expensive task, you have enough to get started at least
@kumquatfelafel hi!
kumquatfelafel
@kumquatfelafel
Sep 12 2017 20:09
haha. alright
hey
kumquatfelafel @kumquatfelafel is semi-here
Christopher McCormack
@cmccormack
Sep 12 2017 20:10
@KUBIX90 I think the nicer hack still would be to push the post content onto the DOM then read the .text() from that element, which should grab what's inside the <p> element I think
Gersho
@Gersho
Sep 12 2017 20:11
isn't there some way to have .html nest the <p> rather than print it ?
Mark Kubik
@KUBIX90
Sep 12 2017 20:11
@cmccormack hmm fair enough, I'll have a fiddle round with it to see if it's better
Christopher McCormack
@cmccormack
Sep 12 2017 20:11
@Gersho it is doing that.
Kelechi Chinaka
@ke1echi
Sep 12 2017 20:14
:smile: i dont get, how do u mean @cmccormack
:smile: i dont get, how do u mean @cmccormack
Gersho
@Gersho
Sep 12 2017 20:14
expensive in terms of computing ressources
Christopher McCormack
@cmccormack
Sep 12 2017 20:15
Kelechi Chinaka
@ke1echi
Sep 12 2017 20:16
you are making it sound scary :smile: @cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 20:17
It's just an abstraction though, it may be slow to do but it can still do it. Just be aware of the limitations
Christopher McCormack
@cmccormack
Sep 12 2017 20:23
One thing to note in that SO post is how the DOM API is much faster than using innerHTML.
@KUBIX90
<div id='test'><p>This is a test</p></div>
console.log(JSON.stringify($('#test').text())) // "This is a test"
console.log(JSON.stringify($('#test').html())) // "<p>This is a test</p>"
Simon Cordova
@gbsimon87
Sep 12 2017 20:30
Hey all, good evening!
kumquatfelafel
@kumquatfelafel
Sep 12 2017 20:32
hi
Kelechi Chinaka
@ke1echi
Sep 12 2017 20:36
been a while @kumquatfelafel
kumquatfelafel
@kumquatfelafel
Sep 12 2017 20:36
aye. Was visiting friends :)
Margaret Greaney
@greaneym
Sep 12 2017 20:41
@cmccormack , thanks again for your codepen link, I am learning from it.
CamperBot
@camperbot
Sep 12 2017 20:41
greaneym sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1210 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Sep 12 2017 20:42
@greaneym you're welcome! Which one, I forget :)
legendinraze
@legendinraze
Sep 12 2017 20:42
Can someon help me with wheres waldo
someone*
function findWaldo(str) {
  var waldoPosition;
  // Code below here
 Waldo.indexOf ("I'm a little tea pot. Waldo is a big tea pot.", );
  return waldoPosition;
}
Christopher McCormack
@cmccormack
Sep 12 2017 20:43
@legendinraze What is Waldo?
Diego Mayer
@Chrono79
Sep 12 2017 20:43
@legendinraze that comma inside indexOf isn't right either
Christopher McCormack
@cmccormack
Sep 12 2017 20:43
@legendinraze you're function parameter is str, you should be using that
kumquatfelafel
@kumquatfelafel
Sep 12 2017 20:43

@legendinraze indexOf will search for the specified string. So you're searching for the string "I'm a little tea ... is a big tea pot."

Additionally, if you don't store this value or use it immediately, it's not useable.

also, yeah, that comma is no good.
Margaret Greaney
@greaneym
Sep 12 2017 20:44
it was the one that changes text, to uppercase , you said you used it for markup. I will use it to learn how to set up sass.
Christopher McCormack
@cmccormack
Sep 12 2017 20:44
@greaneym oh ok good, was hoping it wasn't something temp I might delete :)
kumquatfelafel
@kumquatfelafel
Sep 12 2017 20:45
Also, Waldo is not a defined variable, I suspect what you want is . Oh wait... @cmccormack already brought this up
Diego Mayer
@Chrono79
Sep 12 2017 20:45

@legendinraze What is Waldo?

Are you trying to invent a new game? @cmccormack :P

Margaret Greaney
@greaneym
Sep 12 2017 20:45
But I have a jsx react camp leaderboard that works locally on my laptop, but when I put it on codepen I think I don't have the right set up. Does anyone have a codepen with the javascript settings so that jsx works. I get the error <.
Christopher McCormack
@cmccormack
Sep 12 2017 20:45
@Chrono79 haha it's more existential.
legendinraze
@legendinraze
Sep 12 2017 20:45
no it's a lesson
kumquatfelafel
@kumquatfelafel
Sep 12 2017 20:45
Why is Waldo? :o
Christopher McCormack
@cmccormack
Sep 12 2017 20:46
@greaneym must include babel preprocessor most likely
@greaneym my example should have all those settings
Margaret Greaney
@greaneym
Sep 12 2017 20:46
that is the first problem. second is that I can't do a json retrieval of data and have to use jsonp. My fetch-json is not working.
Christopher McCormack
@cmccormack
Sep 12 2017 20:47
@greaneym what api?
Margaret Greaney
@greaneym
Sep 12 2017 20:47
@cmccormack, I did set up the react, react-dom, browser.js cdns and these did not work, next tried standalone browser cdn, did not work, so still trying.
Christopher McCormack
@cmccormack
Sep 12 2017 20:47
@greaneym link your codepen
@greaneym you should really only need Babel preprocessor, React, and React-DOM to get started, and SCSS for the CSS preprocessor if the project still requires it
Margaret Greaney
@greaneym
Sep 12 2017 20:48
npm fetch-json trying to get the alltime data, here is the codepen link, have to login there again.
Christopher McCormack
@cmccormack
Sep 12 2017 20:48
@greaneym you shouldn't need another library to fetch, just use fetch
Christopher McCormack
@cmccormack
Sep 12 2017 20:49
fetch(url).then((response)=>response.json()).then((data)=>{[do something with data]})
Margaret Greaney
@greaneym
Sep 12 2017 20:49
I tried fetch, but got cors errors in the console
Simon Cordova
@gbsimon87
Sep 12 2017 20:49
Does anyone here have experience append list items to a ul
iterating from an object
Margaret Greaney
@greaneym
Sep 12 2017 20:49
it works locally on my laptop with plain fetch.
Christopher McCormack
@cmccormack
Sep 12 2017 20:50
@greaneym yeah CORS issues can be a pain
Diego Mayer
@Chrono79
Sep 12 2017 20:51
@gbsimon87 use Object(keys) and a foreach or for ... in
Margaret Greaney
@greaneym
Sep 12 2017 20:51
Also don't have the scss set up yet.
Christopher McCormack
@cmccormack
Sep 12 2017 20:52
@greaneym for codepen, get rid of the scripts in your head and add them via the settings > Javascript
@greaneym and don't forget the Babel preprocessor
Margaret Greaney
@greaneym
Sep 12 2017 20:53
@cmccormack , I did try that as well, but I will try again. Does it matter if the babel preprocessor is before react or after it?
Christopher McCormack
@cmccormack
Sep 12 2017 20:53
@greaneym it's not a js script, it's a dropdown in your settings
Margaret Greaney
@greaneym
Sep 12 2017 20:53
I was adding browser.js from a cdn, is that not right , or adding it in the dropdown.
I did add the babel tag also, and also tried the jsx tag.
Christopher McCormack
@cmccormack
Sep 12 2017 20:54
@greaneym "https://fcctop100.herokuapp.com/api/fccusers/top/alltime" should be your URL
@greaneym I have no idea what browser.js is but I don't think it has anything to do with Babel
Babel is a preprocessor, it takes your code and turns it into something that most browsers know how to read
Margaret Greaney
@greaneym
Sep 12 2017 20:56
the alltime.jsonp was just another attempt. So you say, do not add browser.js as a dropdown setting, just add react, react-dom and have the babel script tag, and those are enough?
Christopher McCormack
@cmccormack
Sep 12 2017 20:57
image.png
Margaret Greaney
@greaneym
Sep 12 2017 20:57
plus the fetch-jsonp addition
Christopher McCormack
@cmccormack
Sep 12 2017 20:57
your json fetch was working fine, you don't need jsonp
once I changed the URL back, that is
Margaret Greaney
@greaneym
Sep 12 2017 20:58
thanks, for the screenshot, I never did put it in, the babel prepro. selection. I will try again with your suggestions. thanks, @cmccormack
CamperBot
@camperbot
Sep 12 2017 20:58
greaneym sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Margaret Greaney
@greaneym
Sep 12 2017 20:59
back later
Christopher McCormack
@cmccormack
Sep 12 2017 20:59
@greaneym here's a clone I made in case it helps a bit https://codepen.io/cmccormack/pen/boGrGz
@greaneym it's pulling the data now you just need to display it
Margaret Greaney
@greaneym
Sep 12 2017 21:06
@cmccormack , thank you so much, it is working now! I wasn't using the pulldown babel preprocessor. Now I just need to work on the scss file. Thank you.
CamperBot
@camperbot
Sep 12 2017 21:06
greaneym sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
api offline
Christopher McCormack
@cmccormack
Sep 12 2017 21:06
@greaneym np
Gersho
@Gersho
Sep 12 2017 21:07
any python brain present ? :3
Diego Mayer
@Chrono79
Sep 12 2017 21:11
just a few brain cells dedicated to python, not enough I guess
John
@AnonymousLords
Sep 12 2017 21:14
Hey guys
Stephen James
@sjames1958gm
Sep 12 2017 21:14
@AnonymousLords Hello
John
@AnonymousLords
Sep 12 2017 21:14
i called a function later on (range2) and its saying its not defined.
function findLevel(input4) {
    if (input4 <= 6000000) {
        input4 /= 20000
        return input4
        function range2(input5) { // The function
            var level2 = 0;
            var input6 = input5;
            for (var i = 301; i < 1000; i++) {
            while (input5 + findLevelEXP(i) < findTotalExp(1000)) {
                input5 += findLevelEXP(i)
                level2 = level2 + 1
            }
          }
          return level2
        }
    } else if (input4 > 6000000 && input4 <= 93605000) {
        var level = 0;
        input4 -= 6000000
        level+= 300
        return level + range2(input4) // call it here but its undefined
    }
}
findLevel(6000001)
Diego Mayer
@Chrono79
Sep 12 2017 21:15
@AnonymousLords it's declared inside an if, maybe the if condition is not true, well, you call it in the else, so it surely is not defined there
John
@AnonymousLords
Sep 12 2017 21:15
OH
thanks @Chrono79
CamperBot
@camperbot
Sep 12 2017 21:16
anonymouslords sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4536 | @chrono79 |http://www.freecodecamp.com/chrono79
John
@AnonymousLords
Sep 12 2017 21:16
Didnt notice that lol
Pieter Stokkink
@forkerino
Sep 12 2017 21:16
consider naming your variables properly
John
@AnonymousLords
Sep 12 2017 21:16
I know what they mean
Pieter Stokkink
@forkerino
Sep 12 2017 21:17
You won't if you don't look at the code for two weeks
Diego Mayer
@Chrono79
Sep 12 2017 21:18
@AnonymousLords you should also notice that after the first return, the rest of the code is ignored
John
@AnonymousLords
Sep 12 2017 21:18
@Chrono79 Yeah its supposed to do that
Its a giant filter
Diego Mayer
@Chrono79
Sep 12 2017 21:20
@AnonymousLords I meant that even inside the first if, the definition wasn't reached
Jay Vora
@jayvora92
Sep 12 2017 21:20
hello everyone i want to hash the email address that submit on form. Does anyone kno the best resource for MD5 script where i can add the current JS variable which grabs the email address from form
John
@AnonymousLords
Sep 12 2017 21:22
@Chrono79 okay
Kevin Peña
@kebien6020
Sep 12 2017 22:02
@jayvora92 If you can install node packages md5 is probably what you are looking for
Jay Vora
@jayvora92
Sep 12 2017 22:16
@kebien6020 thanks but i want this to run in google tag manager
CamperBot
@camperbot
Sep 12 2017 22:16
jayvora92 sends brownie points to @kebien6020 :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @kebien6020 |http://www.freecodecamp.com/kebien6020
Garrus Napp
@GarrusNapp
Sep 12 2017 22:22
sup guys
I wanted to fix a problem using regular expressions and I have now 2 problems
Simon Cordova
@gbsimon87
Sep 12 2017 22:30
@Chrono79 how you doing buds
I saw your msg earlier about the for in loops...Any chance you're still around?
Diego Mayer
@Chrono79
Sep 12 2017 22:35
@gbsimon87 I just arrived home
Simon Cordova
@gbsimon87
Sep 12 2017 22:36
Is that good or bad news for me? lol
Diego Mayer
@Chrono79
Sep 12 2017 22:36
dunno, what's the question? ;)
Simon Cordova
@gbsimon87
Sep 12 2017 22:37
menu = {
                    1: {
                        label: 'Shop By Recipient',
                        links: {
                            1: [
                            ['Personalised Gifts For Him', '/gifts-for-him/personalised-gifts-for-him.htm'],
                            ['Personalised Gifts For Her', '/gifts-for-her/personalised-gifts-for-her.htm'],
                            ['Personalised Gifts For Kids', '/gifts-for-kids/personalised-gifts-for-kids.htm'],
                            ['Personalised Baby Gifts', '/baby-gifts/personalised-baby-gifts.htm'],
                            ['Gifts For Couples', '/gifts-for-recipients/gifts-for-couples.htm']
                            ]
                        }
                    },
                    2: {
                        label: 'Gifts For Occasions',
                        links: {
                            1: [
                            ['Personalised Birthday Gifts', '/wedding-gifts/bride-and-groom-gifts.htm'],
                            ['Christening Gifts', '/christening-presents/christening-gifts.htm'],
                            ['Personalised Anniversary Gifts', '/anniversary-presents/personalised-anniversary-gifts.htm'],
                            ['Personalised Wedding Gifts', '/wedding-gifts/personalised-wedding-gifts.htm']
                            ]
                        }
                    },
                    3: {
                        label: 'Top Personalised Gifts ',
                        links: {
                            1: [
                            ['Notebooks','/personalised-gifts/personalised-notebooks.htm'],
                            ['Mugs','/personalised-gifts/personalised-mugs.htm'],
                            ['Aprons','/gifts/personalised-aprons'],
                            ['Wine Glasses','/personalised-gifts/personalised-wine-glasses.htm'],
                            ['Books','/gifts/books.htm'],
                            ['Whisky Glasses','/gifts/personalised-whiskey-glasses.htm'],
                            ['Pint Glasses','/personalised-gifts/personalised-pint-glasses.htm'],
                            [' Jewellery','/personalised-gifts/personalised-jewellery.htm']
                            ]
                        }
                    },
                    4: {
                        label: 'Engraved Gifts',
                        links: {
                            1: [
                            ['Slate Gifts', '/personalised-gifts/personalised-slates.htm'],
                            ['Wood Gifts', '/personalised-presents/personalised-wooden-gifts.htm'],
                            ['Glass Gifts', '/personalised-gifts/personalised-glass-gifts.htm'],
                            ['Silver Gifts', '/personalised-gifts/engraved-silver-gifts.htm'],
                            ['Engraved Gifts', '/personalised-gifts/engraved-gifts.htm']
                            ]
                        }
                    },
                    5: {
                        label: 'More Personalised Gifts ',
                        links: {
                            1: [
                            ['Cheeseboards', '/gifts/personalised-cheeseboards.htm'],
                            ['Cufflinks', '/gifts/cufflinks.htm'],
                            ['Jewellery Boxes', '/personalised-gifts/personalised-jewellery.htm'],
                            ['Wall Art', '/gifts/personalised-wall-art'],
                            ['Alcohol', '/personalised-gifts/personalised-alcohol.htm'],
                            ['Unusual gifts', '/personalised-gifts/unusual-personalised-gifts.htm'],
                            ['Photo Frames', '/gifts/personalised-photo-frames.htm'],
                            ['Cushions', '/gifts/personalised-cushions.htm']
                            ]
                        }
                    }

                };// CLOSE MENU OBJECT
Whoa, that was way bigger than expected, should have provided a codepen sorry
But I've got an object like that..
The labels are the header names, and the links have arrays with the link text and their href...
image.png
Kind of like that...
What I want to do is be able to iterate through the object and append list items to an unorganized list
whereas the first li would be the 'label', then the next li's would be the the arrays within links..
makes sense?
Diego Mayer
@Chrono79
Sep 12 2017 22:40
somehow
Jake
@JakeDVirus
Sep 12 2017 22:42

suppose i have a code like this

function rough1(){
    followingList[i];
   //some other statements
};

function rough2(){
    var followingList =[Array];
   //some other statements
    function rough3(){
          rough1(){};
    }
}

according to name-resolution lookup and execution context, the function rough1 will have access to the variable followingList when called inside the function rough3.
Am i right or wrong?
Actually in my specific piece of code the variable followingList is said to be not defined when called in this manner.

Simon Cordova
@gbsimon87
Sep 12 2017 22:45
@Chrono79 something like this...
<div id='mainContainer'>
     // FIRST UL
  <ul>
    <li>menu.1.label</li>
    <li>menu.1.link 1</li>
    <li>menu.1.link 2</li>
</ul>

   // SECOND UL
  <ul>
    <li>menu.2.label</li>
    <li>menu.2.link 1 </li>
    <li>menu.2.link 2 </li>
</ul>

</div>
Diego Mayer
@Chrono79
Sep 12 2017 22:48
for (var category in menu) {
  console.log(menu[category].label);
  for (var link in menu[category]['links']['1']) {
    console.log(menu[category]['links']['1'][link]); //this will give you an array of the title and the url of the link
  }
}
Try something like that, you can append the html tags one by one or build the whole html in a var and append it at the end
Simon Cordova
@gbsimon87
Sep 12 2017 22:53
Yeah I'd like to build the whole thing at once and append at the end
I've got about a hundred links to do spread across 6 websites so the most dynamic way I can approach this would be my best bet
@Chrono79 thanks a lot, honestly, this really helped
CamperBot
@camperbot
Sep 12 2017 22:57
gbsimon87 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4537 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Sep 12 2017 22:57
:+1:
Simon Cordova
@gbsimon87
Sep 12 2017 22:58
I've been struggling using jquery $.each to little resolution
Jason Luboff
@JLuboff
Sep 12 2017 23:03
Isn't $.each essentially the same as forEach?
Christopher McCormack
@cmccormack
Sep 12 2017 23:03
Am I a crazy person or is the first example on the React refs page incorrect? Shouldn't it be onClick={this.focusTextInput} on the button?
Jason Luboff
@JLuboff
Sep 12 2017 23:04
@cmccormack You're crazy.
Christopher McCormack
@cmccormack
Sep 12 2017 23:05
Dang.
Jason Luboff
@JLuboff
Sep 12 2017 23:05
But really..I have no clue
Diego Mayer
@Chrono79
Sep 12 2017 23:06
@cmccormack it seems to be wrong
Christopher McCormack
@cmccormack
Sep 12 2017 23:06
Thanks @Chrono79 I thought so
CamperBot
@camperbot
Sep 12 2017 23:06
cmccormack sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4538 | @chrono79 |http://www.freecodecamp.com/chrono79
Simon Cordova
@gbsimon87
Sep 12 2017 23:08
@JLuboff I believe it is, but I guess I just don't know how to use it all that well
Does anyone have three minutes if I send them some code and a website to paste the code in the console and see if they have any clue how to accomplish the task at hand. I'm so damn lost.
Everytime I think I'm advancing at Javascript something comes up and makes me realize I'm still a rook
Simon Cordova
@gbsimon87
Sep 12 2017 23:14
Dang, maybe next time lol
Christopher McCormack
@cmccormack
Sep 12 2017 23:15
@gbsimon87 welcome to the club :D
Jason Luboff
@JLuboff
Sep 12 2017 23:15
I think I'm advancing then @Chrono79 posts something and I go "wtf"
Christopher McCormack
@cmccormack
Sep 12 2017 23:18
@gbsimon87 what's your issue?
Simon Cordova
@gbsimon87
Sep 12 2017 23:19
lolol
@cmccormack I'll put the code on a codepen and send you the site...
You have to open the site in mobile view on the browser

If you add that code to the console on that site, you'll see a bunch of links come up...
In my code, the function called generateLinks has a number of if conditions checking for the URL.

The one I sent you is the first one...within that function there is an object called menu, I need to use those that info to replace the current links on the list show on the site

@Chrono79 got me started but I'm still way lost
Simon Cordova
@gbsimon87
Sep 12 2017 23:25
Does that make sense?
Christopher McCormack
@cmccormack
Sep 12 2017 23:43
@gbsimon87 Not sure I get what is failing in your scenario, sorry. I have to run for a bit to make dinner but I can take a look when I get back, but if you explain it succinctly maybe someone else here can also help
Simon Cordova
@gbsimon87
Sep 12 2017 23:46
@cmccormack no worries, thanks for the offer nonetheless I do appreciate it
CamperBot
@camperbot
Sep 12 2017 23:46
gbsimon87 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1212 | @cmccormack |http://www.freecodecamp.com/cmccormack