These are chat archives for FreeCodeCamp/HelpFrontEnd

15th
Jan 2018
Koderkid1936
@Koderkid1936
Jan 15 2018 00:14
@HeinousTugboat ok I'm conufsed about the slicing bit
Alexander Jarman
@HeinousTugboat
Jan 15 2018 00:15
Alright, what've you got so far?
Koderkid1936
@Koderkid1936
Jan 15 2018 00:16
bare with me gimme like just 2 more mins to figure this out then I'll show you
(one last attempt )
Alexander Jarman
@HeinousTugboat
Jan 15 2018 00:17
Sure sure!
Koderkid1936
@Koderkid1936
Jan 15 2018 00:27
@HeinousTugboat goddamn it
I finally figured it out lol
took me long
here it is
var counter = 0;
var a = "#";

var counterForSlice = -7    


while(counter < 12){
  if(a.length <=7){
      console.log(a);
    a+="#";
  }else{
      var res = a.slice(counterForSlice);
    console.log(res);
    counterForSlice++;

  }

  counter++
}
well needs a bit of adjusting
but I notice what always gets me is putting my results into variables, that always throws me off for some reason
Alexander Jarman
@HeinousTugboat
Jan 15 2018 00:28
Yeah, doesn't actually have an 8-line.
And stops a touch prematurely.
Koderkid1936
@Koderkid1936
Jan 15 2018 00:28
yup I'll fix it now
Alexander Jarman
@HeinousTugboat
Jan 15 2018 00:28
Progress, though!
And yeah, that's what I meant about state.
Koderkid1936
@Koderkid1936
Jan 15 2018 00:28
@HeinousTugboat slow progress :/
@HeinousTugboat aaahhhhhh
notes taken
Alexander Jarman
@HeinousTugboat
Jan 15 2018 00:29
State, as far as I'm familiar, is basically the bits of information that make up the app/algorithm/whatever.
In this case, it's things like "what loop are you on", and "which direction are you going".
Koderkid1936
@Koderkid1936
Jan 15 2018 00:30
it's basically like saving the game or something I dunno how to put it
but my mind is always assuming the programming already knows what state its in lol
Alexander Jarman
@HeinousTugboat
Jan 15 2018 00:30
Saving the game is basically dumping the state of the game to a file so you can reconstitute it later. :-)
See, the programming does. But you need to be able to tell it how to react to that state, and you have to create state where you want it to be.
Koderkid1936
@Koderkid1936
Jan 15 2018 00:31
:notebook: :pencil:
@HeinousTugboat thanks for everything
CamperBot
@camperbot
Jan 15 2018 00:32
koderkid1936 sends brownie points to @heinoustugboat :sparkles: :thumbsup: :sparkles:
api offline
Koderkid1936
@Koderkid1936
Jan 15 2018 00:32
I'm heading off to bed
Alexander Jarman
@HeinousTugboat
Jan 15 2018 00:32
No problem! Good night! Feel free and bug me if you have any questions. Or, of course, ask other people here. :-D
Kim Duclos
@KimberlyDuclos
Jan 15 2018 00:59
Anybody good with Tumblr share buttons? I'm confused on how to load the quote and author text after reading the documentation. It loads the share page but nothing in the text box. https://codepen.io/KimberlyDuclos/pen/XVVEKQ
akosuadenell
@akosuadenell
Jan 15 2018 01:32
im using swift. can someone tell me why this isnt working? the function should check if the string starts with a vowel.
_
Screen Shot 2018-01-14 at 8.29.38 PM.png
VaseJS
@VaseJS
Jan 15 2018 02:06
@akosuadenell i don’t know swift but it looks like you are attempting to use a regEx without using a regEx.
Ayush Bahuguna
@relentless-coder
Jan 15 2018 02:07
Hey, I need some help here. I was browsing the gsap library, and I came across this example, can anyone tell the concept behind this scroll?
http://www.yebocreative.com/en/hey/
how are they able to show different sections as if the page is being scrolled?
VaseJS
@VaseJS
Jan 15 2018 02:09
@relentless-coder that’s a css thing. with js, and the browser api, you can know the scroll location. the technique is called parallax
why isn't anything showing up after I added the constructor? Help pl0x
Ayush Bahuguna
@relentless-coder
Jan 15 2018 02:48
@VikrantSingh13 kindly refer to the error that's popping up on your pen
Stephen James
@sjames1958gm
Jan 15 2018 02:48
@VikrantSingh13 There is a red circle with ! in it that tells you where the error is.
You have to change the syntax on your render function
Ayush Bahuguna
@relentless-coder
Jan 15 2018 02:48
@VikrantSingh13 should be render() instead of render: function()
Vikrant Singh
@VikrantSingh13
Jan 15 2018 02:49
@sjames1958gm @relentless-coder thanks got it, there were no error showing up for me oddly
CamperBot
@camperbot
Jan 15 2018 02:49
vikrantsingh13 sends brownie points to @sjames1958gm and @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 383 | @relentless-coder |http://www.freecodecamp.org/relentless-coder
:star2: 8857 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Jan 15 2018 02:49
@VikrantSingh13 :+1:
Vikrant Singh
@VikrantSingh13
Jan 15 2018 02:50
do you people know any updated react tutorial or courses I can learn from?
already did that a bit more advanced please
Vikrant Singh
@VikrantSingh13
Jan 15 2018 02:55
are we still using redux?
Vikrant Singh
@VikrantSingh13
Jan 15 2018 04:03
almost done with this. getting the error "this.setState is not a function" What am I missing here?
https://codepen.io/vikrantsingh13/pen/eGGgGR
Claudio Restifo
@Marmiz
Jan 15 2018 04:10
@VikrantSingh13 are you binding the this context?

no you are not. The this context of the callback is in a different context... you need to bind it to have an access inside the callback...

also setState is a function: this.setState()

Vikrant Singh
@VikrantSingh13
Jan 15 2018 04:14
@Marmiz ay got it thanks
CamperBot
@camperbot
Jan 15 2018 04:14
vikrantsingh13 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1125 | @marmiz |http://www.freecodecamp.org/marmiz
Claudio Restifo
@Marmiz
Jan 15 2018 04:24
:+1:

@VikrantSingh13 personal suggestion: start using ES6 syntax, makes everything easier.

instead of manually binding, for example you can use arrow function that does not bind the context.

addMarkup = (e) => this.setState({...})
Vikrant Singh
@VikrantSingh13
Jan 15 2018 04:31
@Marmiz okay so it works so far, however how I do call the rawMarkup function after I have added stuff to the markdown section?
** do I
Claudio Restifo
@Marmiz
Jan 15 2018 04:34

setState
accept also a callback function:

setState(updater[, callback])

So you could call your markup function after setState is done updating the values.

Or you could for example set the inner markup with
dangerously setinnerhtml
aRtoo
@artoodeeto
Jan 15 2018 07:36

hello guys im doin my tictactoe but on this part of the code is not working

function checkGame() {

    //loops thru the winCombo array of arrays
    for (var i=0; i<winCombo.length; i++) {
        for (var j=0; j<winCombo[i].length; j++) {
            //takes the values or text of the cells 
            var uno = document.getElementById(winCombo[i][0]).textContent;
            var dos = document.getElementById(winCombo[i][1]).textContent;
            var tres = document.getElementById(winCombo[i][2]).textContent;

            //if theres no text on each cells
            if (uno === '' && dos === '' && tres === '') {
                break;
            } 
            //checks if the variables have the same text value
            else if (uno === dos && uno === tres) {
                  //if true remove the eventlistener then alart a winner
                  console.log('this will show if the condtion is true but loop is not working');  
                  for(var c=0; c<cells.length; c++) 
                    {  
                        cells[c].removeEventListener('click', function(){
                            alert('shit!!!!')
                        });
                    }
            }
        }
    }
}

but the console.log is show and the for loop to remove the event is not working.
heres the pen https://codepen.io/artoo/pen/Zvomxr

nevermind i got it now. thanks
Joshua Frias
@Juke-Magic
Jan 15 2018 07:45
guys
how do you <br> in javascript
???
Claudio Restifo
@Marmiz
Jan 15 2018 07:58
what do you mean?
Xapuu
@Xapuu
Jan 15 2018 08:00
@Juke-Magic you dont <br> in javascript you <br> in html in javscript if you want to split a string to a new line , you must put \n inside the string.
Muhammed Hafiz
@zifahm
Jan 15 2018 08:20

Send Action Data to the store (Redux FCC Beta)

 const ADD_NOTE = 'ADD_NOTE';

const notesReducer = (state = 'Initial State', action) => {
switch(action.type) {
// change code below this line
case ADD_NOTE:
return action.text
// change code above this line
default:
return state;
}
};

const addNoteText = (note) => {
// change code below this line
type:ADD_NOTE,
text:note
// change code above this line
};

const store = Redux.createStore(notesReducer);

console.log(store.getState());
store.dispatch(addNoteText('Hello!'));
console.log(store.getState());

when i check the console i get the error saying unexpected token near text:note (addnoteText function)
no objective gets ticked

Muhammed Hafiz
@zifahm
Jan 15 2018 08:32
anybody?
Claudio Restifo
@Marmiz
Jan 15 2018 08:33
@zifahm actions should return plain object... your addNote is not returning anything.
Mind that the curly will be evaluated as body function in your arrow function
Muhammed Hafiz
@zifahm
Jan 15 2018 08:37
ohh thanks
@Marmiz how do i update the state in the case ADD_NOTE
Claudio Restifo
@Marmiz
Jan 15 2018 08:40
@zifahm what's your goal?
Muhammed Hafiz
@zifahm
Jan 15 2018 08:40
@Marmiz You need to add a case that handles the addNoteText() actions. This case should be triggered whenever there is an action of type ADD_NOTE and it should return the text property on the incoming action as the new state.
ohh wait it worked
Claudio Restifo
@Marmiz
Jan 15 2018 08:41
then returning the action text seems correct
have you fixed your action creator?
Muhammed Hafiz
@zifahm
Jan 15 2018 08:42
@Marmiz thank you so much
Claudio Restifo
@Marmiz
Jan 15 2018 08:42
:+1:
Ghost
@ghost~5a4a80acd73408ce4f859755
Jan 15 2018 08:44
Salaam bros, hey guys
I have an idea to make a certain webpage but don't know how to do it, anyone willing to give support?
ChristianLLewis
@ChristianLLewis
Jan 15 2018 09:15
Anyone here used Algolia?
Olga
@OStefani
Jan 15 2018 09:55
hi there! I am not sure where to ask for help. I am learning React on beta FCC. And I can't pass a task React: Add Event Listeners
Here is my code class MyComponent extends React.Component { constructor(props) { super(props); this.state = { message: '' }; this.handleEnter = this.handleEnter.bind(this); this.handleKeyPress = this.handleKeyPress.bind(this); } // change code below this line componentDidMount() { document.addEventListener('keypress', this.handleKeyPress); } componentWillUnmount() { document.removeEventListener('keypress', this.handleKeyPress); } // change code above this line handleEnter() { this.setState({ message: this.state.message + 'You pressed the enter key! ' }); } handleKeyPress(event) { if (event.keyCode === 13) { this.handleEnter(); } } render() { return ( <div> <h1>{this.state.message}</h1> </div> ); } };
What is wrong with it?
Fabien SHAN
@X140hu4
Jan 15 2018 09:57
Can you give the link?
Claudio Restifo
@Marmiz
Jan 15 2018 10:08
I thinks it wants a keydown event, not a keypress
Olga
@OStefani
Jan 15 2018 10:09
@Marmiz exactly! Thanks
CamperBot
@camperbot
Jan 15 2018 10:09
ostefani sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1127 | @marmiz |http://www.freecodecamp.org/marmiz
abraham anak agung
@padunk
Jan 15 2018 10:14
@Marmiz Hi, sorry to bother you but do you know about service-worker?
Claudio Restifo
@Marmiz
Jan 15 2018 10:32
@padunk not really, I just used one in a prject, but I created it with webpack so I cannot really help
abraham anak agung
@padunk
Jan 15 2018 10:34
@Marmiz OK. No problem, i just started learning it. Thks
Varian
@everyonelovesrice
Jan 15 2018 11:29
Hello everyone~
Stephen James
@sjames1958gm
Jan 15 2018 11:33
@everyonelovesrice hello
primuscovenant
@primuscovenant
Jan 15 2018 11:53
@heroiczero thx
CamperBot
@camperbot
Jan 15 2018 11:53
primuscovenant sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2137 | @heroiczero |http://www.freecodecamp.org/heroiczero
Aditya
@ezioda004
Jan 15 2018 12:06
Is the person above me and CamperBot a bot? He sends the same "thx" message to the same person around this time everyday.
Aditya
@ezioda004
Jan 15 2018 12:27
mstellaluna
@mstellaluna
Jan 15 2018 12:50
Yes, camperbot is a bot that belongs to FreeCodeCamp. He gives points (aka cookies/brownies) when thanking people when they are mentioned.
Markus Kiili
@Masd925
Jan 15 2018 12:52
@ezioda004 Most likely he is just thanking both times for some help he got earlier. Happens very often here.
Javier Pons
@JavierPons
Jan 15 2018 12:54
hi all

```<html lang="de">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="style/bootstrap.min.css">

<!-- css custom -->
<link rel="stylesheet" href="style/main.css">

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
 <script>

 $(document).ready(function() {
$(".sympa").fadeIn(4800).removeClass('hidden');

});

</script>  

```

why the js code doesn't work? The text it should appear in few to few.
This time I have been using bootstrap 4 and doesn't work at all. Before the page and code it was exactly the same and it works
nothing solve
Aditya
@ezioda004
Jan 15 2018 13:04
@mstellaluna Not talking about CamperBot, I'm talking about @primuscovenant . Look at this :point_up: January 14, 2018 4:11 PM, :point_up: January 13, 2018 5:07 PM, :point_up: January 11, 2018 10:38 AM, :point_up: January 10, 2018 3:09 PM, :point_up: January 9, 2018 6:01 PM.
@Masd925 I suppose but, I've just noticed he does this everyday not just this time.
mstellaluna
@mstellaluna
Jan 15 2018 13:05
@ezioda004 I will look into it. thanks. bots aside from camperbot are not allowed in the FCC rooms.
CamperBot
@camperbot
Jan 15 2018 13:05
mstellaluna sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 386 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Aditya
@ezioda004
Jan 15 2018 13:06
@mstellaluna :thumbsup:
Roman Struna
@RomchyFCC
Jan 15 2018 13:18
@ezioda004 @mstellaluna I think i know why he does it, might be because of the streak, he's trying to keep alive, 1 item each day, if cookies are counted as an item on FCC thats why this is being done...dunno if it matters much though :)
Gersho
@Gersho
Jan 15 2018 13:20
the issue is not cookie trading, it happens in most room, the issue is finding if he is a bot
Roman Struna
@RomchyFCC
Jan 15 2018 13:20
yea thats why i said, dunno if it matters much, though being new to this i like a riddle, there is always a why :)
Gersho
@Gersho
Jan 15 2018 13:22
i don't think it matters, i'm more concerned about the plans to merge rooms or the fact the chat is hard to find for newcomers
Aditya
@ezioda004
Jan 15 2018 13:23
It's interesting to see what people do to keep them green squares glowing everyday.
Gersho
@Gersho
Jan 15 2018 13:24
well once you're considered a regular people give you cookie for no reason so there's that
also since it's not as the same hour everyday, isn't the guy simply multiboxing ? (assuming it's not just someone giving him cookies the normal way)
Aditya
@ezioda004
Jan 15 2018 13:26
Prob want to keep the streak alive, without coming to glitter
Thats possible too..but the same message is a pattern so idk, or if hes a person then not a smart one, atleast vary your message
Gersho
@Gersho
Jan 15 2018 13:27
lol
i'm more worried about my github streak
on that note time to upload one of my challenges xD
VaseJS
@VaseJS
Jan 15 2018 13:28
gamification at its best again hacking the minds of the unexpecting
Aditya
@ezioda004
Jan 15 2018 13:28
Lol I figured that out, the fcc projects Im working on Im committing as I do so its keeping the streak alive
Gersho
@Gersho
Jan 15 2018 13:28
yeah, i put one of my old challenge once a day
but i'll run out soon
Aditya
@ezioda004
Jan 15 2018 13:29
Then maybe revist some of the old projects and add more features? Maybe make code more readable, add comments and stuff
Gersho
@Gersho
Jan 15 2018 13:30
haha
Aditya
@ezioda004
Jan 15 2018 13:30
git commit -m "Added 2 comments"
Gersho
@Gersho
Jan 15 2018 13:30
i'll try doing actual work, doesn't hurt once in a while ^^
mstellaluna
@mstellaluna
Jan 15 2018 13:30
@RomchyFCC yea the account was banned from the room
Gersho
@Gersho
Jan 15 2018 13:30
happy with the ban hammer eh ?
mstellaluna
@mstellaluna
Jan 15 2018 13:30
bots aren't allowed in any FCC room unless you have permission from FCC
Aditya
@ezioda004
Jan 15 2018 13:31
Who? The person hes sending cookies to?
Roman Struna
@RomchyFCC
Jan 15 2018 13:32
cool beans, good to know if i ever develop a bot(small chance :D)
Ken Haduch
@khaduch
Jan 15 2018 13:35
@JavierPons - re: :point_up: January 15, 2018 7:54 AM - It's hard to see with the way that the code is posted but I don't see the body and the element that has the class sympa on it? If you can repost your code with the three backticks ``` on separate lines before and after the code it would make it easier to see, and also keep any code that might have been in there from being interpreted by the gitter page?
LydaTech
@lydatech
Jan 15 2018 13:40
LOL streaks and brownie points!
Kim Duclos
@KimberlyDuclos
Jan 15 2018 16:41
Hi, does anybody know how to make the correct link for a Tumblr share with quote content? I'm using this and it's not working: https://www.tumblr.com/share/tool?data-content=' and I'm kind of confused how to do it going by this documentation : https://www.tumblr.com/docs/en/share_button
Roman Struna
@RomchyFCC
Jan 15 2018 16:51
Question for all beginners and experienced alike: The navigation in the default CSS. How do you make the navigation bar, do you use floats or text-align?
Gersho
@Gersho
Jan 15 2018 16:54

i use

nav{
  position: fixed;
  z-index: 2;
}

but i'm really bad at CSS so i'll suggest you ask for more opinions ^^

Roman Struna
@RomchyFCC
Jan 15 2018 16:55
it's mostly out of curiousity, you've definetly sparked it
but with you method, how do you push other elements down when you aren't scrolled a bit further down the page
i assume the nav covers up some of the web page
Gersho
@Gersho
Jan 15 2018 16:56
it does
well, like if you -really- want to know
https://codepen.io/Gersho/pen/gmgPBG?editors=1100
but fair warning, it's bad
.airbag {
  height: 60px;
}
/shame
Roman Struna
@RomchyFCC
Jan 15 2018 16:57
hahahah
oh wait that one uses js
you can do it with just css
Roman Struna
@RomchyFCC
Jan 15 2018 16:58
when i get serious about my web page, i make my navbar hidden but it appears when you mouse over the top of the page no matter how much you're scrolled down
i was just wondering with basic CSS what people use
maybe some hidden rendering times are better or something :)
@Gersho it looks fine, i like the design it's a bit wierd at first but you get used to it :D
Gersho
@Gersho
Jan 15 2018 17:01
i have design issues yes, still haven't done my portfolio, but i don't want to copy
Roman Struna
@RomchyFCC
Jan 15 2018 17:02
and you shouldn't probably, it should show your style and your character IMO
Gersho
@Gersho
Jan 15 2018 17:02
my character hopefully, my style i hope not xD
Roman Struna
@RomchyFCC
Jan 15 2018 17:03
:$ oh my i just read your welcome text hahaha highlight of my day
Gersho
@Gersho
Jan 15 2018 17:03
i started it that way thinking about those folders with colored separations you have in real life (don't know what it's called)
like those things
Roman Struna
@RomchyFCC
Jan 15 2018 17:04
:D so planning on adding more then i assume. My life A-Z in a nav bar :D jkjk
Gersho
@Gersho
Jan 15 2018 17:05
don't really have plans yet, but adding more is easy yes
harder part will be picking the colors
Roman Struna
@RomchyFCC
Jan 15 2018 17:05
you can just repeat them like in the photo :)
Gersho
@Gersho
Jan 15 2018 17:07
oh
thanks @RomchyFCC
CamperBot
@camperbot
Jan 15 2018 17:07
gersho sends brownie points to @romchyfcc :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @romchyfcc |http://www.freecodecamp.org/romchyfcc
Olga
@OStefani
Jan 15 2018 18:20
hi, I am doing this task
https://beta.freecodecamp.org/en/challenges/react/optimize-rerenders-with-shouldcomponentupdate
here is my solution, it works, but system doesn't accept it. What is wrong?
https://codepen.io/OStefani/pen/ppZQZN?editors=0011
Kaz Baig
@kbaig
Jan 15 2018 18:25
@OStefani probably a bug with the exervise
Olga
@OStefani
Jan 15 2018 18:25
@kbaig what do you mean?
tests?
Kaz Baig
@kbaig
Jan 15 2018 18:43
@OStefani yeah i think your solution is right
jjzep
@jjzep
Jan 15 2018 18:47
So I’m writing a program with ES6 syntax, and I want to make a counter to keep track of a turn count. Any reason not to make this available in the global scope?
Olga
@OStefani
Jan 15 2018 18:49
@jjzep that is just a good practice to not use a global scope.
jjzep
@jjzep
Jan 15 2018 18:49
I suppose I could define the default value in a constructor and iterate that
Pranav Bhaskar
@CoderPrans
Jan 15 2018 19:07
I am trying to use a variable inside a regular expression.
var regex = new RegExp(/repeated[0]{2,}|repeated[1]{2,}/, 'gi');
where repeated is "ab"
Stephen James
@sjames1958gm
Jan 15 2018 19:08
@CoderPrans /repeated[0]{2,}|repeated[1]{2,}/ this is a regex, try passing a string to RegExp()
Pranav Bhaskar
@CoderPrans
Jan 15 2018 19:09
@sjames1958gm like "repeated[0]{2,}|repeated[1]{2,}"
Stephen James
@sjames1958gm
Jan 15 2018 19:09
@CoderPrans Yes
Pranav Bhaskar
@CoderPrans
Jan 15 2018 19:10
stil not working..
Stephen James
@sjames1958gm
Jan 15 2018 19:10
@CoderPrans Oh, you need to get the value of the variable into the string not the variable name, my bad
repeated + "[0][{2,}|" + repeated + "[0][{2,}"
maybe like this
Pranav Bhaskar
@CoderPrans
Jan 15 2018 19:20
var regex = new RegExp(repeated + "[0]{2,}|" + repeated + "[0]{2,}", 'gi'); permute.forEach(function(x){
var y = x.replace(regex, '');
revised.push(y);
}); // still not working
@sjames1958gm

var ist = repeated[0];
var znd = repeated[1];

var regex = new RegExp(ist + "{2,}|" + znd + "{2,}", 'gi');

this worked thanks @sjames1958gm
CamperBot
@camperbot
Jan 15 2018 19:23
coderprans sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8859 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Olga
@OStefani
Jan 15 2018 19:37
@kbaig yes, I found an issue on github, thanks
CamperBot
@camperbot
Jan 15 2018 19:37
ostefani sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 526 | @kbaig |http://www.freecodecamp.org/kbaig
Stephen James
@sjames1958gm
Jan 15 2018 19:40
:+1:
Pranav Bhaskar
@CoderPrans
Jan 15 2018 19:48

`
function permAlone(str) {

var repeated = str.split('').filter(function(item, i, ar){ return ar.indexOf(item) !== i; }).join('');

var ist = repeated[0];
var znd = repeated[1];

var regex = new RegExp(ist + "{2,}|" + znd + "{2,}", 'gi');

var perm = function(xs){
var ret=[];
for(var i=0;i<xs.length;i++){
var rest = perm(xs.slice(0,i).concat(xs.slice(i+1)));
if(!rest.length){
ret.push([xs[i]]);
}else{
for(var j=0;j<rest.length;j=j+1){
ret.push([xs[i]].concat(rest[j]));}
}
}
return ret;
};

var permute = [];

for(var i in perm(str)){
var z = perm(str)[i].join('');
permute.push(z);
}

var revised = [];
permute.forEach(function(x){
var y = x.replace(regex, '');
revised.push(y);
});

var result = revised.filter(function(x){ return x.length == str.length; });

return perm(str);
}

permAlone('abfdefa');
`
it works for almost all of them but for this str above it says potential infinite loop at line 28, where i push joined strings into permute. . why would it not work ..

cjlynch12
@cjlynch12
Jan 15 2018 19:54
hey all, can anyone help me out with the "React and Redux: Extract Local State into Redux"(https://beta.freecodecamp.org/en/challenges/react-and-redux/extract-local-state-into-redux) challenge? I keep getting an error when trying to pass in submitMessage() { this.setState({ input: '' }); this.props.dispatch(submitNewMessage(this.state.input)); } for my method - the error I'm getting is "submitNewMessage is not defined"
Pranav Bhaskar
@CoderPrans
Jan 15 2018 20:01
got it, had to do var permi = perm(str); and use permi instead, but i dont understand why the previous one did not work.
cjlynch12
@cjlynch12
Jan 15 2018 20:25
@cjlynch12 figured it out - if anyone else has trouble down the line the submitMessage method should look like this:
submitMessage() { this.setState({input: ''}); this.props.submitNewMessage(this.state.input)); }
alpox
@alpox
Jan 15 2018 20:42
@cjlynch12 Just to extend on why this is: you already do the dispatch of the action inside of submitNewMessage: dispatch(addMessage(message))
So the submitNewMessage function fully triggers the action already, without having to connect it to the store through dispatch anymore
Joseph A. Sangine
@HTML-joe
Jan 15 2018 21:41
Can someone help me out here
consol is logging the ajax data as undefined when i test it
Kaz Baig
@kbaig
Jan 15 2018 21:43
@HTML-joe all I see is url not defined whenever I click the input
Joseph A. Sangine
@HTML-joe
Jan 15 2018 21:46
yes that is the issue
Kaz Baig
@kbaig
Jan 15 2018 21:47
you didnt define a variable called url
Joseph A. Sangine
@HTML-joe
Jan 15 2018 21:48
ah yes my bad
now I have a new error
alpox
@alpox
Jan 15 2018 21:55
@HTML-joe You have to get the value from the input field, not from the form
Joseph A. Sangine
@HTML-joe
Jan 15 2018 21:55
thank you @alpox
CamperBot
@camperbot
Jan 15 2018 21:55
html-joe sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1521 | @alpox |http://www.freecodecamp.org/alpox
Joseph A. Sangine
@HTML-joe
Jan 15 2018 21:57
now to figure out how to display everything
Engjell Bislimi
@Engjell00
Jan 15 2018 22:18
hello guys, I have a simple question on atom or sublime text 3 is there a shortcut I can use to write the html head body in one shot? Usually I did it but i forgot thanks.
Mark Pearyer
@marcusp619
Jan 15 2018 22:19
@Engjell00 emmet plugin or a code snippet plugin should do the trick
Engjell Bislimi
@Engjell00
Jan 15 2018 22:19
well before i could do it without even downloading something else
Mark Pearyer
@marcusp619
Jan 15 2018 22:20
did you save the document
before trying
Engjell Bislimi
@Engjell00
Jan 15 2018 22:23
lol you just killed me
thanks
Stephen James
@sjames1958gm
Jan 15 2018 22:23
@Engjell00 did you try typing html then tab?
Mark Pearyer
@marcusp619
Jan 15 2018 22:24
@Engjell00 which one was it?
Engjell Bislimi
@Engjell00
Jan 15 2018 22:24
Yes that works
html then tab
but before that
saving it
Mark Pearyer
@marcusp619
Jan 15 2018 22:24
i do it all the time lol
Engjell Bislimi
@Engjell00
Jan 15 2018 22:25
thanks @sjames1958gm @marcusp619
CamperBot
@camperbot
Jan 15 2018 22:25
engjell00 sends brownie points to @sjames1958gm and @marcusp619 :sparkles: :thumbsup: :sparkles:
:cookie: 394 | @marcusp619 |http://www.freecodecamp.org/marcusp619
:star2: 8860 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Daniel Feldman
@Feldbot
Jan 15 2018 22:43
Hi, can anyone help me with this challenge? I'm not understanding how to generate a Fibonacci sequence.
Tom
@moT01
Jan 15 2018 22:51
@Feldbot what part of it arent you understanding?
Aditya
@ezioda004
Jan 15 2018 22:53
@Feldbot In Fibonacci sequence every number is sum of previous two. Example the first 5 numbers in sequence are: 1, 1, 2, 3, 5. As you can see 1+1 = 2, 1+2 = 3, 2+3=5 and so on. So say you define x = 1 and y = 1, you can guess the fibonacci sequence by doing z = x + y. Now the next number would be sum of previous two numbers ie y + z so all you need to do is assign them to each others.
Daniel Feldman
@Feldbot
Jan 15 2018 22:55
@ezioda004 @moT01 @marcusp619 Thanks, I'll try Aditya's suggestion. I was wondering if I needed to create two variables set to one to start, and it looks like I do. I'll work with that for a bit and see if I can come up with something. Thanks!
CamperBot
@camperbot
Jan 15 2018 22:55
feldbot sends brownie points to @ezioda004 and @mot01 and @marcusp619 :sparkles: :thumbsup: :sparkles:
:cookie: 388 | @ezioda004 |http://www.freecodecamp.org/ezioda004
:cookie: 395 | @marcusp619 |http://www.freecodecamp.org/marcusp619
:cookie: 960 | @mot01 |http://www.freecodecamp.org/mot01
Mark Pearyer
@marcusp619
Jan 15 2018 22:58
@Feldbot okay first i checked if the parameter
was equal to 1 if so return [0]
then in the body of the func
i made a var = to the func(parameter -1)
ugh its hard to explain lol
trying to give you steps without giving you the answer
mauriciodeleonc
@mauriciodeleonc
Jan 15 2018 23:14
Hii could anyone help me with this challenge please?
function rot13(str) { // LBH QVQ VG!
  str = str.split("");
  var i;

for (i = 0; i < str.length; i++) {
    str[i] = str[i].toString().charCodeAt(0) - 13;
    str[i] = String.fromCharCode(str[i]);
  }
  return str.join("");
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
the result should be "FREE CODE CAMP" but im getting "F8EE C5DE CAM6"
Aditya
@ezioda004
Jan 15 2018 23:22
@mauriciodeleonc Thats because theres another condition, look at rot13 documentation, alphabets before "M" needs to be converted to .charCodeAt(0) + 13
mauriciodeleonc
@mauriciodeleonc
Jan 15 2018 23:23
ooohh okay okay, thanks @ezioda004
CamperBot
@camperbot
Jan 15 2018 23:23
mauriciodeleonc sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @ezioda004 |http://www.freecodecamp.org/ezioda004