These are chat archives for FreeCodeCamp/HelpFrontEnd

20th
Apr 2018
zootechdrum
@zootechdrum
Apr 20 2018 00:00
hey guy I am working on the roman numeral challenge. I feel like I am on the right track but the way its headed does not seem very dry. How should I continue to approach this?
function convertToRoman(num) {
 var digits = [];
 var thousand = ["I","II","III","IV"];
 var number = [1,2,3,4];
 var answer = [];

  while (num > 0) {
    digits[digits.length] = num % 10;
    num = parseInt(num / 10);
  }

  digits.reverse();

  if(digits.length === 4){
    for(var i = 0; i < number.length; i++){
      if(digits[i]){
        answer.push(thousand[number.indexOf(digits[i])]);

      }
    }  
  }
  return answer;

}


convertToRoman(3212);
Stephen James
@sjames1958gm
Apr 20 2018 00:13
@zootechdrum I would consider how you would convert a value to roman.
You would look at the number
if > 1000 then write M and subtract 1000
And do this for various values.
you could put these various values into parallel arrays
var numeric = [1000, 900, 500, 400, ...]
var roman = ['M', 'CM', D, CD, ...]
while the number is greater than the value in numeric add the value in roman and subtract
Daniel
@DanJP2016
Apr 20 2018 01:10
completed the simon project, I think I fixed all the bugs. any feedback is welcome or if a bug is found please let me know. thanks.
https://codepen.io/bones211/pen/LdmyrW?editors=0010
Zack
@indiegameguy
Apr 20 2018 01:29
Quick question. Coming back to FCC from a long hiatus. What happened to the general chat room? Not finding it.
hensn5250
@hensn5250
Apr 20 2018 01:30
@DanJP2016 Cool design. Checking out the functionality. If possible I would suggest changing that audio sound to something less sharp. On my cpu it sounds a bit irritating.
Daniel
@DanJP2016
Apr 20 2018 01:45
@hensn5250 thanks for the feedback, i'll look into changing the sounds. is it too loud or just a bad tone in general?
CamperBot
@camperbot
Apr 20 2018 01:45
danjp2016 sends brownie points to @hensn5250 :sparkles: :thumbsup: :sparkles:
:cookie: 331 | @hensn5250 |http://www.freecodecamp.org/hensn5250
Daniel
@DanJP2016
Apr 20 2018 01:46
@indiegameguy they deleted that room sometime last week i believe. not sure why though.
hensn5250
@hensn5250
Apr 20 2018 01:46
@DanJP2016 I sounds like a combination of both loudness and sharpness
Daniel
@DanJP2016
Apr 20 2018 01:49
@hensn5250 I will dig through this web audio api and mess around with it and try to smooth it out.
zootechdrum
@zootechdrum
Apr 20 2018 01:51
@sjames1958gm going to read this 100 times again
hensn5250
@hensn5250
Apr 20 2018 01:51
@DanJP2016 also ask others as well before making the change. There is a chance it may just be my computer.
zootechdrum
@zootechdrum
Apr 20 2018 02:13
@sjames1958gm Holy mother of god was that hard.
Thank you James
I figure it out
function convertToRoman(num) {

  var romanNum = ["MMM","MM","M","CM","DCCC","DCC","DC","D","CD","CCC","CC","C","XC","LXXX","LXX","LX","L","XL","XXX","XX","X","IX","VIII","VII","VI","V","IV","III","II","I"];
  var number = [3000,2000,1000,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1];
  var answer = [];


for(var i = 0; i<number.length; i++){
  if(num >= number[i]){
     answer.push(romanNum[i]);
     num = num - number[i];
  }
}

  return answer.join("");


}

convertToRoman(12);
Anthony Contreras
@AmazeCPK
Apr 20 2018 02:57
Hello, I'm trying to find a way to align the last item of this flex object to the left
image.png
the parent is set to justify-content: center. I'm not sure how to proceed here.
roxxlen
@roxxlen
Apr 20 2018 03:03
justify-content: flex-start
Anthony Contreras
@AmazeCPK
Apr 20 2018 03:04
I only want to move the last item, not any of the other ones.
and flex-start would move it all the way to the left of the page, not to the left of the centered items
roxxlen
@roxxlen
Apr 20 2018 03:08
maybe align-self?
Anthony Contreras
@AmazeCPK
Apr 20 2018 03:12
align-self is for vertical alignment, not horizontal. I may be able to set the :last-child object to a flex item, flex direction to column, and then finally align-self, but then I would reach a simmilar problem, whree it will be aligned to the left of the parent container, not to the 'centered left ' of the other items.
Honestly looks like I'm going to have to hack it to get it to work correctly
Anthony Contreras
@AmazeCPK
Apr 20 2018 03:22
got it.
roxxlen
@roxxlen
Apr 20 2018 03:22
how
Anthony Contreras
@AmazeCPK
Apr 20 2018 03:22
added another element with the same width of the previous if there is an odd number of elements
using Vue so looks like this:
<div v-for="(contest, index) in contests" :key="contest.id" >
    <appContestSingle :contest="contest"></appContestSingle>
    <hr v-if="index !== (contests.length-1) && contests.length%2 == 1">
</div>
<div class="extra" v-if="contests.length%2==1"></div>
roxxlen
@roxxlen
Apr 20 2018 03:35
ah... not famaliar with vue, but got a notion for this solution
Anthony Contreras
@AmazeCPK
Apr 20 2018 03:36
yeah, vue isn't required for my solution. I'm sure you could do some math in CSS to set display:none on the :last-child if the total number of n-childs are an odd number.
but I am not a CSS guru, so I'll leave it to Vue :)
Claudio Restifo
@Marmiz
Apr 20 2018 04:01
@AmazeCPK you can dynamically assign classes with Vue, so you can add a specific class for the last element for instance :)
Anthony Contreras
@AmazeCPK
Apr 20 2018 04:04
@Marmiz Didn't think of that. That would work as well!
Something like <div :class="{'extra' : contests.length%2==1}"
Claudio Restifo
@Marmiz
Apr 20 2018 04:30
@AmazeCPK pretty much what I had in mind :smile: :+1: :fire:
you can use arrays with conditions inside in case you want to add a class to all, and a second one only to a specific one.
almost like mixing in sass/less
coderNewby
@coderNewby
Apr 20 2018 04:38
@DarrenfJ once again thanks for the tip
CamperBot
@camperbot
Apr 20 2018 04:38
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2468 | @darrenfj |http://www.freecodecamp.org/darrenfj
Botenga
@Botenga
Apr 20 2018 06:24

https://codepen.io/Botenga/pen/QrbjZq

hey guys im stuck in trying to align these text boxes with there label. Most of the text boxes in this form are mis-aligned. Any idea why that is?

Daniel T.
@danideicide2_twitter
Apr 20 2018 06:26

Hi! I am trying to do a css animation, but have some issues. I am trying to make an animation so that when I hover over the card, the yellow background get into place nicely and then text appear. You can see my codepen right here: https://codepen.io/danideicide/pen/Qrbjpp

Is there anyone here willing to help me? Thanks!

Claudio Restifo
@Marmiz
Apr 20 2018 06:54
@danideicide2_twitter are you willing to use a little bit of Javascript? Because you can add an event listener on end animation, to which you use to make the second one start
Daniel T.
@danideicide2_twitter
Apr 20 2018 06:57
@Marmiz Thanks! Let me give it a try
CamperBot
@camperbot
Apr 20 2018 06:57
danideicide2_twitter sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1212 | @marmiz |http://www.freecodecamp.org/marmiz
Claudio Restifo
@Marmiz
Apr 20 2018 07:00
@danideicide2_twitter :+1: gl
Aita Kane
@aita-kane
Apr 20 2018 07:32

Hello guys I'm a newbie in PHP and have an assignment due in the afternoon.
Actually i have to create a store that use a session array to retrieve data input in a form, and display it . But the shopping cart has to be built with MVC.
So here is a little details of the assignement:
in the first place we have only a navbar that appears where there is two link ( both are dropdowns menu): Order and Product
When you click on ORDER the dropdown menu appears and you can read "Create" and "List" .
When you click on PRODUCT the dropdown menu appears and you can read "Create".

When you click on " Create" from the PRODUCT 's DROPDOWN you are redirect to a new page. On this new page there is a form where you can input the reference, name, price and quantity of the product you want to add and there is a save button too.
When you click on save the informations are save in a array stored in data.php. Naturally before they get stored the information input have to check if they are valid first.

When you click on " Create" from theORDER 's DROPDOWN, there is a form with two buttons that appears in the same page where you can input information about your order. And when you click on "ADD", a table appear in which you can read the order you entered . when you click on "Save", the informations are save in a array "product" stored in data.php.

When you click on " List" from the ORDER 's DROPDOWN you are redirect to a new page. On this new page there is a table where you can see the list of your order the reference, name, price and quantity of the product you want to add and there is a save button too.
And in each row there is a Details button. When you click on it an other table appears where you can see the elements ordered in that day and the Total

And i need help to know how to start this MVC model in the best way possible. All help appreciated and thanks for everything.

anthonygallina1
@anthonygallina1
Apr 20 2018 07:36
:wave:
Aita Kane
@aita-kane
Apr 20 2018 07:37
@anthonygallina1 hi , how are you
anthonygallina1
@anthonygallina1
Apr 20 2018 07:38
tired long day doing css
Aita Kane
@aita-kane
Apr 20 2018 07:39
coding can be fun and exhausting at the same time, feelings shared tired trying to understand MVC model in PHP
anthonygallina1
@anthonygallina1
Apr 20 2018 07:39
linter and tidy dont play well with BS4 especially since i have a BS3 linter
lol
@aita-kane What linter do you use?
Aita Kane
@aita-kane
Apr 20 2018 07:40
@anthonygallina1 i'm newbie in the coding world .. what is a linter ?
Aita Kane
@aita-kane
Apr 20 2018 07:43
i'm using visual code and i'm trying to do a MVC in php for a shoppping cart without database
anthonygallina1
@anthonygallina1
Apr 20 2018 07:44
i mostly do JS except at work
Aita Kane
@aita-kane
Apr 20 2018 07:45
okay actually i'm learning PHP
anthonygallina1
@anthonygallina1
Apr 20 2018 07:47
Have you googled PHP shoppiing cart github for ideas?
Aita Kane
@aita-kane
Apr 20 2018 07:47
yes but i'm only stuck with the MVC
@aita-kane I think that isPHP MVC what do you have so far?
Aita Kane
@aita-kane
Apr 20 2018 08:33
i got nothing at all but with that link i'm gonna start thanks so much for your concern
shameem fairooz
@sfshameem5
Apr 20 2018 09:09
@bradtaniguchi Thank You, Solved it. The final code.
function findElement(arr, func) {
    var num = 0;

    for (var i = 0; i < arr.length; i++) {
        if (func(arr[i]) === true) {
            return arr[i];
        }

        if (i === arr.length) {
            return undefined;
        }
    }    
    // return num;
}

findElement([1, 3, 5, 8, 9, 10], function(num) {
    return num % 2 === 0;
});
Stephen James
@sjames1958gm
Apr 20 2018 09:18
@zootechdrum :+1:
Markus Kiili
@Masd925
Apr 20 2018 09:18
@sfshameem5 There is some extra code I think. Just this would do:
function findElement(arr, func) {
  for (var i=0; i<arr.length; i++) {
    if (func(arr[i])) return arr[i];
  }
}
JS functions return undefined if there is no explicit return made.
shameem fairooz
@sfshameem5
Apr 20 2018 09:20
@Masd925 Thanks.
CamperBot
@camperbot
Apr 20 2018 09:20
sfshameem5 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4786 | @masd925 |http://www.freecodecamp.org/masd925
Aita Kane
@aita-kane
Apr 20 2018 09:45
hi anyone that can help me with MVC in php please
anthonygallina1
@anthonygallina1
Apr 20 2018 11:40
I am not sure why this isnt right On Sass: Use @for to Create a Sass Loop ```
<style type='text/sass'>

  @for $j from 1 through 6 {
  .text-#{$j} { font-size: 10px  * $j; }
}

</style>

<p class="text-1">Hello</p>
<p class="text-2">Hello</p>
<p class="text-3">Hello</p>
<p class="text-4">Hello</p>
<p class="text-5">Hello</p>
Stephen James
@sjames1958gm
Apr 20 2018 11:46
@anthonygallina1 do you need to do something like (10 * $j)px?
Jefferson
@jeffersonnnn
Apr 20 2018 11:50
Still looking out for help, please. My console keeps printing errors. Here is the code

    componentDidMount() {

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

        let simpsonQuotes = data.results.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);
    })
}

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

        );
    }

}
anthonygallina1
@anthonygallina1
Apr 20 2018 11:52
@sjames1958gm i will give it a shot thanks
CamperBot
@camperbot
Apr 20 2018 11:52
anthonygallina1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9215 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
anthonygallina1
@anthonygallina1
Apr 20 2018 11:54
@sjames1958gm that was it Confused me because I was getting the correct out put thanks again
CamperBot
@camperbot
Apr 20 2018 11:54
api offline
anthonygallina1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Apr 20 2018 11:55
@jeffersonnnn What are the errors?
@jeffersonnnn console.log(results) to see what the format of the data is
@jeffersonnnn is the error calling function map on undefined?
@anthonygallina1 :+1:
anthonygallina1
@anthonygallina1
Apr 20 2018 11:58
quote key maybe
index 0
Stephen James
@sjames1958gm
Apr 20 2018 12:02
My thought is that is should be data.map and not data.results.map
Jefferson
@jeffersonnnn
Apr 20 2018 12:04

@sjames1958gm

  1. I keep getting ReferenceError: simpsonQuotes is not defined at eval
  2. i just commented out console.log('state', this.state.simpsonQuotes); , and that was funny to say the least
  3. it is also calls that as an error oo

@anthonygallina1 alrighty then, i shall need to try that out

Stephen James
@sjames1958gm
Apr 20 2018 12:05
@jeffersonnnn Did you define this.state.simpsonQuotes in your constructor?
anthonygallina1
@anthonygallina1
Apr 20 2018 12:05
@jeffersonnnn put the address in your browser Thats the first thing i do
if you want :)
Jefferson
@jeffersonnnn
Apr 20 2018 12:11

@sjames1958gm @anthonygallina1 special thanks to you guys for holding my hands through this haha, it is my first react project :smile:

Okay, i actually did. Here is the component

import React, { Component } from "react";
import ReactDOM from "react-dom";


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

    componentDidMount() {

    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);
    })
}

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

        );
    }

}



// const wrapper = document.getElementById("app");
// wrapper ? ReactDOM.render(<FormContainer />, wrapper) : false;
CamperBot
@camperbot
Apr 20 2018 12:11
jeffersonnnn sends brownie points to @sjames1958gm and @anthonygallina1 :sparkles: :thumbsup: :sparkles:
:star2: 9217 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
:star2: 5875 | @anthonygallina1 |http://www.freecodecamp.org/anthonygallina1
Jefferson
@jeffersonnnn
Apr 20 2018 12:12
@anthonygallina1 also, i put the address into postman, if that is what you mean :D
Stephen James
@sjames1958gm
Apr 20 2018 12:12
@jeffersonnnn I think he just meant the address bar of your browser - that is where I always start to see if I get json
and what it looks like
anthonygallina1
@anthonygallina1
Apr 20 2018 12:13
Even better :)
yes @sjames1958gm
@jeffersonnnn na not hand Holding i know the feeling of coding in a silo.
:)
Jefferson
@jeffersonnnn
Apr 20 2018 12:20
@sjames1958gm it definitely looks like json haha. @anthonygallina1 all the time i spent following Tuts thinking i understood, i could have been building haha
anthonygallina1
@anthonygallina1
Apr 20 2018 12:20
:thumbsup:
Jefferson
@jeffersonnnn
Apr 20 2018 12:24
So what could be my error. I still can't find it @sjames1958gm @anthonygallina1
Stephen James
@sjames1958gm
Apr 20 2018 12:25
@jeffersonnnn What is your current error message?
Jefferson
@jeffersonnnn
Apr 20 2018 12:25
OH MY GOD> IT WORKED!
Stephen James
@sjames1958gm
Apr 20 2018 12:27
@jeffersonnnn :checkered_flag:
Jefferson
@jeffersonnnn
Apr 20 2018 12:28

@sjames1958gm @anthonygallina1 it worked guysss. It is on a blank canvas and i need to build out the presentation component and i need to style, but fgs, it worked!

one error though: Warning: Each child in an array or iterator should have a unique "key" prop.

anthonygallina1
@anthonygallina1
Apr 20 2018 12:28
:checkered_flag:
Wadie
@wadie
Apr 20 2018 12:39
Why is there no gitter link on fcc
Markus Kiili
@Masd925
Apr 20 2018 12:39
@wadie They wan't people to use the forums instead.
Wadie
@wadie
Apr 20 2018 12:40
that's better
Guys, I'm currently in Drop It algorithm challenge.
I'm unable to solve, no idea as to why it doesn't work. Here's the code.
```

function dropElements(arr, func) {

    for (var i = 0; i < arr.length; i++) {

        if (func(arr[i]) === false) {
            arr.splice(i, 1);
        }

        if (func(arr[i]) === true) {
            console.log(arr);
            return arr;
        }

    }
    console.log(arr);
    return arr;

}



dropElements([1, 2, 3, 4], function(n) {return n > 5;})
Any suggesstions ?
Markus Kiili
@Masd925
Apr 20 2018 12:59
@sfshameem5 Mutating the array you iterate over with for is a recipe for disaster (usually messes up the indices).
A while loop that chops off elements as long as needed is a better idea.
shameem fairooz
@sfshameem5
Apr 20 2018 13:00
@Masd925 What should I do instead ?
@Masd925 Will keep you updated!
Markus Kiili
@Masd925
Apr 20 2018 13:00
Or find out the index that way and slice at the end.
shameem fairooz
@sfshameem5
Apr 20 2018 13:00
@Masd925 so, create a new array, find out the index, and then chop ?
Markus Kiili
@Masd925
Apr 20 2018 13:01
@sfshameem5 You can find the index out without any new array.
shameem fairooz
@sfshameem5
Apr 20 2018 13:02
@Masd925 I'm not getting it.
Markus Kiili
@Masd925
Apr 20 2018 13:04
@sfshameem5 You can loop through arr and test if func(arr[i]) is true. If it is, you can return a slice of arr.
shameem fairooz
@sfshameem5
Apr 20 2018 13:05
@Masd925 Okay. I'll try doing it that way.
shameem fairooz
@sfshameem5
Apr 20 2018 13:10
Using a while loop now. Still not getting it.

function dropElements(arr, func) {

    var i = 0; 

    while (true) {

        if (func(arr[i]) === false) {
            arr.splice(i, 1);
        }

        if (func(arr[i]) === true) {
            return func(arr[i]);
        }

        i += 1; 
        if (i === arr.length) {
            break;
        }
    }    

    return arr;

}



dropElements([1, 2, 3, 4], function(n) {return n > 5;})
@Masd925
Aditya
@ezioda004
Apr 20 2018 13:20
@sfshameem5 You're still mutating the same array you're looping on. Also, splice() is prob not a good method to use here since if you remove the ith element, next time it'll splice ith+2 instead of ith+1 element due to its index being changed but i remaining the same.
Nate Mallison
@NJM8
Apr 20 2018 13:21
@sfshameem5 Your two if statements are going to mutate the array, you should do one or the other on each loop
Or, loop through the array until the func condition is true, counting up, then splice starting there and return
shameem fairooz
@sfshameem5
Apr 20 2018 13:25
@NJM8 @ezioda004 What's wrong here ?
function dropElements(arr, func) {
    var places = [];

    for (var i = 0; i < arr.length; i++) {
        if (func(arr[i]) === false) {
            places.push(arr[i]);
        }
        if (func(arr[i]) === true) {
            break;
        }
    }

    for (var i = 0; i < places.length; i++) {
        if (places[i] === arr[i]) {
            arr.splice(i, 1);
        }
    }
}

dropElements([1, 2, 3, 4], function(n) {return n > 5;})
Aditya
@ezioda004
Apr 20 2018 13:30
@sfshameem5 You arent returning anything and second what is your 2nd loop suppose to do?
if (places[i] === arr[i]) {
            arr.splice(i, 1);
        }
This will again skip over elements in arr. Should probably look into slice() instead of splice()
shameem fairooz
@sfshameem5
Apr 20 2018 13:40
@ezioda004 I'll redo the solution, and post when i get stuck.
tundeiness
@tundeiness
Apr 20 2018 13:40
the feed back on the twitchtv API project is confusing...can anyone kindly update me with the latest approach to the project?...I intend using ajax please.
_
shameem fairooz
@sfshameem5
Apr 20 2018 13:50
@ezioda004 It worked! The Final Solution
function dropElements(arr, func) {

    var things = [];

    for (var i = 0; i < arr.length; i++) {
        if (func(arr[i]) === false) {
            things.push(arr[i]);
        }
        if (func(arr[i]) === true) {
            break;
        }
    }

    for (var i = 0; i < things.length; i++) {
        arr.shift();
    }
    return arr;
}

dropElements([1, 2, 3, 4], function(n) {return n >= 3;})
Aditya
@ezioda004
Apr 20 2018 13:57
:thumbsup:
Markus Kiili
@Masd925
Apr 20 2018 14:12
@sfshameem5 You could do it with a loop without any mutating:
function dropElements(arr, func) {
   for (var i=0; i<arr.length; i++) {
     if (func(arr[i])) return arr.slice(i);
   }
   return [];
}
NikolaNbgd
@NikolaNbgd
Apr 20 2018 14:16

Hi guys, I need quick help, I am trying to valite input for UK phone number, like this

pattern="^\+?[1-9]\d{1,14}$"

but I got this error in console

Pattern attribute value ^+?[1-9]d{1,14}$ is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^+?[1-9]d{1,14}$/: Nothing to repeat

Does anyone know why?

Stephen James
@sjames1958gm
Apr 20 2018 14:24
@NikolaNbgd You might need \\ in your string so that it keeps the \
NikolaNbgd
@NikolaNbgd
Apr 20 2018 14:26

@sjames1958gm
instead of

pattern="^\+?[1-9]\d{1,14}$"

this

pattern="^\\+?[1-9]\\d{1,14}$"

?

Raphael Miedl
@RaphaelAddile
Apr 20 2018 14:30

@NikolaNbgd Yes, both string and regex have \ as escape character so

pattern="^\+?[1-9]\d{1,14}$"

is equivalent to the regex literal:

pattern = /^+?[1-9]d{1,14}$/

pattern = "^\\+?[1-9]\\d{1,14}$"

is equivalent to

pattern = /^\+?[1-9]\d{1,14}$/
One \ get consumed as string escape character, another one as regex escape character
NikolaNbgd
@NikolaNbgd
Apr 20 2018 14:32
@sjames1958gm do you know how I can required UK phone?
@sjames1958gm e.g it needs +44
and then phone number
Stephen James
@sjames1958gm
Apr 20 2018 14:36
/^\+44/ this matches starting with +44
@NikolaNbgd If you do new Regex("^\\+44") because of what @RaphaelAddile said above about consuming \
NikolaNbgd
@NikolaNbgd
Apr 20 2018 14:39
@sjames1958gm yes, it works, thank you man, again! :)
CamperBot
@camperbot
Apr 20 2018 14:39
nikolanbgd sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9218 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Apr 20 2018 14:47
@NikolaNbgd :+1:
shameem fairooz
@sfshameem5
Apr 20 2018 15:08
I'm currently in Steamroller challenge.
Any, suggestions on doing it ? I'm unable to get the big picture.
Nate Mallison
@NJM8
Apr 20 2018 15:12
@sfshameem5 The idea is to take the nested array [1, [2], [3, [[4]]]] and turn it into a flat array with no sub-arrays [1, 2, 3, 4]
Markus Kiili
@Masd925
Apr 20 2018 15:14
@sfshameem5 The level of nesting is not known, so recursion or an infinite loop is in order. Most people go for recursion.
Concat method is a friend here.
shameem fairooz
@sfshameem5
Apr 20 2018 15:15
@Masd925 Thanks!. I'll try the contact method.
CamperBot
@camperbot
Apr 20 2018 15:15
sfshameem5 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4788 | @masd925 |http://www.freecodecamp.org/masd925
tundeiness
@tundeiness
Apr 20 2018 15:56
@Masd925 can you help with these API calls? Not getting what I actually require
$(document).ready(function() {
   users = ["ESL_SC2", "OgamingSC2"];

   for (let i = 0; i < users.length; i++) {
      let baseUrl = "https://wind-bow.glitch.me/twitch-api/users/";

      let tailUrl = users[i];

      let webLink = baseUrl + tailUrl;

      $.ajax({
         url: webLink,
         type: "GET",
         dataType: "json",
         success: function(data) {
            console.log(data.name);
         },
         error: function() {
            alert("Something went wrong with the server...");
         }
      });
   }

   for (let j = 0; j < users.length; j++) {
      let stream = "https://wind-bow.glitch.me/twitch-api/streams/";

      let tailUrl = users[j];

      let streamLink = stream + tailUrl;
      $.ajax({
         url: streamLink,
         type: "GET",
         dataType: "json",
         success: function(data) {
            console.log(data.stream);
         },
         error: function() {
            alert("Something went wrong with the server...");
         }
      });
   }
});
dinesh
@1532j0004kg
Apr 20 2018 16:01
can u share the codepen link
@tundeiness
dinesh
@1532j0004kg
Apr 20 2018 16:08
that is working right ?
see it in the console
Stephen James
@sjames1958gm
Apr 20 2018 16:21
@tundeiness If you want to access both sets of data in the second $.ajax callback you will need to use a different variable name
than data in one of them.
tundeiness
@tundeiness
Apr 20 2018 16:25
@sjames1958gm yeah I changed it but it is still the same response
Aita Kane
@aita-kane
Apr 20 2018 16:59
Can someone please tell me why do we have to give the value of the attribute "value "in here if we want to use them in if($_POST['btn_submit']=="btn_connexion") <button type="submit" name="btn_submit" value="btn_connexion" class="btn btn-primary">Connexion</button>
niniyzni
@niniyzni
Apr 20 2018 17:03
hi,
  • I am new to js.
  • can you tell me how to print like this "a" -> "a1" "aabbbaa" -> "a2b3a2"
    • i tried with hash map but test cases failing.
    • providing my code below.
    • i am not good in hash map.
    • can you tell me how to solve with hash map so that in future I can fix it my self.
    • not sure what data structure to use for this one.
    • providing my code below.

const _ = require("underscore");

const rle = ( input ) => {

  console.log("input--->" + input);

  //var someString ="aaa";
    var someString = input;

  var arr = someString.split("");
  var numberCount = {};
  for(var i=0; i< arr.length; i++) {
    var alphabet = arr[i];

    if(numberCount[alphabet]){

        numberCount[alphabet] = numberCount[alphabet] + 1;

       }
    else{
        numberCount[alphabet] = 1;

       }
  }

  console.log("a:" + numberCount['a'], "b:" + numberCount['b']);


}

/**
 * boolean doTestsPass()
 * Returns true if all the tests pass. Otherwise returns false.
 */
/**
 * Returns true if all tests pass; otherwise, returns false.
 */
const doTestsPass = () => {

  const VALID_COMBOS = {"aaa": "a3", "aaabbc":"a3b2c1"};

  let testPassed = true;

  _.forEach(VALID_COMBOS, function(value, key) {
  console.log(key, rle(key));
  if (value !== rle(key)) {
    testPassed = false;
  }
  });

  return testPassed;
}


/**
 * Main execution entry.
 */
if(doTestsPass())
{
  console.log("All tests pass!");
}
else
{
  console.log("There are test failures.");
}
Gulsvi
@gulsvi
Apr 20 2018 17:08
@aita-kane Using the value in that code helps distinguish the button from others with the same name. Otherwise, it wouldn't be needed. I'm guessing you must need that because other buttons also have name="btn_submit"
Aita Kane
@aita-kane
Apr 20 2018 17:11
@gulsvi yes they have that
@gulsvi actually i really want to understand fully
@gulsvi thank you so much
CamperBot
@camperbot
Apr 20 2018 17:11
aita-kane sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2706 | @gulsvi |http://www.freecodecamp.org/gulsvi
Gulsvi
@gulsvi
Apr 20 2018 17:12
Glad that helped
Aita Kane
@aita-kane
Apr 20 2018 17:12
@gulsvi and do you know something about MVC in php ?
Nate Mallison
@NJM8
Apr 20 2018 17:12
@niniyzni What is the result of the console.log(key, rle(key)); inside your testing loop?
Gulsvi
@gulsvi
Apr 20 2018 17:12
I know about MVC, but I'm not very good at PHP @aita-kane
MVC applies to most languages
But, I guess there are prescribed ways to build it - I think JavaScript tends to use an object to encapsulate the model
niniyzni
@niniyzni
Apr 20 2018 17:16
@niniyzni hey that line not printing...I dont see anything in coderpad
Nate Mallison
@NJM8
Apr 20 2018 17:22
@niniyzni Can you throw your code in a codepen or jsFiddle? I can't get past the log in/ front page / bull coderpad is trying to sell to get to your code
Aita Kane
@aita-kane
Apr 20 2018 17:22
@gulsvi alright thanks for all
CamperBot
@camperbot
Apr 20 2018 17:22
aita-kane sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
api offline
Gulsvi
@gulsvi
Apr 20 2018 17:23
@niniyzni To solve that, try using a for loop and a counter to generate a new string. Loop through the initial string one letter at a time, add each letter to the new string. If the next letter is the same as the current letter, increase the counter, else, update the new string with the counter value and reset it.
No need for a hash table in this case
Andy Zhao
@Zhao-Andy
Apr 20 2018 17:24
Hi y'all, I'm trying to clone Twitter's "who to follow" sidebar, but not sure what you call the sort of behavior where you can close one suggestion and another shows up in place of it. Closest thing I could think of is pagination, but I'm having trouble figuring out a good search term. Image example:
https://cl.ly/0h2b41210V28
Nate Mallison
@NJM8
Apr 20 2018 17:25
@Zhao-Andy Repopulate?
@niniyzni Also being new to JS I would not use any libraries until you know what you really need from them. Vanilla JS has several array iterators, you can make an object (has map) of the string in just a few lines with reduce
Andy Zhao
@Zhao-Andy
Apr 20 2018 17:26
@NJM8 Ah, that's definitely closer. Thanks!
Nate Mallison
@NJM8
Apr 20 2018 17:27
@Zhao-Andy Just the first thing that came to mind, hope it helps
Andy Zhao
@Zhao-Andy
Apr 20 2018 17:27
@NJM8 saying thanks again for points :)
CamperBot
@camperbot
Apr 20 2018 17:27
zhao-andy sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 422 | @njm8 |http://www.freecodecamp.org/njm8
Nate Mallison
@NJM8
Apr 20 2018 17:27
:smile:
markclynch
@markclynch
Apr 20 2018 19:18
Can anyone help me? I put the wrong login id in vs code to login to my github account :( DOH!
I need to know where in VS code to change that login and password.
I think I put my username in instead of the email for login creds
LydaTech
@lydatech
Apr 20 2018 19:22
@markclynch Ctrl+Shift+G
markclynch
@markclynch
Apr 20 2018 19:22
Ok, did that, but it's not like it's giving me a command line
just gets me into the git changes portion
@lydatech
@markclynch VSCode uses your installed Git . You can set your creds inside of git itself
markclynch
@markclynch
Apr 20 2018 19:27
man I'm so lost lol. Should have learned this ages ago
So inside gitbash?
LydaTech
@lydatech
Apr 20 2018 19:28
yep
markclynch
@markclynch
Apr 20 2018 19:28
dang, don't know how to do that yet lol
google time :)
LydaTech
@lydatech
Apr 20 2018 19:29
@markclynch git config --global user.name ",yourname>"
git config --global user.email "<youremail>}
markclynch
@markclynch
Apr 20 2018 19:29
ah, cool.
creator0323
@Amasian
Apr 20 2018 19:30

Could somebody check my code? I am working on Wiki viewer project and I got some problems. Once user type something in the search bar, the API supposed to bring the information but I think there is a problem related to CORS. what am I doing wrong? Thank you for you time and attention.

https://codepen.io/Amasian/pen/geNJWw?editors=0010

Eric Weiss
@eweiss17
Apr 20 2018 19:30
anyone here familar with flat iron school web dev ?
markclynch
@markclynch
Apr 20 2018 19:31
How come it still shows mark@MSI as my command prompt, does that mean nothing has changed really? @lydatech
LydaTech
@lydatech
Apr 20 2018 19:32
thats your name@your machine name
markclynch
@markclynch
Apr 20 2018 19:32
Yeah, figured that much. Well it seems to have pushed, sort of I guess.
Not getting error in VS Code now, but it doesn't seem to show up as a commit in git
@lydatech oh, it worked! I used the ... and hit push!
markclynch
@markclynch
Apr 20 2018 19:42
@lydatech Thanks!
CamperBot
@camperbot
Apr 20 2018 19:42
markclynch sends brownie points to @lydatech :sparkles: :thumbsup: :sparkles:
:star2: 2778 | @lydatech |http://www.freecodecamp.org/lydatech
Stephen James
@sjames1958gm
Apr 20 2018 19:54
@Amasian For wikipedia add origin=* to bypass CORS
creator0323
@Amasian
Apr 20 2018 20:06
@sjames1958gm you mean like this: Access-Control-Allow-Origin: * ? where can i insert the code?
Botenga
@Botenga
Apr 20 2018 20:10

https://codepen.io/Botenga/pen/QrbjZq

hey can anyone help me? I am trying to align my inputs right next to my labels but I am having trouble doing that. Any help would be much appreciated.

Tiago Correia
@tiagocorreiaalmeida
Apr 20 2018 20:32
hey @Botenga you have an width defined
on the fieldset label class removed the width
ExpressyCode
@ExpressyCode
Apr 20 2018 20:36
Hello guys! I'm almost done with the weather app project. But I can't get the api to work. I only get Shuzenji, JP. Is there anything wrong with my XMLHtppRequest?
Nate Mallison
@NJM8
Apr 20 2018 20:43
@ExpressyCode If you console.log the api address right before you call it you will see that the geoLocation function has not returned yet, console.log('https://fcc-weather-api.glitch.me/api/current?lat=' + lat + '&lon=' + lon); === "https://fcc-weather-api.glitch.me/api/current?lat=&lon="
this is because the xml request code is being fired before the geolocation function can return
ExpressyCode
@ExpressyCode
Apr 20 2018 20:44
@NJM8 Ok, thanks. Will look in to that!
CamperBot
@camperbot
Apr 20 2018 20:44
expressycode sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 423 | @njm8 |http://www.freecodecamp.org/njm8
Nate Mallison
@NJM8
Apr 20 2018 20:44
so put the xml call into it's own function and call the function inside of the getCurrentPosition function success callback
ExpressyCode
@ExpressyCode
Apr 20 2018 20:45
@NJM8 Ok thanks :)
CamperBot
@camperbot
Apr 20 2018 20:45
expressycode sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
api offline
Nate Mallison
@NJM8
Apr 20 2018 20:45
  if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    lat = position.coords.latitude;
    console.log('Lat: ' + position.coords.latitude);
    lon = position.coords.longitude;
    console.log('Lon: ' + position.coords.longitude);
// Do XML work here
  });
otherwise looks good!
ExpressyCode
@ExpressyCode
Apr 20 2018 20:46
@NJM8 There we go now it works, awesome thanks for your help :clap:
CamperBot
@camperbot
Apr 20 2018 20:46
expressycode sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
api offline
Nate Mallison
@NJM8
Apr 20 2018 20:58
sure thing!