These are chat archives for FreeCodeCamp/HelpJavaScript

6th
May 2018
Conor Murphy
@cmurphy580
May 06 2018 00:05
figured it out was the scripts section
Stephen James
@sjames1958gm
May 06 2018 01:16
@cmurphy580 Glad I could help :)
aRtoo
@artoodeeto
May 06 2018 02:30
someone i could bother? help a brother out
Brad
@bradtaniguchi
May 06 2018 02:35
@artoodeeto hello
aRtoo
@artoodeeto
May 06 2018 02:35
yow bro @bradtaniguchi
Brad
@bradtaniguchi
May 06 2018 02:36
Hi, hows it going
aRtoo
@artoodeeto
May 06 2018 02:37
bro i have a problem bro. so im making this practice game. i need to guess a word. lets say. abba i need to make them in -(did that) now my problem is user input a word. lets say a i have this a--a. but when i enter b itll update the text to -bb- not abba
heres my code for now bro
 checker: function(userKey){
                let returnObjOfSetUp = toCheckTitle; //thsis will return the word that needs to be guessed
                let dashArr = returnObjOfSetUp.dashedWord.split('');
                let DOMelemGuessWordHolder = returnObjOfSetUp.DOMelem; // DOM elem of guess word
                let guessWord = returnObjOfSetUp.songTitle; // title of the song string
                let guessWordArr = guessWord.split('') //song title will be modified as an array
                let newWordArr = []; //will be use to return an 

                if (guessWord.includes(userKey)) {
                    for (let i = 0; i < guessWordArr.length; i++) {



                        if( guessWord[i].includes(userKey)){
                            newWordArr.push(dashArr[i] = userKey);

                        }
                    }
                    DOMelemGuessWordHolder.innerText = dashArr.join("");
                    console.log(dashArr.join(""));

                }
@bradtaniguchi i know bro kinda hard kinda not. but i think im near. im just missing something.
Brad
@bradtaniguchi
May 06 2018 02:40
So just to make sure I understand your example, guessWord will start as 'a--a' right?
Id like to know what dashArr, and guessWord starts as so I can walk thru the code in my mind, Im not too sure about what each is tho
aRtoo
@artoodeeto
May 06 2018 02:42
@bradtaniguchi no itll start at. ---- dashes depending on the length of the word
Brad
@bradtaniguchi
May 06 2018 02:43
So in your example, both start as ----?
aRtoo
@artoodeeto
May 06 2018 02:44
dashArr will be the word to ----
guessword will be the actual word. say abba
only one word will show up bro
anthonygallina1
@anthonygallina1
May 06 2018 02:44
Hi
aRtoo
@artoodeeto
May 06 2018 02:45
@anthonygallina1 lets team up. lols
anthonygallina1
@anthonygallina1
May 06 2018 02:46
What does the data look like?
Brad
@bradtaniguchi
May 06 2018 02:46
Ah I see
anthonygallina1
@anthonygallina1
May 06 2018 02:47
@bradtaniguchi :)
@artoodeeto On what?
aRtoo
@artoodeeto
May 06 2018 02:48
scroll a bit. i have a bug. lols. haha. help a bro out?
@bradtaniguchi thanks man.
CamperBot
@camperbot
May 06 2018 02:48
artoodeeto sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 471 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Brad
@bradtaniguchi
May 06 2018 02:49

My guess is with this code:

if (guessWord[i].includes(userKey)) {
  newWordArr.push(dashArr[i] = userKey);
}

If the guessWord at the index i has the userKey, we push into the new array the userKey ( and assign the userKey to the dashArr[i] at the same time))

Now if it doesn't include anything, you skip over that item in the guessWord array, and update the innerText with the dashArr;
So I just noticed this arrary doesn't do anything, its all the dashArr
hmm
aRtoo
@artoodeeto
May 06 2018 02:53
@bradtaniguchi yea bro. thats problem. that condition
Brad
@bradtaniguchi
May 06 2018 02:54
Oh, wait checking guessWord[i].includes(userKey) is guessWord[i] just a single letter?
Wait no thats fine :/
(Or at least I think it should be)
aRtoo
@artoodeeto
May 06 2018 02:55
yea just single letter
@bradtaniguchi i think i need to re use the dashArr to be in the condition
Brad
@bradtaniguchi
May 06 2018 02:58
Yea maybe, Im still not sure of the original bug tho so I'm not 100% sure if that would fix it
anthonygallina1
@anthonygallina1
May 06 2018 02:59
I still dont understand the data It is using Oh wells
Brad
@bradtaniguchi
May 06 2018 03:01
Yea something is up, throwing out the DOM stuff I feel like the underlying code shouldn't be able todo a--a to -bb- on a single keystroke, its almost like something else is happening.
like the text is reset (which doesn't seem to be done in this code) but I could be wrong
aRtoo
@artoodeeto
May 06 2018 03:02
@anthonygallina1 arrBand: [ { song_title: 'passionfruit', imgUrl: './assets/images/drake_passion_fruit.jpeg', mp3Url: './music.mp3' }, { song_title: 'location', imgUrl: './assets/images/khaled_location.jpeg', mp3Url: './music2.mp3' }, { song_title: 'psycho', imgUrl: './assets/images/Post_Malone_Psycho.png', mp3Url: './music3.mp3' } ]
@anthonygallina1 its an array of objects if thats what you meant
@bradtaniguchi its ok bro. cool. its just im reassigning the array and update the DOM
@bradtaniguchi thanks much
CamperBot
@camperbot
May 06 2018 03:04
artoodeeto sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
api offline
Brad
@bradtaniguchi
May 06 2018 03:05
Id look at returnObjOfSetUp.dashedWord.split('') since if Im right, that means every time you come through this function its getting the ----thus this function works as expected (more or less) but one of its inputs is always the default value.
anthonygallina1
@anthonygallina1
May 06 2018 03:11
Seems this place gets more helper unfriendly
I was just wondering the data So.... Maybe i could figure it out. Sorry.
Brad
@bradtaniguchi
May 06 2018 03:12
@anthonygallina1 Im not even sure what you mean by data :/
anthonygallina1
@anthonygallina1
May 06 2018 03:12
like the keys it was working on
Ummm like jason data Or who knows I didnt see the whole thing
Brad
@bradtaniguchi
May 06 2018 03:13
bro i have a problem bro. so im making this practice game. i need to guess a word. lets say. abba i need to make them in -(did that) now my problem is user input a word. lets say a i have this a--a. but when i enter b itll update the text to -bb- not abba
anthonygallina1
@anthonygallina1
May 06 2018 03:14
Yup didnt understand that. oh wells I used to call it communication
np
Brad
@bradtaniguchi
May 06 2018 03:16
Oh, I mean I figured the last sentence was good enof to get the bug across
anthonygallina1
@anthonygallina1
May 06 2018 03:16
Ya loop over the data and return string -
Maybe write to DOM or console
Conor Murphy
@cmurphy580
May 06 2018 03:35
can anyone help me with the scripts section of my package.json?
Brad
@bradtaniguchi
May 06 2018 03:36
whats wrong with it?
Conor Murphy
@cmurphy580
May 06 2018 03:37
@bradtaniguchi i have such i can deploy it to heroku later, and its worked, but recently i can get past the 'start' section of the 'scripts' object when it compiles. here is what is going on:
  "scripts": {
    "dev": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "postinstall": "webpack -p",
    "start": "node server.js",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
    "test:watch": "npm run test -- --watch"
  }
Brad
@bradtaniguchi
May 06 2018 03:39
what you mean when you say can't get past the start parts of the scripts?
Conor Murphy
@cmurphy580
May 06 2018 03:40
when i run 'run start' in the terminal this is how far it goes, and doesn't compile:
> redux-simple-starter@1.0.0 start /Users/CMurphy/Desktop/World News 2.0
> node server.js
Conor Murphy
@cmurphy580
May 06 2018 03:46
or could @bradtaniguchi this be a different issue
Greg Duncan
@GregatGit
May 06 2018 04:34
@cmurphy580 make sure you have all the node modules downloaded
Conor Murphy
@cmurphy580
May 06 2018 04:49
@GregatGit how do i make sure theyre all downloaded
anthonygallina1
@anthonygallina1
May 06 2018 05:16
ls in node modules dir Or open the folder and look if you want
Raghav Mundra
@Raghav17
May 06 2018 06:32
Hey!
I am stuck on this challenge for a while now: https://beta.freecodecamp.org/en/challenges/react/create-a-controlled-form
Here's my code:
class MyForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      input: '',
      submit: ''
    };
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }
  handleChange(event) {
    this.setState({
      input: event.target.value
    });
  }
  handleSubmit(event) {
    // change code below this line
    this.setState({
      submit: this.state.input
    });
    event.preventDefault();
    // change code above this line
  }
  render() {
    return (
      <div>
        <form onSubmit={this.handleSubmit}>
          { /* change code below this line */ }
          <input value={this.state.input} onChange={this.handleSubmit}>
          </input>
          { /* change code above this line */ }
         <button type='submit'>Submit!</button>
        </form>
        { /* change code below this line */ }
        <h1>
        <submit/>
        </h1>
        { /* change code above this line */ }
      </div>
    );
  }
};
Can anyone please help?
anthonygallina1
@anthonygallina1
May 06 2018 06:34
No guarantees I am kinda slow. But I will copy yours and go look to see if i see anything. If you want
Raghav Mundra
@Raghav17
May 06 2018 06:36
@anthonygallina1 That would be great! :D
Raghav Mundra
@Raghav17
May 06 2018 07:23
@anthonygallina1 Had a chance to look at it?
anthonygallina1
@anthonygallina1
May 06 2018 07:26
@Raghav17 i have been looking at it LOL :)
Raghav Mundra
@Raghav17
May 06 2018 07:27
@anthonygallina1 haha, okay. :smile:
anthonygallina1
@anthonygallina1
May 06 2018 07:27
My win machine is updating to 1803 and I cant get to my class notes
:(
I was working through some thing like this with mcginnis last week
Raghav Mundra
@Raghav17
May 06 2018 07:28
@anthonygallina1 From where did you studied React?
Razvan Jackson
@RazvanJackson
May 06 2018 07:29
Someone here who's investing in stocks?
anthonygallina1
@anthonygallina1
May 06 2018 07:31
Cory house Azmut some here Udemy plurasight Bucky Roberts etc
Raghav Mundra
@Raghav17
May 06 2018 07:31
Thanks! Bucky is great! :+1:
anthonygallina1
@anthonygallina1
May 06 2018 07:33
Some on here helped 2 I took a step away from my foundation learning 2 years ago But React looks like it will be strong here eventually
Ya I can understand Bucky
K on the end of that update keeping my fingers crossed and rebooting
Hanging on the restart screen
Raghav Mundra
@Raghav17
May 06 2018 07:39
Ayee
:worried:
anthonygallina1
@anthonygallina1
May 06 2018 07:39
looks normal so far
Raghav Mundra
@Raghav17
May 06 2018 07:39
That's good news. :)
anthonygallina1
@anthonygallina1
May 06 2018 07:39
Might wait a while to run my registry cleaner
Raghav Mundra
@Raghav17
May 06 2018 07:41
@anthonygallina1 BTW, checked out your website. It is very impressive. :+1:
anthonygallina1
@anthonygallina1
May 06 2018 07:42
This guy is good but he moves fast https://www.youtube.com/watch?v=ul0tRkeu5CE
But straight to the point
@Raghav17 thank you
CamperBot
@camperbot
May 06 2018 07:44
anthonygallina1 sends brownie points to @raghav17 :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @raghav17 |http://www.freecodecamp.org/raghav17
anthonygallina1
@anthonygallina1
May 06 2018 07:44
It really needs lots of work
Marianissimus
@Marianissimus
May 06 2018 07:53
Hi, guys, I need your help: my click event fires the first time, and then every other 2 times:
var isMenuButtonClicked = false;
document.querySelector('#buttonwaves').addEventListener('click', function() {
 if (isMenuButtonClicked === false ){
    menulinks.play();
    isMenuButtonClicked = true;
  } else if (isMenuButtonClicked === true) {
    menulinks.reverse();
    isMenuButtonClicked = false;
  }
});
I tried on click, and is menubuttonclicked = !ismenubuttonclicked, same result
Raghav Mundra
@Raghav17
May 06 2018 07:56
@anthonygallina1 Hey, It worked for me. Thanks. :)
anthonygallina1
@anthonygallina1
May 06 2018 07:57
@Raghav17 was afk Cool :)
Raghav Mundra
@Raghav17
May 06 2018 08:01
:+1:
anthonygallina1
@anthonygallina1
May 06 2018 08:05
var isMenuButtonClicked = false;
document.querySelector('#buttonwaves').addEventListener('click', function() {
 if (isMenuButtonClicked = true){
    menulinks.play();
  } else (isMenuButtonClicked =  false) {
    menulinks.reverse()
  }
});
I dunno maybe?
I wonder if you need the global var
Marianissimus
@Marianissimus
May 06 2018 08:07
on ismenubuttonclicked? I'll try, thanks
anthonygallina1
@anthonygallina1
May 06 2018 08:09
Seems default might be false
Marianissimus
@Marianissimus
May 06 2018 08:13
Yes, default is false; and I want to toggle it on click
Should I use a different logic?
anthonygallina1
@anthonygallina1
May 06 2018 08:16
@Marianissimus checking button code here It maybe simular
i have that in vanilla when this update stops
Unles it wiped my data
Then backups fishing
aRtoo
@artoodeeto
May 06 2018 08:57
anyone online?
anthonygallina1
@anthonygallina1
May 06 2018 08:58
nope
;)
Hi @artoodeeto
aRtoo
@artoodeeto
May 06 2018 08:59
@anthonygallina1 sup bro.
i aleady asked you. haha
anthonygallina1
@anthonygallina1
May 06 2018 09:00
Good Lord just finished the win10 1803 update Finished with a aggrement screen almost need to be a lawyer to read all that
I thought it was nuking my data It took so long
Aditya
@ezioda004
May 06 2018 09:25
@anthonygallina1 The new update sucks, anything that uses v8 engine freezes windows and its super annoying.
Amit Patel
@AmitP88
May 06 2018 09:29
hey guys, what do you think of my weather app so far? is it accurate with the weather in your location? https://amitp88.github.io/Local-Weather-App/
Pieter Stokkink
@forkerino
May 06 2018 09:38
@AmitP88 yeah, seems accurate. However, I twice had a weird thing happening where it got stuck on Fahrenheit (on chrome/Android). Tapping the temp didn't change it anymore. First it happened immediately, the second time after switching a couple times back and forth.
Amit Patel
@AmitP88
May 06 2018 09:39
@forkerino oh yeah, I've noticed that too. it works again on refresh, but I'll see if I can tweak my code to fix that
aRtoo
@artoodeeto
May 06 2018 09:40
hey fam i need help
is it ok?
Amit Patel
@AmitP88
May 06 2018 09:42

@forkerino I've looked over my code

                var Fahrenheit_temp = Math.floor(weather_data.currently.apparentTemperature);
                var Celsius_temp = Math.floor((Fahrenheit_temp - 32) * 0.5556);
                temperature.innerHTML = Fahrenheit_temp;
                scale.innerHTML = 'F';
                scale.style.color = 'red';
                scale.style.fontWeight = 'bold';

                $(scale).click(function(){
                    if((temperature.innerHTML = Fahrenheit_temp)&&(scale.innerHTML === 'F')){
                        temperature.innerHTML = Celsius_temp;
                        scale.innerHTML = 'C';
                        scale.style.color = 'blue';
                    } else if((temperature.innerHTML = Celsius_temp)&&(scale.innerHTML === 'C')){
                        Fahrenheit_temp = Math.floor(Celsius_temp * 1.8 + 32);
                        temperature.innerHTML = Fahrenheit_temp;
                        scale.innerHTML = 'F';
                        scale.style.color = 'red';
                    }
                });

but I can't figure out how to tweak it to get rid of that bug. In the if statement I tried changing scale.innerHTML === 'F' to scale.innerHTML = 'F' (and the same thing with C), but it broke the toggle after that

JS
@24KPureHandSome
May 06 2018 09:56
hi
somebody
how can i get a key of json array using javascript?
Amit Patel
@AmitP88
May 06 2018 09:59
@24KPureHandSome you mean just access an array element?
JS
@24KPureHandSome
May 06 2018 10:02
including more than 1 object
i just want to judge what i type whether it exist
so i waht to get the key
@AmitP88
Amit Patel
@AmitP88
May 06 2018 10:04
@24KPureHandSome hmmm, i'm not really sure. Sorry :(
JS
@24KPureHandSome
May 06 2018 10:05
ok fine
NikolaNbgd
@NikolaNbgd
May 06 2018 11:49
@megma_jj_twitter if I can use js, that would be solved like a charm, but this time I have to figure out how to iterate through object via PUG template, damn
Stephen James
@sjames1958gm
May 06 2018 11:58
@24KPureHandSome
Can you provide an example? Key of json array doesn't make a lot of sense without example.
@AmitP88 Looks like you got it workin?
Amit Patel
@AmitP88
May 06 2018 12:03
@sjames1958gm yeah :) now I'm just picking out some backgrounds to go with the weather icons
@sjames1958gm do you know where I can get animated weather background gifs? I've tried googling for them but haven't had much luck
Stephen James
@sjames1958gm
May 06 2018 12:04
@AmitP88 I don't know of anything specific - would have to google myself
JS
@24KPureHandSome
May 06 2018 12:04
image.png
@sjames1958gm
like this
Amit Patel
@AmitP88
May 06 2018 12:04
@sjames1958gm ah ok, no worries. I'll probably just stick with still images then
Stephen James
@sjames1958gm
May 06 2018 12:05
@24KPureHandSome You will have to search the array using a loop
@24KPureHandSome
   for (var i = 0; i < contacts.length; i++) {
     // test each contact[i] for key
  }
JS
@24KPureHandSome
May 06 2018 12:12
@sjames1958gm thx i will try
CamperBot
@camperbot
May 06 2018 12:12
24kpurehandsome sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9231 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
May 06 2018 12:13
@sjames1958gm good luck
Ken Haduch
@khaduch
May 06 2018 12:13
@AmitP88 - I just tried it on my phone and it didn’t display anything? Maybe a responsive issue? I’ll go try the desktop...
Amit Patel
@AmitP88
May 06 2018 12:14
@khaduch it takes a second or two to load. I might add a preloader to it after I'm done
Ken Haduch
@khaduch
May 06 2018 12:14
I waited for 10 seconds? Let me try again...
Amit Patel
@AmitP88
May 06 2018 12:16
@khaduch oh... hmmm, I'll have to try it on mobile in a bit. I'm working on picking out some backgrounds for it
Ken Haduch
@khaduch
May 06 2018 12:20
@AmitP88 - I could see the "progress bar" streak across the top of the screen after a couple seconds, but just displays the message about "Click on the temperature to change from Fahrenheit to Celsius and back again".
On the desktop, it asked for my location permission, after I clicked that it came up with the temp and I could click it. Maybe I have a security setting on my phone that doesn't allow access to the location? Maybe I'll pop the URL into the Chrome browser on my phone and see what it does. But on the desktop it looked like it got the location and weather accurately.
Amit Patel
@AmitP88
May 06 2018 12:21
@khaduch ohh yeah, on the browser it'll ask you for location permissions first so it could be that
Ken Haduch
@khaduch
May 06 2018 12:22
@AmitP88 - yes! The Chrome browser popped up the location request, so once I allowed it, it worked. The display was a little off, but you probably just haven't gotten to take a look at that. Looking good so far!
Amit Patel
@AmitP88
May 06 2018 12:23
@khaduch thank you! :) yeah, I just wanted to get the user stories fulfilled first. Now I'm just working on completing the design part
CamperBot
@camperbot
May 06 2018 12:23
amitp88 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3907 | @khaduch |http://www.freecodecamp.org/khaduch
Ken Haduch
@khaduch
May 06 2018 12:48
@AmitP88 - I did see someone use GIFs for their weather app. but they took a totally different approach. Instead of weather-related GIFs, they "translated" the conditions to some search so that if the weather was rainy or lousy, he searched for some related pictures. It was kind of funny. I think that it was @NJM8 - maybe he'll see this and respond? But it wasn't strictly weather GIFs.
Amit Patel
@AmitP88
May 06 2018 12:48
@khaduch actually, I already picked out some high-res photos, but if he responds, I'll check it out :)
@khaduch thanks again :)
CamperBot
@camperbot
May 06 2018 12:49
amitp88 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
api offline
Nate Mallison
@NJM8
May 06 2018 13:12
@AmitP88 @khaduch yes that was mine. It's on my portfolio page linked in my profile. I used the giphy api to get the gifs, I was able to use the weather description for the weather gif but had to make a scale for words to match wind speed and temperature. You can see the switch statements in the code link.
Amit Patel
@AmitP88
May 06 2018 13:15
@NJM8 ah I see. I just checked out your project. Btw, nice portfolio site! I really like the animations :)
aRtoo
@artoodeeto
May 06 2018 14:57
someone here i could DM?
aRtoo
@artoodeeto
May 06 2018 15:34
Help a bro out please
Amit Patel
@AmitP88
May 06 2018 15:43
hey guys, I'm working on making my local weather app responsive (starting from small mobile sizes first). Below is a screenshot at min-width 320px. What do you think of it? Is the design good or do I need to adjust it?
weather-app-mobile.png
K-ream
@K-ream
May 06 2018 15:44
look nice
Amit Patel
@AmitP88
May 06 2018 15:46
@K-ream thank you :) is the text easy to read? I'm a little concerned about readability issues
CamperBot
@camperbot
May 06 2018 15:46
amitp88 sends brownie points to @k-ream :sparkles: :thumbsup: :sparkles:
api offline
K-ream
@K-ream
May 06 2018 15:48
@AmitP88 Nice, soft color
Amit Patel
@AmitP88
May 06 2018 15:48
@K-ream thanks. The background will also change based on the weather conditions
CamperBot
@camperbot
May 06 2018 15:48
amitp88 sends brownie points to @k-ream :sparkles: :thumbsup: :sparkles:
api offline
K-ream
@K-ream
May 06 2018 15:49
@camperbot ?I don't understand what you mean
@AmitP88
That's more interesting.
Amit Patel
@AmitP88
May 06 2018 15:53
@K-ream here's a demo of it: https://amitp88.github.io/Local-Weather-App/ (it doesn't look good at desktop screensize, so you'll have to view it in chrome dev tools mobile view at 320px to see it more together)
K-ream
@K-ream
May 06 2018 15:53
Is he a robot? I'm sorry, I don't know
Amit Patel
@AmitP88
May 06 2018 15:54
yeah, it's the chatbot. Basically just there to distribute brownie points and stuff like that
K-ream
@K-ream
May 06 2018 15:56
Oh, I don't have this thing in my community
My English is not good.
Amit Patel
@AmitP88
May 06 2018 15:57
your English is actually pretty decent
I didn't know what CamperBot was at first, but once you visit this room time again you come to know
K-ream
@K-ream
May 06 2018 15:57
Thank you. I'll study well
Amit Patel
@AmitP88
May 06 2018 15:58
@K-ream How long have you been doing FreeCodeCamp?
K-ream
@K-ream
May 06 2018 15:58
Uh huh, I sleep, I have classes tomorrow, I sleep early.
For two weeks
You should also sleep early
Amit Patel
@AmitP88
May 06 2018 16:00
Sleep? what's that?
it's been so long. I forgotten what that is
aRtoo
@artoodeeto
May 06 2018 16:01
help a bro out please. anyone here?
Amit Patel
@AmitP88
May 06 2018 16:01
@artoodeeto what's up?
K-ream
@K-ream
May 06 2018 16:01
Ha ha, you are really humorous
Amit Patel
@AmitP88
May 06 2018 16:01
lol thank you
aRtoo
@artoodeeto
May 06 2018 16:01
@AmitP88
Amit Patel
@AmitP88
May 06 2018 16:02
@artoodeeto cool thumbnail btw :)
aRtoo
@artoodeeto
May 06 2018 16:02
@AmitP88 so bro i have a problem with my guessing game.
Amit Patel
@AmitP88
May 06 2018 16:04
@artoodeeto damn dude, I took a look at your profile and you're way ahead of me on FCC lol
aRtoo
@artoodeeto
May 06 2018 16:04
if the guess hidden word is abba initially itll look like this - - - - . and if on keyUp user press a it should be like this a - - a now my problem is. when user press b itll re assign my array - b b -
Amit Patel
@AmitP88
May 06 2018 16:04
@artoodeeto I'll give it a shot, but I dunno how much I can help. I'm still very novice at this
aRtoo
@artoodeeto
May 06 2018 16:05
@AmitP88 its ok bro. you might solve this. im not good too. im still struggling
Amit Patel
@AmitP88
May 06 2018 16:05
@artoodeeto lol tbh, the only thing I can think of to possibly solve this is to use if statements :P
aRtoo
@artoodeeto
May 06 2018 16:06
@AmitP88 yea. i have bunch of ifs
Amit Patel
@AmitP88
May 06 2018 16:06
@artoodeeto either that or use a switch if you have a lot of if statements
aRtoo
@artoodeeto
May 06 2018 16:06
@AmitP88 i only have 2
RicardoLFoco
@RicardoLFoco
May 06 2018 16:07

Hey everyone

I am having trouble with the Spinal Tap Case - Algorithm

Amit Patel
@AmitP88
May 06 2018 16:08
@artoodeeto ah ok, then you don't need switch then. Other than if statements, I'm not quite sure what to do
aRtoo
@artoodeeto
May 06 2018 16:09
@AmitP88 my only prblem is the conditioning. its like im missing something. im 1% off. just 1%
RicardoLFoco
@RicardoLFoco
May 06 2018 16:09
function spinalCase(str) {
    console.log(str);
    str = str.split("");

    for (var i = 1; i < str.length; i++) {
            if (str[i] == str[i].toUpperCase()) {
                var lower = " " + str[i].toLowerCase();
                str[i] = lower;
            }
    }
    str = str.join("");

    str = str.replace(/[\s_]/g, "-");
    console.log(str);
    }


  spinalCase('thisIsSpinalTap');
Amit Patel
@AmitP88
May 06 2018 16:09
@artoodeeto lol it's always that last 1% that drives us nuts huh?
RicardoLFoco
@RicardoLFoco
May 06 2018 16:09

This logs:

thisIsSpinalTap
this-is-spinal-tap

This works for that string but for others leaves duplicate dashes

Is there some way that I am missing here? I am trying to account for these cases for where there are no spaces in the str parameter between the words

aRtoo
@artoodeeto
May 06 2018 16:11
@AmitP88 yea bro. i cant sleep. im a wake since 8am yesterday. i wont sleep until i get this. im almost there
1Mher1
@1Mher1
May 06 2018 16:12
please help what my mistake I want to change color when my ball move to other wall https://codepen.io/1Mher1/pen/QrqYjQ
Amit Patel
@AmitP88
May 06 2018 16:13
@artoodeeto hmmm, I dunno. my brain's kinda fried since last night lol. Been at it for like 6+ hours straight
aRtoo
@artoodeeto
May 06 2018 16:16
@AmitP88 cool bro still thanks
CamperBot
@camperbot
May 06 2018 16:16
artoodeeto sends brownie points to @amitp88 :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @amitp88 |http://www.freecodecamp.org/amitp88
Amit Patel
@AmitP88
May 06 2018 16:17
@artoodeeto np. sorry I couldn't be of much help lol
I kinda feel like a zombie right now
aRtoo
@artoodeeto
May 06 2018 16:17
its ok bro
all good
Adel
@AdelMahjoub
May 06 2018 16:54
@1Mher1
this.defaultColor = "lime"
this.hitColor = "red"
this.hit = false
// In the ball draw function
ctx.fillStyle = this.hit ? this.hitColor : this.defaultColor

// Set hit to true on ball vs wall else to false
@1Mher1 the ball is drawn in the canvas you can't target it using jQuery
Adel
@AdelMahjoub
May 06 2018 17:01
@1Mher1 , if you have noticed, the update freeze when an event is triggered in the page when your game loop uses setInterval, a game loop like below will refresh according to the window refresh rate with no more freezes when an event is triggered
function update() {
  ctx.clearRect(0, 0, canvas.width, canvas.height)
  b.update()
  b.draw()
  requestAnimationFrame(update)
}
update()
@1Mher1 if you want your game or animation to be independant of the refresh rate you need to express motions in pixels/seconds, for that you need to calculate the time elapsed between two draws, and multiply your vx and vy by that delta time. Or you can use an animation library which take care of that
1Mher1
@1Mher1
May 06 2018 17:16
but color not change namely i want to randomizing my ball exact object
Adel
@AdelMahjoub
May 06 2018 17:17
@1Mher1 you want a random color or change the ball color when it hits a wall
1Mher1
@1Mher1
May 06 2018 17:17
@AdelMahjoub if(this.y>canvas.height-this.r || this.y < this.r){
this.vy*=-1
$(this).css('background',randomColor());
    }
Adel
@AdelMahjoub
May 06 2018 17:17
@1Mher1 that won't work, the ball is a canvas draw
1Mher1
@1Mher1
May 06 2018 17:18
change the ball's color when it hits a well
Adel
@AdelMahjoub
May 06 2018 17:18
@1Mher1 it don't lay in the DOM, you can't target it using css selector
@1Mher1 use that code above, and in your hit checks, set this.hit to true else to false
@1Mher1 then you can make hitColor random, since ctx.fillStyle can be expressed as rgb string
@1Mher1 you pick a random number for r, g, b between 0 and 255 or anyrange you want, then assign it to ctx.fillStyle
@1Mher1 here a good lib for random colors, https://github.com/davidmerfield/randomColor
@1Mher1 and a good quality tutorial in the same line of what you are writing https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript
1Mher1
@1Mher1
May 06 2018 17:28

@AdelMahjoub https://codepen.io/1Mher1/pen/QrqYjQ
but they d
ont worked again I found ctx.strokeStyle = "rgba(0, 0, 255, 0.5)";

@AdelMahjoub https://codepen.io/1Mher1/pen/QrqYjQ
but they d
ont worked again I found ctx.strokeStyle = "rgba(0, 0, 255, 0.5)";

Adel
@AdelMahjoub
May 06 2018 17:28
@1Mher1 fillStyle, the ball is filled not stroke
@1Mher1 stroke are lines
@1Mher1 in the ball.draw function
ctx.fillStyle = this.hit ? this.hitColor : this.defaultColor
@1Mher1 you can replace this.hitColor with a function that retun a random color
@1Mher1 inside the ball.draw function not in the constructor
1Mher1
@1Mher1
May 06 2018 17:32
hitColor change ctx.fillStyle?
Adel
@AdelMahjoub
May 06 2018 17:43
@1Mher1
image.png
Adel
@AdelMahjoub
May 06 2018 17:58
1Mher1
@1Mher1
May 06 2018 18:01
@AdelMahjoub it should get a random color and keep that color as long as it does not collide with its next wall
@AdelMahjoub in your update you bring when hited red than lime
Adel
@AdelMahjoub
May 06 2018 18:23
@1Mher1 I guess this is what you want https://codepen.io/SultanCodeCamper/pen/odGVGo?editors=0100
anthonygallina1
@anthonygallina1
May 06 2018 21:42

@ezioda004

@anthonygallina1 The new update sucks, anything that uses v8 engine freezes windows and its super annoying.

?
anthonygallina1
@anthonygallina1
May 06 2018 21:49
@ezioda004 thanks I did a fresh install on friends machine because they wanted that fixed. I couldnt after many hours find the prob. So reinstalled. On the fresh one. The prob appeared again in less than a week. I appreciate the link. Takes some of the questions out of my mind.
CamperBot
@camperbot
May 06 2018 21:49
anthonygallina1 sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 552 | @ezioda004 |http://www.freecodecamp.org/ezioda004