These are chat archives for FreeCodeCamp/HelpJavaScript

22nd
Apr 2018
jusgoose
@gusd773
Apr 22 2018 00:05
@cmccormack no I have it in another sheet linked in the head
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:07
@gusd773 can u paste all code to codepen?
how can we help if u don't paste the css code?
jusgoose
@gusd773
Apr 22 2018 00:08
@brittanyrutherford that last bit of code is the only css added thus far
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:09
@gusd773 according to that, the background changes
@gusd773 here's ur code https://codepen.io/anon/pen/erpgZW
jusgoose
@gusd773
Apr 22 2018 00:09
@brittanyrutherford I know it works in codepen but won't in the browser I am running the script through
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:10
@gusd773 what script?
jusgoose
@gusd773
Apr 22 2018 00:10
blob
the html through*
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:10
@gusd773 is the css file rendered?
jusgoose
@gusd773
Apr 22 2018 00:11
@brittanyrutherford what do you mean? I have it linked into my html head if that's what you're asking
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:11
@gusd773 yeah, but it is actually downloaded by the page? open developer tools and see if the .css file is actually downloaded
jusgoose
@gusd773
Apr 22 2018 00:12
@brittanyrutherford gotcha, nope it is not being recognized by the browser
rendered*
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:12
@gusd773 share the folder structure
do u have a folder called css
jusgoose
@gusd773
Apr 22 2018 00:12
blob
@brittanyrutherford ^
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:13
u have ur html page under img folder
why?
for sure it won't find the .css
move the html to the root of the project folder
jusgoose
@gusd773
Apr 22 2018 00:14
@brittanyrutherford tutorial not personal preference but I figured it'd be for a good reason
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:14
nope
it doesn't make sense
even for a tutorial
move it to the root of the project project
same level as css folder
anthonygallina1
@anthonygallina1
Apr 22 2018 00:16
../css/main.css To go down and then up for example. The path is relative isnt it?
jusgoose
@gusd773
Apr 22 2018 00:16
@brittanyrutherford thank you that fixed it
CamperBot
@camperbot
Apr 22 2018 00:16
gusd773 sends brownie points to @brittanyrutherford :sparkles: :thumbsup: :sparkles:
:cookie: 4 | @brittanyrutherford |http://www.freecodecamp.org/brittanyrutherford
jusgoose
@gusd773
Apr 22 2018 00:16
@anthonygallina1 I tried doing them like that and it wouldn't work
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:17
@gusd773 it should work with ../css, but it doesn't make sense to have ur html under "img" folder
jusgoose
@gusd773
Apr 22 2018 00:17
I usually always place everything in the same folder idk why this dude didn't lol
prolly just old habit
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 00:17
because u shouldn't place everything in the same folder
anthonygallina1
@anthonygallina1
Apr 22 2018 00:18
@brittanyrutherford Is right though A index on root To not expose everything.
anthonygallina1
@anthonygallina1
Apr 22 2018 00:26
@brittanyrutherford yup putting everything in the same folder could scale hard
Your right
jusgoose
@gusd773
Apr 22 2018 00:34
@brittanyrutherford well anything with code I leave in the main folder anything else I learned goes into folders within the main one like images
Brittany Rutherford
@brittanyrutherford
Apr 22 2018 02:31
@gusd773 well, u can put html files in folders, but not one named img :P and most importantly, with correct links to the css folder
tundeiness
@tundeiness
Apr 22 2018 05:40
hi guys any help on how to turn these html element into strings which will then be pushed into a dive element called "pre"? the code are below
pre.innerHTML += "<div class='row listing'><div class='col-sm-3 logo'><img class = img-responsive src=" + data.logo + '></div><div class='row text'>
            <div class='col-sm-12 name'><p><a href=" ' + data.url + ' " target = "_blank">  + data.display_name + "</a></p></div><div class='row status'>
            <div class='col-sm-12 worx'><p class='neon'>ON-AIR</p></div>
         </div>
         </div></div>"
I'm having a big confusion here...
Joseph
@revisualize
Apr 22 2018 05:52
REFACTOR AGAIN!!!!!!!!!!!!!!!!!!!!
Let's DO THIS!
guys please help me I must stope my div when car go left or right they passed in my background please help me to stop this
1Mher1
@1Mher1
Apr 22 2018 09:58
exact I want to Relatively moving a div left or right with jQuery
Tom
@moT01
Apr 22 2018 12:09
@1Mher1 get the cars location with this http://api.jquery.com/offset/ - and use a test to make sure it stays within the area you want
1Mher1
@1Mher1
Apr 22 2018 12:11
@moT01 if I same Do position.left?
Tom
@moT01
Apr 22 2018 12:29
what
i dont know - give it a try
check
Tom
@moT01
Apr 22 2018 12:43
what am i checking - its all commented out
looks like it logs when you hit the left key
Jefferson
@jeffersonnnn
Apr 22 2018 12:46
Hi guys, i have a ReactJS specific question, okay if i ask?
Tom
@moT01
Apr 22 2018 12:48
i would do something like this...
$(document).keydown(function(e) {
  let stexn = e.key
  //get car position
  //if(not too far left && not too far right) {      
    if(stexn=="a"|| stexn=="A" || stexn=="ArrowLeft"){
      $("#div1").css({left:"-=10px"})
    } else if(stexn=="d"|| stexn=="D" || stexn=="ArrowRight"){
      $("#div1").css({left:"+=10px"})
    }
  }
}
@jeffersonnnn ask away - its better to just ask and not ask to ask
there isnt always someone hanging around to answer - but if you just ask - someone might show up and have an answer for ya
Stephen James
@sjames1958gm
Apr 22 2018 12:50
@jeffersonnnn Ask away
please check my js code
Tom
@moT01
Apr 22 2018 12:52
@1Mher1 its not working - check that last message i sent
1Mher1
@1Mher1
Apr 22 2018 12:54
above meesage if () plese wrote me correct code

if($("#div1").position().left<="540px" || $("#div1").position().right>="540px"){

}

I do that
Tom
@moT01
Apr 22 2018 12:55
check the console - when you hit left what do you get?
1Mher1
@1Mher1
Apr 22 2018 12:56
540,530,520 etc
Tom
@moT01
Apr 22 2018 12:57
what type of data is it
1Mher1
@1Mher1
Apr 22 2018 12:57
    console.log($("#div1").position().left)
pixels
Tom
@moT01
Apr 22 2018 12:57
is it?
looks like integers to me
and when you make your test, what type of data are you testing against
"540px"
1Mher1
@1Mher1
Apr 22 2018 13:03
I put if you want to pass 540pixels stop
my question about this why they don't stopped
I ried my best to solve but i can't for this i asked thid question
Tom
@moT01
Apr 22 2018 13:05
two reasons - you dont make any test to stop the movement before the piece actually moves
and the test you're trying to make wouldnt work if you did have it in the right place
540 === "540px" ? wont work
1Mher1
@1Mher1
Apr 22 2018 13:06
no
dont worked
Tom
@moT01
Apr 22 2018 13:07
did you read that code message i sent - where i gave you the logic
1Mher1
@1Mher1
Apr 22 2018 13:08

@moT01 if($("#div1").position().left>=540 || $("#div1").position().right<=540){

}

right worked already but left don't please help
Tom
@moT01
Apr 22 2018 13:09
im trying to help
here's your code...
$(document).keydown(function(e) {
    let stexn = e.key
    if(stexn=="a"|| stexn=="A" || stexn=="ArrowLeft"){
        $("#div1").css({left:"-=10px"})
        $("#div1").position().left
        console.log($("#div1").position().left)
    }if($("#div1").position().left<="540px" || $("#div1").position().right>="540px"){
so when someone hits left, there's nothing to stop the piece from moving
Jefferson
@jeffersonnnn
Apr 22 2018 13:11
@sjames1958gm @moT01 thanks guys. Okay, i am looking for an acceptable way to trigger a rerender of json - ina component- from an API housed in another component. So far i have floundered between component State (found it impractical) to plain introducing Redux to help with the state management. Any thoughts?
CamperBot
@camperbot
Apr 22 2018 13:11
jeffersonnnn sends brownie points to @sjames1958gm and @mot01 :sparkles: :thumbsup: :sparkles:
:star2: 1039 | @mot01 |http://www.freecodecamp.org/mot01
:star2: 9223 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Apr 22 2018 13:14
@jeffersonnnn What is the purpose of the other component? Simply to call an API?
Jefferson
@jeffersonnnn
Apr 22 2018 13:18
@sjames1958gm yes yes. It is a dumb one named button .
Stephen James
@sjames1958gm
Apr 22 2018 13:20
Why another component just for API?
Jefferson
@jeffersonnnn
Apr 22 2018 13:23
Wrong move? I just thought to house the api in a component, then make references to it from other components.
Stephen James
@sjames1958gm
Apr 22 2018 13:26
Well, in my mind a component relates to something put on the screen.
This is where redux could come in - but for a small application may be too much
You could house the API in a parent component which passes the API response to its children through props.
Somewhat depends on how big you expect your app to get
1Mher1
@1Mher1
Apr 22 2018 13:29
@moT01 if one tank passed car what code I can add points?
in my h1 tag
Jefferson
@jeffersonnnn
Apr 22 2018 13:36

@sjames1958gm so manipulating the re-rendering of the json is possible through parent components? okay then.

The app isn't anything big. A small random quotes generator shouldn't have to require Redux if i can avoid it. Plus i want mastery of React first before i bring in Redux. I have my hands full dealing with the vagaries of Webpack and Babel as it stands :D

Stephen James
@sjames1958gm
Apr 22 2018 13:38
Maybe start with a single component that invokes the API based on a simple button / paragraph tag, then refactor to more components as the design evolves.
Jefferson
@jeffersonnnn
Apr 22 2018 13:39
As an aside though, i was looking at just housing the button and json component in the same place: it would help deal with the state being manipulated (component state would work perfectly here). Thoughts?
@sjames1958gm exactly my thoughts. How to make this happen is what i don't know right now.
Stephen James
@sjames1958gm
Apr 22 2018 13:40
True but then how to get the API response data into the display component?
@jeffersonnnn Your API call is advised to go in componentDidMount, then in the async response from the API call you use setState to update the component state
1Mher1
@1Mher1
Apr 22 2018 13:41
@sjames1958gm can you help me to add in my h1 tag scores?
Jefferson
@jeffersonnnn
Apr 22 2018 13:42
@sjames1958gm shouldn't exporting it to a parent app.js solve the problem with view?
Stephen James
@sjames1958gm
Apr 22 2018 13:43
@jeffersonnnn How do you get the data out of the component's state?
@1Mher1 Just use document.QuerySelector("h1").textContent = newScore on the h1
Jefferson
@jeffersonnnn
Apr 22 2018 13:46
@sjames1958gm lemme share my code till now with you, please.

export default class JsonComponent extends Component {
    constructor(props) {
        super(props);
        this.state = {
            simpsonQuotes: [],
        };
    }

    getQuotes() {
            fetch('https://thesimpsonsquoteapi.glitch.me/quotes')
        .then(results => {
            return results.json();
        }).then(data => {

            let simpsonQuotes = data.map((quotes) => {
                return (
                    <div key={quotes.results}>
                        <p>{quotes.quote}</p>
                        <img src={quotes.image} />
                        <p>{quotes.character}</p>
                        <p>{quotes.characterDirection}</p>
                    </div>
                )
            })
            this.setState({simpsonQuotes: simpsonQuotes});
            console.log('state', this.state.simpsonQuotes);
        })
    }

    componentDidMount() {
    this.getQuotes();
}

    handleChange(event) {
        event.preventDefault();
        this.setState({ simpsonQuotes: this.refs.})
    }    

    render() {
        return (
            <div className="container">
                <div className="container1">
                    {this.state.simpsonQuotes}    
                </div>
            </div>

        );
    }

}
1Mher1
@1Mher1
Apr 22 2018 13:46
@sjames1958gm I should have variable global newScore? and I should Do cycle for?????????????
Stephen James
@sjames1958gm
Apr 22 2018 13:47
@1Mher1 You could have a global newScore -
1Mher1
@1Mher1
Apr 22 2018 13:48
@sjames1958gm I need to add cycle for i mean?
Stephen James
@sjames1958gm
Apr 22 2018 13:48
@1Mher1 I don't know what that means cycle
@jeffersonnnn This looks like the whole component with display
Jefferson
@jeffersonnnn
Apr 22 2018 13:51
@sjames1958gm you will notice the handleChange object. There is where i plan to place the method that will be called in the proximity of the onClick handler that should activate the new API call.
@sjames1958gm yes yes. It is exported to the app.js component
Stephen James
@sjames1958gm
Apr 22 2018 13:52
So on handleChange you just call this.getQuotes() again?
1Mher1
@1Mher1
Apr 22 2018 13:57
@sjames1958gm I mean for
Jefferson
@jeffersonnnn
Apr 22 2018 13:58
@sjames1958gm of course!
@sjames1958gm why didn't i think of such an obvious thing, christ! Okay, i need to try to implement this.
Stephen James
@sjames1958gm
Apr 22 2018 14:07
@1Mher1 When you pass a tank, just add one to score and set into the h1 you don't need a loop (for)
1Mher1
@1Mher1
Apr 22 2018 14:09
please help me to write correct code @sjames1958gm
Stephen James
@sjames1958gm
Apr 22 2018 14:12
@1Mher1 Write a function that you can call (score is global)
function updateScore() {
   score++;
   document.QuerySelector("h1").textContent = score;
}
1Mher1
@1Mher1
Apr 22 2018 14:17
@sjames1958gm in console they dont show error but dont worked
Stephen James
@sjames1958gm
Apr 22 2018 14:17
put some console.log statements in your code to see what is happening.
1Mher1
@1Mher1
Apr 22 2018 14:20
@sjames1958gm var score = 0
function updateScore() {
score++;
document.QuerySelector("#score").textContent = score;
console.log(score)
}
undifined
Stephen James
@sjames1958gm
Apr 22 2018 14:21
I think it is querySelector not QuerySelector - my bad
Are you even calling the function?
1Mher1
@1Mher1
Apr 22 2018 14:23
yes but they don't worked
in my html i have < h1 id="score"></h1>
<h1 id="score">Score</h1>
Stephen James
@sjames1958gm
Apr 22 2018 14:25
Do console.log("score = " + score)
So you know that you are calling the funcvtion
1Mher1
@1Mher1
Apr 22 2018 14:31
@sjames1958gm function updateScore() {
score++;
document.querySelector("#score").textContent = score;
}
console.log("score = " + score) they show me in console this script.js:26 score = [object HTMLHeadingElement]
@sjames1958gm if do this option var score = 0
function updateScore() {
score++;
document.querySelector("#score").textContent = score;
}
console.log("score = " + score) they show me this var score=0
1Mher1
@1Mher1
Apr 22 2018 14:48
????????????????????????????
???????????????????????
?????????????????????????????????
Amit Patel
@AmitP88
Apr 22 2018 15:16

hey guys, I know this isn't the right channel for this, but is it ok if you guys can give me some feedback on my project? https://amitp88.github.io/Random-Quote-Generator/

I spent some time trying to get it as responsive as I can get it

Tom
@moT01
Apr 22 2018 15:29
@AmitP88 looks good - there's some code in some of the quotes or jokes
Joke : "Knock knock. \n Who's there? \n Little old lady. \n Little old lady who?"
Stephen James
@sjames1958gm
Apr 22 2018 15:30
@AmitP88 :+1: Good job!
Tom
@moT01
Apr 22 2018 15:30
but it looks like it all works, and is resposive
Amit Patel
@AmitP88
Apr 22 2018 15:31
@moT01 oh yeah, that's coming from the API itself
@sjames1958gm thanks Stephen! :)
CamperBot
@camperbot
Apr 22 2018 15:31
amitp88 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9224 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Amit Patel
@AmitP88
Apr 22 2018 15:31
@moT01 thanks Tom! :)
Dhaval Vira
@dhavalveera
Apr 22 2018 15:34
not only one but we all are here to help everyone
1Mher1
@1Mher1
Apr 22 2018 15:41
anybody who can help me to add score in my game?
1Mher1
@1Mher1
Apr 22 2018 16:27
??????????????????????
tundeiness
@tundeiness
Apr 22 2018 17:44
@sjames1958gm hi james I need help with this code...I am trying to turn them into string which will then be converted into proper HTML elements..
pre.innerHTML += "<div class='row listing'><div class='col-sm-3 logo'><img class = 'img-responsive src=' " + data.logo +  " '></div>" + "<div class='row text'>
            <div class='col-sm-12 name'><p><a href=" ' + data.url + ' " target = "_blank">  + data.display_name + "</a></p></div><div class='row status'>
            <div class='col-sm-12 worx'><p class='neon'>ON-AIR</p></div>
         </div>
         </div></div>"
@sjames1958gm I suspect the img tag as the culprit
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 17:51
Hey guys
Stephen James
@sjames1958gm
Apr 22 2018 17:57
@tundeiness You could use template strings - easier to get right - but I see a missing ' after img-responsive
tundeiness
@tundeiness
Apr 22 2018 18:00
@sjames1958gm sure..but the missing ' isn't the only issue...
Stephen James
@sjames1958gm
Apr 22 2018 18:02
@tundeiness Look at _blank you are using " I think that should b'
And you need a " after > before + data.display_name
tundeiness
@tundeiness
Apr 22 2018 18:03
@sjames1958gm okay
tundeiness
@tundeiness
Apr 22 2018 18:14
@sjames1958gm still unexpected illegal token
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 18:16
I have a request body that is showing as a string how do I fix this?
Tiago Correia
@tiagocorreiaalmeida
Apr 22 2018 18:19
@RoniqueRicketts what do you mean?
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 18:20
@tiagocorreiaalmeida the form you were helping me witch won't allow me to access the body of my request
Tiago Correia
@tiagocorreiaalmeida
Apr 22 2018 18:20
Do you have someline saying app.use(express.json()) ?
So you can acess the request body by named propreties
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 18:21
oh cool
@tiagocorreiaalmeida this is how it comes up { userInfo: '[object Object]' }
Tiago Correia
@tiagocorreiaalmeida
Apr 22 2018 18:26
try to use Object.keys(obj) to see what you get
Josh Queen
@Kohota107
Apr 22 2018 18:31
Evening all
Can somebody explain why you would use the arguments object to pass in the argument values rather than the use the named argument itself?
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 18:36
@tiagocorreiaalmeida this is my response [ 'userInfo', 'avatar' ]
Josh Queen
@Kohota107
Apr 22 2018 18:37
Actually, nevermind
I've figured it out
Danny Chan
@chandanny
Apr 22 2018 18:43
Hello
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 18:44
hail
Danny Chan
@chandanny
Apr 22 2018 18:47
What is the entry level of full stack developer?
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 18:50
One of the pros will answer soon.
Brad
@bradtaniguchi
Apr 22 2018 19:07
@chandanny what do you mean entry level?
Josh Queen
@Kohota107
Apr 22 2018 19:15
Guys how do I splice from a multi-dimensional array?
var someArr  = [[4,6],[6,9],[3,5]]
How would I splice out the number 9 for example
I.e. at position [1][1]
jusgoose
@gusd773
Apr 22 2018 19:19
nvm
Joseph
@revisualize
Apr 22 2018 19:39
Hi.
@Kohota107 Do you still need assistance?
Joseph
@revisualize
Apr 22 2018 19:44

If you're trying to remove 9 from:

var someArr  = [[4,6],[6,9],[3,5]]

someArr[1] = someArr[1].slice(0,1);

or
if you're just trying to remove the last element.
someArr[1].pop();
or if you're trying to remove the first element.
someArr[1].shift();
And as you mentioned.
If you're trying to just capture the 9 as a value.
someArr[1][1];
Now... If you have a random multi-dim array and don't know if or where a value is within that array and you want to search for and remove that value.....
tundeiness
@tundeiness
Apr 22 2018 19:50
Hi all in the twitchtv user story which says: User Story: if a Twitch user is currently streaming, I can see additional details about what they are streaming. what additional details are we referring to here please?
is it from something from data.status?
Joseph
@revisualize
Apr 22 2018 20:18
@tundeiness Have you looked at the json data?
tundeiness
@tundeiness
Apr 22 2018 20:19
@revisualize yes I have
@revisualize the only additional info i'd like to add is data.status using the channel end point
@revisualize the users endpoint does not have too much information though
Joseph
@revisualize
Apr 22 2018 20:22
@tundeiness You're the one creating the project.
Stevie
@StevieCF
Apr 22 2018 20:22
Hi all, I've got a basic question. In the lookup challenge (https://www.freecodecamp.org/challenges/using-objects-for-lookups) why was it neccesary to use bracket notation instead of dot notation?
tundeiness
@tundeiness
Apr 22 2018 20:22
@revisualize yeah...true that...i will just add anything I want then.
Joseph
@revisualize
Apr 22 2018 20:24
I haven't completed that project.
Tiago Correia
@tiagocorreiaalmeida
Apr 22 2018 20:24
anyone who uses bcrypt around?
Ronique Ricketts
@RoniqueRicketts
Apr 22 2018 20:26
@tiagocorreiaalmeida thanks
CamperBot
@camperbot
Apr 22 2018 20:26
roniquericketts sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 523 | @tiagocorreiaalmeida |http://www.freecodecamp.org/tiagocorreiaalmeida
Stephen James
@sjames1958gm
Apr 22 2018 20:26
@tundeiness Hope you resolved it I had to go clean up the garage
tundeiness
@tundeiness
Apr 22 2018 20:27
@sjames1958gm yup I did..I will show you
@sjames1958gm
pre.innerHTML += "<div class='row listing'><div class='col-sm-3 logo'><img class = 'img-responsive' src=" + data.logo + "></div><div class='row text'><div class='col-sm-12 name'><p><a href="+ data.url +" target = '_blank'>"  + data.display_name + "</a></p></div><div class='row status'><div class='col-sm-12 worx'><p class='neon' style='color:#32CD32;'> ON-AIR </p></div></div></div>"
Joseph
@revisualize
Apr 22 2018 20:28
@sjames1958gm :wave:
Stephen James
@sjames1958gm
Apr 22 2018 20:28
@revisualize :wave:
Joseph
@revisualize
Apr 22 2018 20:28
I had a phone interview about an hour ago.
I don't know how it went.
Stephen James
@sjames1958gm
Apr 22 2018 20:29
@revisualize I guess that is better than knowing you blew it :)
anthonygallina1
@anthonygallina1
Apr 22 2018 20:29
:wave:
Joseph
@revisualize
Apr 22 2018 20:29
@sjames1958gm true
@sjames1958gm Now... Back to... Exact Change.
Joseph
@revisualize
Apr 22 2018 20:36
@anthonygallina1 @sjames1958gm is there a better way of doing this:
var ammountToCustomer = Number( ( (cash).toFixed(2) - (price).toFixed(2) ).toFixed(2) );
anthonygallina1
@anthonygallina1
Apr 22 2018 20:37
let
Stephen James
@sjames1958gm
Apr 22 2018 20:38
@revisualize Is there a reason to use toFixed on anything but the last result?
@revisualize meaning the first two seem not useful
Joseph
@revisualize
Apr 22 2018 20:41
@sjames1958gm Yeah. You're correct. var ammountToCustomer = Number( ( cash - price ).toFixed(2) );
anthonygallina1
@anthonygallina1
Apr 22 2018 20:41
sry was it const?
Joseph
@revisualize
Apr 22 2018 20:42
@anthonygallina1 Floating Point math sucks.
I'm trying to figure out how to make my application not break.
anthonygallina1
@anthonygallina1
Apr 22 2018 20:44
@revisualize I just woke up. I was looking at it yesterday, about this time same situation. Late night coding.
Joseph
@revisualize
Apr 22 2018 20:45
@anthonygallina1 Yeah, I solved Exact Change .... But, I do NOT like my solution.
anthonygallina1
@anthonygallina1
Apr 22 2018 20:45
I made some thing in google challenge simular Want me to boot up the sys and see if I can find it?
Joseph
@revisualize
Apr 22 2018 20:46
It's all good.
I'm still playing around with a new solution.
This is the meh solution that I came up with last night. Github - revisualize: FreeCodeCamp/Exact Change.js
anthonygallina1
@anthonygallina1
Apr 22 2018 20:47
Checking
Joseph
@revisualize
Apr 22 2018 20:48
There are just WAY too many loops and too many steps.
Converting everything to pennies. Then looping through the array to figure out how much is in the drawer then doing math to figure out everything.
I don't think I need to figure out how much is in the till before I start to cash the person out.
When I worked as a waiter, I never checked how much was in the till before I cashed a customer out.
anthonygallina1
@anthonygallina1
Apr 22 2018 20:55
Good job. Maybe ternary operators if you wanted. https://hackernoon.com/rethinking-javascript-the-if-statement-b158a61cd6cb
Joseph
@revisualize
Apr 22 2018 20:56
@anthonygallina1 I use those in other challenges.
Stephen James
@sjames1958gm
Apr 22 2018 20:58
@revisualize Just cash out the till like when you were a waiter, if you happen to run out of change in the till then "insufficient change"
the only issue is that they want you to close out the till if it is empty, which adds extract logic :(
Joseph
@revisualize
Apr 22 2018 20:58
Yeah.
@sjames1958gm I'm working through it.
Stephen James
@sjames1958gm
Apr 22 2018 20:58
@revisualize good skill !
Joseph
@revisualize
Apr 22 2018 20:59
@sjames1958gm I am going to need to figure out the logic for checking if there is no money left in the cid.
I think I'm just going to need to do a .every()
Stephen James
@sjames1958gm
Apr 22 2018 20:59
yes
Joseph
@revisualize
Apr 22 2018 21:07
@sjames1958gm Something like this:
  var ammountToCustomer = Number( ( cash - price ).toFixed(2) ); 

  cid.reverse(); // reverse the cid to work from largest denoms down to smallest.

  var change = cid.reduce( function ( accumArr , currentArr , index) {
                                  } , []);

  if (ammountToCustomer.toFixed(2) > 0) {
        return "Insufficient Funds";
  }
  if ( cid.every(function (val) { return Number( val.toFixed(2) ) === 0; }) ) {
        return "Closed";
  }
That isn't correct.
val[1].toFixed(2)
That's correct.
Because val[0] is a String.
jusgoose
@gusd773
Apr 22 2018 21:11
blob
blob
can anybody tell my why timer isn't within my "wrap" div?
Joseph
@revisualize
Apr 22 2018 21:12
Because you have to put it in there.
Just linking to the JS doesn't do anything.
jusgoose
@gusd773
Apr 22 2018 21:13
what do you mean? @revisualize
Joseph
@revisualize
Apr 22 2018 21:13
@gusd773 You could and should move all of those script tags out of your inline HTML
@gusd773 A script tag is not like an img tag.
@gusd773 Putting the script tag there will not make all of the code for that js load there.
@gusd773 You need to create a <div class="timer"></div> or <div id="timer"></div> (if you just have 1 timer)
@gusd773 Also, you need to show more code. Do you have this on CodePen or in a Github Pages?
jusgoose
@gusd773
Apr 22 2018 21:17
ahhh so @revisualize putting the script into a div of it's own will push it into my "wrap" div container
?
Joseph
@revisualize
Apr 22 2018 21:17
@gusd773 Only means that the js is executed when it his that line.
The script tags should either be in the head or after the body.
anthonygallina1
@anthonygallina1
Apr 22 2018 21:21
@revisualize i am liking your gist Making me think thanks
CamperBot
@camperbot
Apr 22 2018 21:21
anthonygallina1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4466 | @revisualize |http://www.freecodecamp.org/revisualize
Joseph
@revisualize
Apr 22 2018 21:26
@anthonygallina1 This is a challenging challenge.
anthonygallina1
@anthonygallina1
Apr 22 2018 21:27
:)
Joseph
@revisualize
Apr 22 2018 21:36
Screw this.
anthonygallina1
@anthonygallina1
Apr 22 2018 21:36
:(
You will get it
Joseph
@revisualize
Apr 22 2018 21:38
I know.
I'm kind of hungry.
anthonygallina1
@anthonygallina1
Apr 22 2018 21:38
I got a nice set up running on old wiring. I need to pull up my other system. But insufficient battery backups too.
Soome times a break helps
Joseph
@revisualize
Apr 22 2018 21:39
And I've been thinking about this even before my interview.
I was thinking about it all night long.
I'm going to make some popcorn and enjoy Sunday.
I did have a 45min interview on a Sunday.
anthonygallina1
@anthonygallina1
Apr 22 2018 21:40
:(
you missed it?
Damn
Joseph
@revisualize
Apr 22 2018 23:01
@anthonygallina1 I didn't miss the interview.
anthonygallina1
@anthonygallina1
Apr 22 2018 23:01
good