These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Aug 2018
Christopher McCormack
@cmccormack
Aug 13 2018 00:01
try to walk through the logic - if the current contact first name matches the name parameter, then I want to check the property. If I find the property for that matched name, I want to return it. If I don't find that property, I want to return a string that says No such property. I don't need to progress through the remaining contacts because I already found the contact by name. However, there is a case that you never find a matching contact where you want to return No such contact. This case only happens when you have exhausted all of the contacts and thus you would not return this inside your for loop @Fikry82
Fikry82
@Fikry82
Aug 13 2018 00:25
function lookUpProfile(name, prop){
// Only change code below this line

for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName == name){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }else{
        return "No such property";
      }

    }else{
        return "No such contact";
    }
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
is that better ?
@cmccormack
Greg Duncan
@GregatGit
Aug 13 2018 00:32
@Fikry82 your final return "no such contact" should be outside the for loop - only reached if you loop through everything
not part of any else statement
Fikry82
@Fikry82
Aug 13 2018 00:34
wow
thx @GregatGit
thx @cmccormack
it works :)
Christopher McCormack
@cmccormack
Aug 13 2018 00:47
@Fikry82 :thumbsup:
Fikry82
@Fikry82
Aug 13 2018 00:48
thx @cmccormack your explanation helped me allot ...
Christopher McCormack
@cmccormack
Aug 13 2018 00:48
glad it helped!
Fikry82
@Fikry82
Aug 13 2018 00:49
so can i go somewhere with javascripet or not
Christopher McCormack
@cmccormack
Aug 13 2018 00:50
@Fikry82 keep practicing and it will keep getting easier
Fikry82
@Fikry82
Aug 13 2018 00:50
i hope so
Christopher McCormack
@cmccormack
Aug 13 2018 00:50
When there used to be a lot more people in these chats, this specific problem probably had the most questions asked
it's a milestone problem
Fikry82
@Fikry82
Aug 13 2018 00:51
i think my bad English work against me .... when i understand the logic its much easier to code
Christopher McCormack
@cmccormack
Aug 13 2018 00:52
keep practicing that too!
Fikry82
@Fikry82
Aug 13 2018 00:54
all my English knowledge from American movies ... i think i will watch more movies hahahah
Christopher McCormack
@cmccormack
Aug 13 2018 00:55
haha
Wangxinyue
@Wangxinyue2018
Aug 13 2018 01:21
excuse me,what is the mean of "wordBlanks("dog", "big", "ran", "quickly") 应该包含所有传入的单词并且单词之间要有间隔(可以添加任意修饰的单词)."
excuse me,what is the mean of "wordBlanks("dog", "big", "ran", "quickly") 应该包含所有传入的单词并且单词之间要有间隔(可以添加任意修饰的单词)."
excuse me,what is the mean of "wordBlanks("dog", "big", "ran", "quickly") 应该包含所有传入的单词并且单词之间要有间隔(可以添加任意修饰的单词)."
Henry
@GitHub-Henry
Aug 13 2018 06:03
@Wangxinyue2018 中国人在这帮忙
Fikry82
@Fikry82
Aug 13 2018 13:57

var a = parseInt("11", 2);

The radix variable says that "11" is in the binary system, or base 2. This example converts the string "11" to an integer 3.

i don't understand what radix mean ??
basically the number base
Moisés Man
@moigithub
Aug 13 2018 14:09
@Fikry82 there are different numeral system, binary, octal, hexadecimal, decimal
each of those have different "set of numbers" to represent a value
ie. decimal use base 10 ( 10 digits 0,1,2,3,4,5,6,7,8,9 )
u can google to check whats the base of the other :)
Fikry82
@Fikry82
Aug 13 2018 14:30
okay i will thx
Jason Luboff
@JLuboff
Aug 13 2018 15:06
Morning :wave:
Mrsmao
@whb123
Aug 13 2018 15:08
function lookUp(firstName, prop){
// 请把你的代码写在这条注释以下
for (i=0;i<contacts.length;i++){
/document.write(contacts[i].firstName+' '+i+' '+'<br/>');/
var a = contacts[i].firstName;
if (a == firstName) {
document.write(a + '<br/>');
}else{
return 'no such contacts';
}
}
document.write(contacts[1].prop+'<br/>');
// 请把你的代码写在这条注释以上
}
// 你可以修改这一行来测试你的代码
lookUp("Harry", "likes");
help
freecode.html:1 Error in event handler for (unknown): TypeError: Cannot read property 'join' of undefined
is anyone here?
Jason Luboff
@JLuboff
Aug 13 2018 15:09
You shouldn't be using document.write, you should only be returning. In addition, make sure your strings match exactly what FCC has
Christopher McCormack
@cmccormack
Aug 13 2018 15:09
image.png
@JLuboff :wave: :wave:
Jason Luboff
@JLuboff
Aug 13 2018 15:10
@cmccormack What up
Christopher McCormack
@cmccormack
Aug 13 2018 15:10
workin
worked all weekend though, so hoping for a relaxed week :)
you?
Jason Luboff
@JLuboff
Aug 13 2018 15:11
Just got in. So...workin' I guess haha
Christopher McCormack
@cmccormack
Aug 13 2018 15:13
@JLuboff I know you don't have a lot of time but https://www.interviewbit.com has been pretty interesting
Facebook recommends it for interviewees so can't be too bad I imagine
I ran through some this weekend and it's pretty good
Jason Luboff
@JLuboff
Aug 13 2018 15:14
Just a quick peak, does look interesting. Looks like it has some core programming information?
Mrsmao
@whb123
Aug 13 2018 15:14
@JLuboff but if i write '!=' its okye
Jason Luboff
@JLuboff
Aug 13 2018 15:15
@whb123 Whats okay? If its okay, then it would pass.
Mrsmao
@whb123
Aug 13 2018 15:17
Code can run
Tiago Correia
@tiagocorreiaalmeida
Aug 13 2018 15:17
@cmccormack does it support javascri+pt?
Jason Luboff
@JLuboff
Aug 13 2018 15:17
@whb123 It can run all it wants, but if it's not passing than its not correct. What I mentioned before still holds true
Mrsmao
@whb123
Aug 13 2018 15:17
If i use "= =", will prompt the mistake.
@JLuboff
Jason Luboff
@JLuboff
Aug 13 2018 15:18
You need to fix the issues I mentioned before first, then continue form there
Christopher McCormack
@cmccormack
Aug 13 2018 15:19
@tiagocorreiaalmeida I've only done one exercise so far but it did I believe. I was using Python
seems to have a lot of languages
Jason Luboff
@JLuboff
Aug 13 2018 15:19
@tiagocorreiaalmeida What up
Christopher McCormack
@cmccormack
Aug 13 2018 15:19
it's not quite like codewars or whatever, a lot more instruction
And some of the videos have been really good refreshers
Mrsmao
@whb123
Aug 13 2018 15:22
I have something to do. I'll discuss it later. Thank you. @JLuboff
Christopher McCormack
@cmccormack
Aug 13 2018 15:23
Busy guy
Jason Luboff
@JLuboff
Aug 13 2018 15:25
@cmccormack Aren't we all
Christopher McCormack
@cmccormack
Aug 13 2018 15:26
no?
some people here are on summer break, makes me a bit jealous
Jason Luboff
@JLuboff
Aug 13 2018 15:27
haha.. fair enough
Christopher McCormack
@cmccormack
Aug 13 2018 15:28
psshht not fair
although work gives me lots of vacation time so I'm not sure why I'm complaining, just need to find time to use it :)
Jason Luboff
@JLuboff
Aug 13 2018 15:30
I'll finally be eligable for 3 weeks starting next year
Christopher McCormack
@cmccormack
Aug 13 2018 15:30
nice man
you should ask for four!
all the dev work you've been doing you earned it
Jason Luboff
@JLuboff
Aug 13 2018 15:31
Eh they do it on a how many years you've been here basic
And... at this point.. 3 will be the most I'll ever be to get...they used to give you 4 at 10 year mark, but got rid of that
Christopher McCormack
@cmccormack
Aug 13 2018 15:32
I don't get why you would not reward that kind of loyalty
Jason Luboff
@JLuboff
Aug 13 2018 15:33
Couldn't tell you why they did that besides money saving
Christopher McCormack
@cmccormack
Aug 13 2018 15:34
I guess
Jason Luboff
@JLuboff
Aug 13 2018 15:36
:shrug: (there's no shrug emoji)
Amit Patel
@AmitP88
Aug 13 2018 15:37
hey guys, in React, how can I pick a random state property? I'm working on a tic tac toe game in React, and so far I've gotten to the point where the user can click on any cell to fill it, but now I'm trying to make it to where if a user clicks on an empty cell, the computer will pick a random empty cell to fill
pick_a_random_cell.png
Christopher McCormack
@cmccormack
Aug 13 2018 15:38
@AmitP88 not a react question - you have to know which cells are empty, and use something like board[Math.floor(Math.random() * 9)] and check if there is already a value there or not
you should use an array not individual states for each cell
that's just going to add a whole lot of unnecessary code on top for no good reason
Amit Patel
@AmitP88
Aug 13 2018 15:40
@cmccormack hmmm, so I should setup my state like this?
this.state = ["cell1" = '', "cell2" = '', etc];
I also knew about how to pick a random number on it's own, but I was confused on the state part
Christopher McCormack
@cmccormack
Aug 13 2018 15:41
no just an array of length 9
you don't need the text at all
you can initialize with undefined or 0 or whatever as long as it's falsey
Amit Patel
@AmitP88
Aug 13 2018 15:41
but then later on, how would I be able to check for matching rows?
sorry, I'm confused
Christopher McCormack
@cmccormack
Aug 13 2018 15:42
@AmitP88 just check possible winning values against what you have in your state
you can check if cell 0, 3, and 6 all contain truthy values and all three values are the same - that value would be the winner. Same with any other possible winning combination
Amit Patel
@AmitP88
Aug 13 2018 15:43
ah ok
so first, my state would look like this.state = [0,0,0,0,0,0,0,0,0]; ? just want to make sure I understand this right
Christopher McCormack
@cmccormack
Aug 13 2018 15:45
probably want to fill it in
yeah
like that, like your edit ;)
Amit Patel
@AmitP88
Aug 13 2018 15:45
lol I just read what you had above
Christopher McCormack
@cmccormack
Aug 13 2018 15:45
The rest of it you should consider and work out, this should be plenty of head start
Amit Patel
@AmitP88
Aug 13 2018 15:46
ok, this kind of makes sense
thanks! :)
hensn5250
@hensn5250
Aug 13 2018 15:48
@cmccormack is there a benefit in using React over Html with what @AmitP88 is trying to do?
Amit Patel
@AmitP88
Aug 13 2018 15:48
@hensn5250 I'm just trying to get more React practice :)
I want to get good at it so I have to start somewhere. I've already done the Front End Libraries Certification on FCC
hensn5250
@hensn5250
Aug 13 2018 15:50
ok, I'm curious on the advantage of using React over traditional Html,CSS,JS
I only know very little about react thats why I asked
Amit Patel
@AmitP88
Aug 13 2018 15:53

@cmccormack I get this warning when trying to use this.state as an array like above

index.js:2178 Warning: GameBoard.state: must be set to an object or null

Christopher McCormack
@cmccormack
Aug 13 2018 15:53
@hensn5250 React is very fast to change the state of the DOM, probably more efficient than we would be just using built in JS methods or jQuery
@AmitP88 this.state should never be an array
@AmitP88 make a state property called board or something
assign the array to that
Amit Patel
@AmitP88
Aug 13 2018 15:54
oh ok
I should've known lol
Christopher McCormack
@cmccormack
Aug 13 2018 15:55
@hensn5250 it's also a pleasure to work with, as the way state works forces you to rethink the structure of your app, which can lead to a lot better code IMO
going back and writing vanilla JS makes me feel like I"m in the wild west and I can break anything now
hensn5250
@hensn5250
Aug 13 2018 15:58
I see. I have been meaning to learn it so that I can implement it in some older projects where I need to append class-like elements to the page. Doing via traditional Html and JS can be very costly.
Amit Patel
@AmitP88
Aug 13 2018 15:59
I feel like I'm using React the wrong way in this by attempting to use setState on a property array
Christopher McCormack
@cmccormack
Aug 13 2018 15:59
@AmitP88 make sure you don't try to change an array in place; instead, clone it with the updates
React won't update a state entry if the state reference is the same unless you use a special lifecycle method
Amit Patel
@AmitP88
Aug 13 2018 16:01
are you sure I can't do it with my original state? the this.state = {cell1: '', etc}
I feel like this is getting over my head quickly
Christopher McCormack
@cmccormack
Aug 13 2018 16:02
@AmitP88 you can but I really suggest you do not
Amit Patel
@AmitP88
Aug 13 2018 16:02
is it really that hard to select a random javascript object property though?
Christopher McCormack
@cmccormack
Aug 13 2018 16:03
?
Amit Patel
@AmitP88
Aug 13 2018 16:03
since state is technically an object
Tiago Correia
@tiagocorreiaalmeida
Aug 13 2018 16:03
@cmccormack guess I was lost on the website ahaha ended up closing it
Christopher McCormack
@cmccormack
Aug 13 2018 16:06
@tiagocorreiaalmeida like it?
@AmitP88 you can do it the hard way if you like not sure why
Amit Patel
@AmitP88
Aug 13 2018 16:06
@cmccormack I dunno, using state as an array seems like the hard way to me lol
Christopher McCormack
@cmccormack
Aug 13 2018 16:07
you dont use state as an array
you add an array to state
Amit Patel
@AmitP88
Aug 13 2018 16:07
sorry, that's what I meant
Christopher McCormack
@cmccormack
Aug 13 2018 16:07
state = { board: [0,0,0...] }
Amit Patel
@AmitP88
Aug 13 2018 16:08
so for setState, if I wanted to update the index[0], what would it look like? that's the part i'm kind of struggling on
Christopher McCormack
@cmccormack
Aug 13 2018 16:08
then to update
this.setState({ board: clonedBoardWithUpdate })
to clone an array is as simple as
newBoard = [...board]
Amit Patel
@AmitP88
Aug 13 2018 16:09
oh shoot, I should've remembered this from the algorithms
Tiago Correia
@tiagocorreiaalmeida
Aug 13 2018 16:09
@JLuboff all good almost summer holidays how about you?
Jason Luboff
@JLuboff
Aug 13 2018 16:10
@tiagocorreiaalmeida Its going. Another start of the week
Tiago Correia
@tiagocorreiaalmeida
Aug 13 2018 16:10
@cmccormack I Prefer codefights
but will give a new look to it once again later on
Amit Patel
@AmitP88
Aug 13 2018 16:10

so to update the first array item, it would be

newBoard = [PLAYER, ...board]

?

Tiago Correia
@tiagocorreiaalmeida
Aug 13 2018 16:11
@JLuboff so have you finished the application you have been working?
Jason Luboff
@JLuboff
Aug 13 2018 16:11
@tiagocorreiaalmeida It went into production last Monday! But I'm still making some changes to it, mainly enabling the ability to upload multiple files as opposed to a single file
Christopher McCormack
@cmccormack
Aug 13 2018 16:14
@AmitP88 no that would be 10 elements instead of 9
@AmitP88 clone, then update, then setState
Amit Patel
@AmitP88
Aug 13 2018 16:22
@cmccormack how do I update the cloned array?
hensn5250
@hensn5250
Aug 13 2018 16:22
@AmitP88 Maybe you should build the application in traditional HTML CSS and JS first
Christopher McCormack
@cmccormack
Aug 13 2018 16:22
@AmitP88 how do you modify any array?
hensn5250
@hensn5250
Aug 13 2018 16:22
that way you have the structure and behavior of the app and you can implement it in React easier since you have a final product
Christopher McCormack
@cmccormack
Aug 13 2018 16:22
as long as it's a new array, React will update when you setState
Amit Patel
@AmitP88
Aug 13 2018 16:23
@cmccormack use array methods like slice, splice, push, shift, etc
Tiago Correia
@tiagocorreiaalmeida
Aug 13 2018 16:23
are you using multer @JLuboff ?
Jason Luboff
@JLuboff
Aug 13 2018 16:23
@tiagocorreiaalmeida Yup
Changed from single to multi
I have the backend all done for it
Amit Patel
@AmitP88
Aug 13 2018 16:23
@hensn5250 hmmm, maybe. I was hoping I could just figure it out in React, but you may be right
Jason Luboff
@JLuboff
Aug 13 2018 16:23
Just been working on the front end
Christopher McCormack
@cmccormack
Aug 13 2018 16:24
@AmitP88 yeah
hensn5250
@hensn5250
Aug 13 2018 16:24
@AmitP88 hoping === freestyle coding , which is bound to lead to frustration and wasted time
Christopher McCormack
@cmccormack
Aug 13 2018 16:25
@AmitP88 or just board[4] = 'X' or whatever
hensn5250
@hensn5250
Aug 13 2018 16:25
and bugs
Amit Patel
@AmitP88
Aug 13 2018 16:26
@cmccormack I see
ugh, I can't think today
@hensn5250 I may have to take your suggestion and start over using plain js
hensn5250
@hensn5250
Aug 13 2018 16:26
@AmitP88 did you make a TicTacToe app already?
Amit Patel
@AmitP88
Aug 13 2018 16:27
@hensn5250 nope, first time
hensn5250
@hensn5250
Aug 13 2018 16:27
@AmitP88 will then you kinda have 2 things going against you there
Amit Patel
@AmitP88
Aug 13 2018 16:27
I briefly looked at the one on the React tutorial site, but that one is functionally different to how I'm making mine
true
I just really want to get good at React though
hensn5250
@hensn5250
Aug 13 2018 16:28
I would suggest coming up with your pseudo-code first
Amit Patel
@AmitP88
Aug 13 2018 16:29
yeah, I was doing that at first actually, just to see the component hierarchy
and how to pass down the parent state down to the child component as props
hensn5250
@hensn5250
Aug 13 2018 16:29
I don't know React at all but you should start small so you dont get frustrasted
Amit Patel
@AmitP88
Aug 13 2018 16:30
lol I thought I was starting small by trying to build a simple tic tac toe
but I get your point
hensn5250
@hensn5250
Aug 13 2018 16:31
well tictactoe can get complicated
if it has AI
I just completed a few variations of the TTT game and it took forever to get the AI working right
Amit Patel
@AmitP88
Aug 13 2018 16:33
hmmm, well I suppose it sort of has an AI, even if it was just about selecting something randomly if it's empty
I think that's the hardest part actually, since declaring a winner should be easy to do in code
hensn5250
@hensn5250
Aug 13 2018 16:34
oh ok
Amit Patel
@AmitP88
Aug 13 2018 16:34
it's just these last two steps really
but this one that i'm on about the computer selecting a random cell is frustrating
hensn5250
@hensn5250
Aug 13 2018 16:35
I thought you were at the very beginning stages due to the questions you were asking @cmccormack
Amit Patel
@AmitP88
Aug 13 2018 16:35
when it comes to working with React's state object
oh I see
nah, I'm towards the end
been working on this for the past few days actually
been making progress here and there
hensn5250
@hensn5250
Aug 13 2018 16:37
i see
Amit Patel
@AmitP88
Aug 13 2018 16:43
I'm going to take a break and let my mind cool off lol
Brad
@bradtaniguchi
Aug 13 2018 17:16
mmm steamy code :P
Ozarion
@Ozarion
Aug 13 2018 17:23
Hi everyone :)
Christopher McCormack
@cmccormack
Aug 13 2018 17:24
@Ozarion heya
Ozarion
@Ozarion
Aug 13 2018 17:24
@cmccormack How are you today? :)
Christopher McCormack
@cmccormack
Aug 13 2018 17:24
busy busy but that's a good thing
you?
Ozarion
@Ozarion
Aug 13 2018 17:24
yeah. Good thing.
Jason Luboff
@JLuboff
Aug 13 2018 17:25
Hola
Ozarion
@Ozarion
Aug 13 2018 17:25
Right now. Going through fcc challenges
@JLuboff Hey!
Whazzup @JLuboff :)
Jason Luboff
@JLuboff
Aug 13 2018 17:25
Working hard, you?
Ozarion
@Ozarion
Aug 13 2018 17:26
Yeah. I'm working hard too. If going through FCC Challenges counts. XD
BTW have you guys finished FCC Completely?
Jason Luboff
@JLuboff
Aug 13 2018 17:27
I'd say that counts
I've earned several of the certs, but no, not completed
Have the Front and Back end "Legacy" certs
Along with the algo and API certs
Brad
@bradtaniguchi
Aug 13 2018 17:28
man I haven't event completed the front-end cert XD got lazy around some of the more interesting projects
Ozarion
@Ozarion
Aug 13 2018 17:28
That totals up to 75% + FCC
I skipped over the visualizations cert.
Jason Luboff
@JLuboff
Aug 13 2018 17:29
I'm only in programming becuase of FCC, so figured I should finish some of them hah
Christopher McCormack
@cmccormack
Aug 13 2018 17:30
Visualizations was the most fun!
Ozarion
@Ozarion
Aug 13 2018 17:31
How long have you been programming @JLuboff . Before FCC I programmed 1 year in .Net but Javascript in web dev a whole diffrent beast.
@cmccormack interesting. Because I found it boring somehow. LOL.
Jason Luboff
@JLuboff
Aug 13 2018 17:31
@Ozarion I started FCC in May 2016 I believe. I am now doing programming for work as of this year /end of last year
Christopher McCormack
@cmccormack
Aug 13 2018 17:32
@Ozarion but you skipped it
Ozarion
@Ozarion
Aug 13 2018 17:32
@JLuboff cool!
Christopher McCormack
@cmccormack
Aug 13 2018 17:32
WHICH IS IT?!?!
Ozarion
@Ozarion
Aug 13 2018 17:32
@cmccormack I skipped the projects. Did the challenges actually.
Christopher McCormack
@cmccormack
Aug 13 2018 17:33
oh the challenges are alright but the projects are where you really see D3 shine
Ozarion
@Ozarion
Aug 13 2018 17:34
really? If that's the case I'll do it right after I complete API challenges. Which I am doing right now.
Christopher McCormack
@cmccormack
Aug 13 2018 17:34
you should!
no better feeling than finally seeing your data presented, sometimes even properly!
Ozarion
@Ozarion
Aug 13 2018 17:35
Hahah. Yeah. Sometimes.
Jason Luboff
@JLuboff
Aug 13 2018 17:35

Neat. Just found this ES6 feature. Normally to assign a key/value to an object, in which we use a variable as the key we do

let key = "potato";
let obj = {};
obj[key] = 3;

With ES6 its

let key = "potato";
let obj = { [key] : 3 };
Ozarion
@Ozarion
Aug 13 2018 17:36
pretty neat.
Christopher McCormack
@cmccormack
Aug 13 2018 17:36
@JLuboff that's really awesome when working with events or something where you can target an attribute and use it as a key
I found it by accident on one of my projects, just wondered if it worked, and it did!
Jason Luboff
@JLuboff
Aug 13 2018 17:36
@cmccormack Yup, basically what I'm doing
Ozarion
@Ozarion
Aug 13 2018 17:37
I think it's using js symbols. Right? that [<Expression>] evaluates to "potato"
I read this in Eloquent Javascript book.
Christopher McCormack
@cmccormack
Aug 13 2018 17:39
I thought Symbols were something else
Ozarion
@Ozarion
Aug 13 2018 17:39
btw I want to auto number the "short_url" field. How do I define it's schema?
const urlSchema = new Schema({
  original_url : String,
  short_url : Number
});
@cmccormack You may be right. I just made a wild guess.
This is symbol usage:
let sym = Symbol("name");
Rabbit.prototype[sym] = 55;
console.log(blackRabbit[sym]);
// → 55
Christopher McCormack
@cmccormack
Aug 13 2018 17:43
so what is it haha
guess I can look it up
The data type "symbol" is a primitive data type having the quality that, values of this type can be used to make object properties that are anonymous. This data type is used as the key for an object property when the property is intended to be private, for the internal use of a class or an object type.
neat
Ozarion
@Ozarion
Aug 13 2018 17:50
I am dumb af So, is it js symbols or something else being implemented?
Christopher McCormack
@cmccormack
Aug 13 2018 17:54
I think it may be Enhanced Object Literals
I didn't even know about that site, I guess I've never searched for es6 before haha
Ozarion
@Ozarion
Aug 13 2018 17:55
@cmccormack Okay. I'll read about it now. XD
I too only know about MDN
Jason Luboff
@JLuboff
Aug 13 2018 17:56
@cmccormack I have that page bookmarked..looked at it once or twice
Christopher McCormack
@cmccormack
Aug 13 2018 17:56
Now I kind of feel dumb for not trying the ES5 way of handling those haha
@JLuboff Make an extension that randomly opens one of es6 features when you open a new tab
Ozarion
@Ozarion
Aug 13 2018 17:57
You know it's depressing that, We are sharpening our JS day in and out like a Samurai sharpens it's Katana. And, They say WebAssembly is gonna kill it...
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 17:57

Hey guys I'm trying to create an array of prime numbers and it seems to be working fine except 9 is being returned.

var arr = [2, 3, 4, 5, 6, 7, 8, 9, 10];

arr.filter((value, index, array) => {
  for (let i = 2; i < array.length; i++) {
    if (value % i === 0 && value !== i) {
      return '';
    }
    else {
      return value;
    }
  }
})

Does anyone see why?

Christopher McCormack
@cmccormack
Aug 13 2018 17:58
@Ozarion sharpening JS also means sharpening general problem solving and language skills which should be transferable
Ozarion
@Ozarion
Aug 13 2018 17:59
totally agree. you can't take that away.
"You can break my tools but you can't break my craft" XD
Christopher McCormack
@cmccormack
Aug 13 2018 18:00
@ArchivalBoat50 you're returning too soon
Jason Luboff
@JLuboff
Aug 13 2018 18:00
@ArchivalBoat50 I'm not positive, but.. it doesn't like like the inner loop is needed here, as it never iterates past 2 (I placed a console.log inside the loop, and see that i stays 2)
Returning too soon sounds about right
Ozarion
@Ozarion
Aug 13 2018 18:01
@ArchivalBoat50 Either don't use the filter and do it your for loop way or remove the inner loop and use the index provided by filter method
Chris
@crokita
Aug 13 2018 18:03
the function passed to filter should return a boolean: true if you want to keep the element and false if you don't want to keep the element. it may be working for you in this case because '' coerces to false and value coerces to true (only if the value is not 0 !). I recommend changing it to booleans to make it more clear what's being filtered
Ozarion
@Ozarion
Aug 13 2018 18:06
@ArchivalBoat50 you can use your inner condition with filter this way:
filter(value, index //passing array is not needed) => (!(value % index === 0 && value !== index))
Chris
@crokita
Aug 13 2018 18:07
May I suggest an easier way to write a prime number generating function?
Start out with an empty array that contains all your prime numbers. Then, make an iterator starting from 2 and goes up to whatever maximum number you want to check. For every said number, check if it is divisible by any of the numbers in that prime number array. If it's not, then you can add it to the array as a new prime number. repeat until you hit your maximum value
(lol so much advice)
JJ Megma
@megma_jj_twitter
Aug 13 2018 18:11
@crokita Are you saying to manually fill an array with a bunch of prime numbers? then loop through that?
Or did I read that wrong?
Chris
@crokita
Aug 13 2018 18:12
nope. I'll try and explain it with an example. I'll need a moment
JJ Megma
@megma_jj_twitter
Aug 13 2018 18:14
I'm sure you mean something like this?
let primes = []
for(let i = 2; i<someNum; i++){
 if(isPrime(i)){
  primes.push(i)
}
}
Chris
@crokita
Aug 13 2018 18:14
so, you start with no knowledge of prime numbers: []. You check 2 to start with. Is 2 divisible by any number in the array? well, it's empty, so no. Add it to the array: [2]. Go to 3. 3 isn't divisible by 2, so add it: [2,3]. go to 4 now. 4 isn't divisible by 3 but it is divisible by 2. Don't add it. Go to 5, etc.
so in your snippet what isPrimedoes is check the primes array against the current i value
but yeah something like that
JJ Megma
@megma_jj_twitter
Aug 13 2018 18:16
Im not the one that asked you about this, I am just chiming in
:)
Chris
@crokita
Aug 13 2018 18:17
mhmm
JJ Megma
@megma_jj_twitter
Aug 13 2018 18:17
mhmm
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 18:18
I was originally trying to just filter out all the non prime numbers from an array. But now I realize theres another way to do the algorithm challenge with prime number generating
Chris
@crokita
Aug 13 2018 18:24
do whatever makes the most sense for you! you can worry about making it good later
Ozarion
@Ozarion
Aug 13 2018 18:34
In Mongoose/Mongodb, I can't find a way to add a simple auto incremented number field. How is it supposed to work?
Jason Luboff
@JLuboff
Aug 13 2018 18:35
@Ozarion You have to implement it with $inc
I don't think there is an indentity like in SQL
Ya, looks like you can create a squence..but I would probably just do $inc
or if you're not updating a document, then just find the last document and manually increment that result by one for your new doc
Ozarion
@Ozarion
Aug 13 2018 18:38
So I've to find the last document and whatever the "counter" value it had, I'll increment it by 1 and assign it to the new document?
Jason Luboff
@JLuboff
Aug 13 2018 18:39
Ya
If this is for the shorten url project... at the time (man that was a long time ago) I just created a random 4 digit number and then checked ym db if that existed, if not I used it, otherwise, I regenerated
Ozarion
@Ozarion
Aug 13 2018 18:40
@JLuboff Thanks. Yeah that seems like a nice hack. ;)
@JLuboff Did you check for valid url via regex or used dns.lookup if you could remember?
Jason Luboff
@JLuboff
Aug 13 2018 18:43
Somehow I came up with this app.get(/\/?(http:\/\/|https:\/\/)(.*)/, to determine that they atleast put in a valid http:\\ or https:\\ beginning.. but otherwise, no didn't check if the url itself is actually valid
(and by "I came up with this" I mean someone either helped me or I found it via google lol)
Christopher McCormack
@cmccormack
Aug 13 2018 18:43
I made a hashy thing for the url shortener if you want to use it https://github.com/cmccormack/url-shortener-service/blob/master/app/base54.js
Ozarion
@Ozarion
Aug 13 2018 18:46
@cmccormack Yeah. I too used a similiar regex to check and Didn't bother with dns lookup for now.
@cmccormack It's neat. Will it always generate unique short url?
Christopher McCormack
@cmccormack
Aug 13 2018 18:47
I think you meant @JLuboff
@Ozarion it's a large bucket but you can still check like @JLuboff suggested
Ozarion
@Ozarion
Aug 13 2018 18:49
@cmccormack Yes I'm using a similiar solution to what @JLuboff suggested right now. I'm just curios about the one you provided, For a given url, does it generate a unique short_url?
Jason Luboff
@JLuboff
Aug 13 2018 18:49
His method would be mostly unique, but I think could still generate in a very rare circumstance, a duplicate
Ozarion
@Ozarion
Aug 13 2018 18:50
I see...
Christopher McCormack
@cmccormack
Aug 13 2018 18:50
@Ozarion it's not guaranteed unique but it should have a large enough domain that collisions are very rare
Ozarion
@Ozarion
Aug 13 2018 18:50
Cool!
Jason Luboff
@JLuboff
Aug 13 2018 18:50
If you wanted to make it even less likely for a duplicate..you can feed a random number each time
(not sure if @cmccormack is doing that or is a fixed number but I see it takes a number as input)
Ozarion
@Ozarion
Aug 13 2018 18:53
seeding with random will surely make this pretty robust. But I think I'll just go with the simple approach for this Fcc challenge. When I'm making a full blown url shortner, I'll definately look forward to using this.
Brad
@bradtaniguchi
Aug 13 2018 18:53
man spent the entire morning working on some tough logic :(
Christopher McCormack
@cmccormack
Aug 13 2018 18:53
mine doesn't require a lookup
it's reversible
Ozarion
@Ozarion
Aug 13 2018 18:55
Yeah. encode and decode functions, both provided. It's pretty awesome.
@bradtaniguchi Nice mental workout I say.
Brad
@bradtaniguchi
Aug 13 2018 18:57
I walked away, someone else more zealous is working on it now, I just passed him the test-cases we need to run against
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 18:58

@crokita How would I get the code to work like how it first starts for the generator:

What I mean is, when the array is empty, what can I do to push the first prime number i.e 2 to the array since the array is empty

Christopher McCormack
@cmccormack
Aug 13 2018 19:02
@ArchivalBoat50 push
Chris
@crokita
Aug 13 2018 19:03
so you need one loop to start from 2 to go up to whatever. then you need another loop for all the elements in the array to check for divisibility. You basically need to store some boolean for if the number is prime, starting at true, then if you find it's divisible by something then change it to false
once you figure out that prime check you could actually use that for your original idea and it should work the same way
either way, you want to check if a number is divisible from an array of numbers (not including the number itself or 1)
try and make that part work first
Christopher McCormack
@cmccormack
Aug 13 2018 19:09
You can also stop checking when you get the the square root of each value you are checking
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:11
@crokita So what I'm trying to do is generate an array of prime numbers until it reaches the limit. and I don't know how to start it off with the empty array part.
I'm trying to do something like this:
Christopher McCormack
@cmccormack
Aug 13 2018 19:13
@ArchivalBoat50 you should probably have a few base cases where you check if the value is <= 1 or value is === 2. If greater than or equal to 2, then the array should not be empty as the array should at least have 2 in it
oops just realized you're filtering an array, you can ignore above for this context
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:16
var array = [];

if (array is empty) {
  for (i=2; i<limit; i++) {
    if (i is a prime number) {
      array.push(i);
    }
  }
}
Thats basically what im picturing for my prime number generator
Christopher McCormack
@cmccormack
Aug 13 2018 19:16
why would you check if the array is empty?
Chris
@crokita
Aug 13 2018 19:17
oh. do you know how to make a loop that lets you go through all the elements in an array?
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:18
Oh oops, I don't know what i was thinking there with the array is empty part
@crokita for (let i=0; i<arr.length; i++) ?
Christopher McCormack
@cmccormack
Aug 13 2018 19:19
there really isn't a reason you need to push anything to an array
if you're just checking if it's prime or not, you should keep looping until either you exit the for loop and return true, or return false if it is not prime within the loop
Chris
@crokita
Aug 13 2018 19:22
@ArchivalBoat50 yeah. maybe I should have guided you to how you were trying to do it originally.
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:24

This is the function im picturing
primeNumberGenerator(10)

// returns [2,3,5,7]

Christopher McCormack
@cmccormack
Aug 13 2018 19:25
ah
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:25
lol
Christopher McCormack
@cmccormack
Aug 13 2018 19:25
then what I stated above will apply @ArchivalBoat50 :point_up: August 13, 2018 12:13 PM
That's how I normally see this problem done :)
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:26
lol there was a lot of miscommunication
Christopher McCormack
@cmccormack
Aug 13 2018 19:27
Run with it and see where you get
Chris
@crokita
Aug 13 2018 19:30
whichever way you do it is fine. just pick a way and we'll help out if you get stuck
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:44

@crokita @cmccormack Ok so here is where I'm stuck at.

function primeNumberGen(limit) {
  var arr = [];
  for (let i=2; i<limit; i++) {
    if (value % i || value !== i) { //Currently stuck at this line right here
      arr.push("");
    }
    else {
      arr.push(i);
    } 
  }
}

At the line I'm stuck at I don't know how I can do the math/comparision operations with i if the array is empty in the first place. I don't know what to declare value as.

I didn't know how to apply what you stated above to this lol
Maybe I could say if limit is greater than two than value = something?
Christopher McCormack
@cmccormack
Aug 13 2018 19:45
is that all of your code?
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:45
yes
Christopher McCormack
@cmccormack
Aug 13 2018 19:45
you'll need two loops, one to iterate over each (odd) value from 2 to limit, and one to determine if that value is prime
JJ Megma
@megma_jj_twitter
Aug 13 2018 19:46
Is that an Freecodecamp challenge?
Chris
@crokita
Aug 13 2018 19:46
@ArchivalBoat50 yeah, you'll need to use another loop to iterate over the arr value inside the first loop.
inside the second loop you can assume that values in arr exist because that inner loop code will only run if there are elements that exist (assuming the loop is setup correctly)
Christopher McCormack
@cmccormack
Aug 13 2018 19:47
a tip is that if a number is greater than 2, then the array can be initiated as [2]
2 is the only even prime
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:47
@megma_jj_twitter I'm using this as part of the code for the freecodecamp challenge. It's the sum all primes algorithm.
Christopher McCormack
@cmccormack
Aug 13 2018 19:47
so if you remove 2 from your loops, you no longer have to check if it's an even or odd value, just start at 3 and increment by 2 instead so it's always odd
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:53
@cmccormack How do you iterate through each odd value if you start from 2 using a loop?
JJ Megma
@megma_jj_twitter
Aug 13 2018 19:54
const isPrime = n => {//some code checking if n is prime return true/false}
function sumPrimes(limit){
const sum = 0
 for(loop start at 0 and ending at limit){
  if(isPrime(iterator)){
 sum += iterator 
}
}
return sum
}
Thats how I would probably do it, break it up.
Christopher McCormack
@cmccormack
Aug 13 2018 19:55

@ArchivalBoat50

for (let i=2; i<limit; i++) {

This can be modified so i increments by more than just one, and you can assign a different value to iin the declaration

ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:57
@cmccormack But since i start at 2 saying i+= 2 or something like that will make it miss those odd values. Am I suppose to start i somewhere else? Like 1?
Christopher McCormack
@cmccormack
Aug 13 2018 19:57
@ArchivalBoat50 :point_up: August 13, 2018 12:47 PM
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 19:58
Oh
Christopher McCormack
@cmccormack
Aug 13 2018 19:58
:D
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:00
@megma_jj_twitter Thats how I was originally doing it but then I decided to switch ways lol
@cmccormack How do you set up the second loop where you check if it's a prime number or not?
Oh wait
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:05
nvm i'm still stuck there lol
Christopher McCormack
@cmccormack
Aug 13 2018 20:06
Personally I would make a separate function for checking each value so you can return early
but if you just want an inner loop you can use break to exit the outer loop early if it is not prime
Chris
@crokita
Aug 13 2018 20:06
yeah, I'd make a separate function that just tests if a single number is prime
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:08
oops my question didn't make sense. ignore it lol. i figured that one out
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:15

@cmccormack @crokita Ok

function primeNumberGen(limit) {
  var arr = [2];
  for (let i=3; i<limit; i+2) {
    for (j=0; j<arr.length; j++) {
      if () {}
    }
  }
}

I'm stuck at the part where you have to check if the value is prime or not

Moisés Man
@moigithub
Aug 13 2018 20:16
i+2 wont increment i
u need to reassign it
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:17
oops
Chris
@crokita
Aug 13 2018 20:17
okay, if you're using arr as your source of truth for prime numbers, then i is the value you want to check is prime, and j is the value you want to use to check i's divisibility
remember how to check if i is divisible by j?
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:21
Check i's divisibility?
Chris
@crokita
Aug 13 2018 20:22
yeah. To check if i is prime you need to make sure the value stored in i is not divisible by any element in arr.
for example, if arr had [2,3,5,7] and you're checking 9, then you check if 9 is divisible by 2, 3, 5, 7. if it is not divisible by any of them then you have a prime number
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:24
Hey it's that old 9 error i was having trouble with lol
Christopher McCormack
@cmccormack
Aug 13 2018 20:25
your error was that you returned at 2 everytime I believe :)
and all the odd numbers > 1 and < 9 are prime
Jason Luboff
@JLuboff
Aug 13 2018 20:28
I want to use padStart, however, still need to support IE11 which padStart is not supported in. On MDN, they show the polyfill script. Would I just include that at the top of my script and then it would be available to use anywhere in my script? Never used a polyfill script so not positive
Christopher McCormack
@cmccormack
Aug 13 2018 20:28
@JLuboff yeah pretty much
padStart is a method so polyfill is a good way to do it
if you had to use something like template literals you would need to transpile I think
Jason Luboff
@JLuboff
Aug 13 2018 20:29
:thumbsup:
Ya not worrying about template literals (albeit would be nice..doin't want to deal with transpiling)
Christopher McCormack
@cmccormack
Aug 13 2018 20:30
oh wasn't suggesting you should, just pointing that out as something you probably can't do with a polyfill
(probably)
Jason Luboff
@JLuboff
Aug 13 2018 20:31
Ya I know..I was more speaking aloud
Christopher McCormack
@cmccormack
Aug 13 2018 20:31
ME TOO
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:31
This is what I have now, my function is returning undefined
function primeNumberGen(limit) {
  var arr = [2];
  for (let i=3; i<limit; i+=2) {
    for (j=0; j<arr.length; j++) {
      if (i % arr[j] === 0 || i === arr[j]) {
        arr.push('');
      }
      else {
        arr.push(i);
      }
    }
  }
  return arr;
}
Moisés Man
@moigithub
Aug 13 2018 20:34
u pushing too soon
u need to check if NOT divisible by ALL arr values before pushing
Chris
@crokita
Aug 13 2018 20:34
that inner loop will run indefinitely. you always push a value to arr. it should only contain prime number values. dont push ''
Christopher McCormack
@cmccormack
Aug 13 2018 20:34
also why are you iterating over arr.length?
Jason Luboff
@JLuboff
Aug 13 2018 20:35
Wow. I just used a while loop. Think thats the first time I've used one in..a long long time..
Chris
@crokita
Aug 13 2018 20:35
he's using the method where a value is a prime number if it's not divisible from an array of already found primes
Christopher McCormack
@cmccormack
Aug 13 2018 20:35
@JLuboff they scare me
Brad
@bradtaniguchi
Aug 13 2018 20:35
@JLuboff I gotta ask.... why did you need it over the other like 10 alternatives :P
Christopher McCormack
@cmccormack
Aug 13 2018 20:35
I always put an upper limit and a counter in just in case
Chris
@crokita
Aug 13 2018 20:36
and is generating the primes as he goes
Jason Luboff
@JLuboff
Aug 13 2018 20:36

@bradtaniguchi First solution that came to mind..I need to loop over dynamically added DOM elements and add a number... so

while($('#actionFile' + index + 'ID').length > 0){
    index = index.substring(0, 2) + (Number(index.substring(2,4)) + 1).toString().padStart(2, '0');
  }

I'm sure there's another solution but its what came to mind lol

Christopher McCormack
@cmccormack
Aug 13 2018 20:37
Sieve of Eratosthenes?
hmm no that's not even close
Chris
@crokita
Aug 13 2018 20:39
instead of having a list of numbers and removing the composites it creates the primes from an empty array and builds it up
I dont remember what the name is for it
Christopher McCormack
@cmccormack
Aug 13 2018 20:43
should be breaking if the result of the modulus is 0, not pushing empty string and continuing
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:44
How do you make it so that arr doesn't push anything if the number is not prime?
Christopher McCormack
@cmccormack
Aug 13 2018 20:44
break
what is i === arr[j] doing?
Chris
@crokita
Aug 13 2018 20:47
you need to do something like this:
remember that i is prime by default
inner for loop {
    i is divisible by something? then remember that i is not prime
}
recall whether i is prime here. do something about it
ew maybe the code block wasn't the best idea lol
Christopher McCormack
@cmccormack
Aug 13 2018 20:48
can you do something like
```plain
?
> would work
Chris
@crokita
Aug 13 2018 20:48
oh. like that?
Christopher McCormack
@cmccormack
Aug 13 2018 20:49
nah I like your code block better
Chris
@crokita
Aug 13 2018 20:49
lmao
Christopher McCormack
@cmccormack
Aug 13 2018 20:49
maybe
```text
?
Chris
@crokita
Aug 13 2018 20:49
this is going downhill quickly
Christopher McCormack
@cmccormack
Aug 13 2018 20:50
for (let i = 0; i < 100; i+=1) {
    // ...
}
yeah text works fine
Chris
@crokita
Aug 13 2018 20:50
I see! thank you
Christopher McCormack
@cmccormack
Aug 13 2018 20:50
np
Chris
@crokita
Aug 13 2018 20:50
good to know
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 20:59
Shouldn't the function be this simple if i is prime by default?
function primeNumberGen(limit) {
  var arr = [2];
  for (let i=3; i<limit; i+=2) {
    arr.push(i);
  }
  return arr;
}
Christopher McCormack
@cmccormack
Aug 13 2018 20:59
why would you assume i is prime by default?
if limit was 12, would 9 be prime?
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 21:00
Oh wait my math was wrong lol
Christopher McCormack
@cmccormack
Aug 13 2018 21:00
little bit yeah :)
newmoon
@newmoon
Aug 13 2018 21:04
You may want to explore the Sieve of Eratosthenes for this. An efficient approach to finding all primes up to a given number.
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 21:36

I read the Sieve of Eratosthenes Algorithm and here is the psuedocode:

 Input: an integer n > 1.

 Let A be an array of Boolean values, indexed by integers 2 to n,
 initially all set to true.

 for i = 2, 3, 4, ..., not exceeding √n:
   if A[i] is true:
     for j = i2, i2+i, i2+2i, i2+3i, ..., not exceeding n:
       A[j] := false.

 Output: all i such that A[i] is true.

Where did the i cannot exceed √n part come from? What does it mean for it to not exceed the square root of the limit?

newmoon
@newmoon
Aug 13 2018 21:54
@ArchivalBoat50 It isn't necessary to check every multiple up to the limit - mathematically, we only need to check up to the square root of the limit. Much more efficient that way.
Christopher McCormack
@cmccormack
Aug 13 2018 22:02
@ArchivalBoat50 think of it this way, if you want to see which numbers multiply to equal a number (limit) you can start with a low number (low), then multiply low by limit/low to find the high number right?
The square root of thelimit will always represent the highest low value, as the square root can be multiplied by itself to equal high, and if you proceed higher than that then you are repeating yourself.
not a great explanation but it's how I think about it
ArchivalBoat50
@ArchivalBoat50
Aug 13 2018 22:31
I think i still dont understand
Pagnito
@Pagnito
Aug 13 2018 22:37
anyone know this error.
i keep getting it in heroku deployment
my build succueeds but i think this is the reason my bundle isnt being served right
The /tmp/build_cceb7bb3f92f94a66ffdf4e3d394e292/client/node_modules/mozjpeg/vendor/cjpeg binary doesn't seem to work correctly
remote: ⚠ mozjpeg pre-build test failed
Pagnito
@Pagnito
Aug 13 2018 22:57
iit was the image webpack loader
ima just a diffirent package
Jason Luboff
@JLuboff
Aug 13 2018 22:57
@Pagnito Not sure if it will make a difference, but I've found before that sometimes something wont deploy on Heroku, but deploys fine on Glitch
Christopher McCormack
@cmccormack
Aug 13 2018 22:58
@Pagnito this is kind of stupid, but if you have an invalid favicon I've had issues on both glitch and heroku
if you're using image webpack loader and it's handling your favicon, maybe...
Pagnito
@Pagnito
Aug 13 2018 22:58
i still havent used anythin besides heroku
ima check out glitch now
Christopher McCormack
@cmccormack
Aug 13 2018 22:59
i've used image-webpack-loader very recently and it works well
Pagnito
@Pagnito
Aug 13 2018 23:00
yea it works perfect in dev
it wasnt the thing that was breakin my build tho
Christopher McCormack
@cmccormack
Aug 13 2018 23:00
could be something you're loading, do you have a screenshot of the log?
Pagnito
@Pagnito
Aug 13 2018 23:01
the errors arent htere anymore but my js and css files are still served weird
Screen Shot 2018-08-12 at 4.25.45 PM.png
Christopher McCormack
@cmccormack
Aug 13 2018 23:02
@Pagnito i'm betting it's because your bundle didn't actually get created, check your network tab
Pagnito
@Pagnito
Aug 13 2018 23:03
it should ve because when i clone the repo off of heroku it was all there
Christopher McCormack
@cmccormack
Aug 13 2018 23:04
you should be building it on heroku not pulling the bundle from github
Pagnito
@Pagnito
Aug 13 2018 23:04
yea i know im using the postbuild script
im saying because i pulled it off heroku that means the bundle is built on heroku
Christopher McCormack
@cmccormack
Aug 13 2018 23:05
pulled what off heroku?
Pagnito
@Pagnito
Aug 13 2018 23:05
what i deployed on there
like the same way u can clone a github repo
i just cloned back what i deployed on heroku and opend it in my editor
Christopher McCormack
@cmccormack
Aug 13 2018 23:07
but you just said it's building as part of your process, so that would not include your bundle file
did you check the network tab to see if the bundle was loaded?
Pagnito
@Pagnito
Aug 13 2018 23:07
Screen Shot 2018-08-13 at 7.07.13 PM.png
i dont get it tho it shows the build process in the shell
hold on
"heroku-postbuild": "npm install --prefix client && npm run build --prefix client"
i have all my dev deps in deps
so i didnt use the NPM_CONFIG_PRODUCTION=false
Jason Luboff
@JLuboff
Aug 13 2018 23:15
Whooo... think I finally got my multi-file upload working...even though I haven't tested it lol
Christopher McCormack
@cmccormack
Aug 13 2018 23:15
mmhmm
Jason Luboff
@JLuboff
Aug 13 2018 23:17
Don't give me that
Christopher McCormack
@cmccormack
Aug 13 2018 23:18
you don't know me!
Jason Luboff
@JLuboff
Aug 13 2018 23:19
This is true. I only know the virtual embodiment of you.
Christopher McCormack
@cmccormack
Aug 13 2018 23:19
well and fb
Pagnito
@Pagnito
Aug 13 2018 23:19
Screen Shot 2018-08-13 at 7.19.17 PM.png
this shows during the heroku build process
Jason Luboff
@JLuboff
Aug 13 2018 23:19
@cmccormack True. I think I follow you on instagram too... I think
Christopher McCormack
@cmccormack
Aug 13 2018 23:24
I never post so now I will!
Jason Luboff
@JLuboff
Aug 13 2018 23:26
I post semi-infrequently
It's pretty much just my kid lol
Christopher McCormack
@cmccormack
Aug 13 2018 23:33
I just post my dogs mainly haha
Jason Luboff
@JLuboff
Aug 13 2018 23:33
Ya its usually your wife that tags you in something hah
Christopher McCormack
@cmccormack
Aug 13 2018 23:33
she posts?
not sure if I"m following her haha
Jason Luboff
@JLuboff
Aug 13 2018 23:34
She tags you in places you visit
Christopher McCormack
@cmccormack
Aug 13 2018 23:34
@Pagnito you may want to make sure your paths match, production vs local can be different. webpack has a publicPath variable I have to use to get mine working sometimes
yeah she does, no privacy!
haha
Well i'm off see you later!
Jason Luboff
@JLuboff
Aug 13 2018 23:35
See ya, hope dinner comes out good
Christopher McCormack
@cmccormack
Aug 13 2018 23:35
thanks :)
Pagnito
@Pagnito
Aug 13 2018 23:35
@cmccormack yea for some reason when i put my bundles in src folder it works but not when i create a build folder