These are chat archives for FreeCodeCamp/Help

5th
Nov 2017
Stephen James
@sjames1958gm
Nov 05 2017 00:53
@deebarizo /.-\s(.*)/ just take everything u p to first -
korzo
@korzo
Nov 05 2017 01:05
@DarrenfJ Hi and thanks
CamperBot
@camperbot
Nov 05 2017 01:05
korzo sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2245 | @darrenfj |http://www.freecodecamp.com/darrenfj
Jansan Selvasingam
@JansanSelva
Nov 05 2017 02:39
public class LibraryItem {
    private String title;
    public LibraryItem()
    {
         title = "";
    }
    public String getDescription()
    {
        return title;
    }

}
//-------------------------------------------------
public class DVD extends LibraryItem {
    public String certificate;
    public String leadActor;

    public DVD(String cert, String actor)
    {
        certificate =  cert;
        leadActor = actor;
    }
    public String getCertificate()
    {
        return certificate;
    }
    public String getleadActor()
    {
        return leadActor;
    }
    public String toString()
    {
        return "DVD[Title =" + "][Certificate:" + getCertificate()  + "] [Lead Actor:" + getleadActor() + "]";
    }

}
I am trying to make a program that gives you the description of an item when u call it , so for example if i say DVD title it will give the file name, certificate and lead actor as a string desciption
i havent wrote the tester main yet
wondering what im doing wrong so far
Manish Giri
@Manish-Giri
Nov 05 2017 02:50
@JansanSelva what error do you get
@DarrenfJ @korzo @thekholm80 @Marmiz @heroiczero @alexanderkopke @daddycardona @khaduch @longnt80 ty
CamperBot
@camperbot
Nov 05 2017 02:50
manish-giri sends brownie points to @darrenfj and @korzo and @thekholm80 and @marmiz and @heroiczero and @alexanderkopke and @daddycardona and @khaduch and @longnt80 :sparkles: :thumbsup: :sparkles:
:star2: 1576 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 1085 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 2013 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 2246 | @darrenfj |http://www.freecodecamp.com/darrenfj
:cookie: 466 | @daddycardona |http://www.freecodecamp.com/daddycardona
:cookie: 652 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 740 | @korzo |http://www.freecodecamp.com/korzo
:star2: 3462 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 1714 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Jansan Selvasingam
@JansanSelva
Nov 05 2017 03:27
@Manish-Giri i figured it out thanks, i thought i had mistakes
CamperBot
@camperbot
Nov 05 2017 03:27
jansanselva sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6767 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ken Haduch
@khaduch
Nov 05 2017 03:28
@Manish-Giri @GitHub-Henry @heroiczero @DarrenfJ - thank you, faithful and regular contributors... don't you all forget to set your clocks back tonight, if you are in a location that changes between Daylight Savings Time and Standard time... :clock2:
CamperBot
@camperbot
Nov 05 2017 03:28
khaduch sends brownie points to @manish-giri and @github-henry and @heroiczero and @darrenfj :sparkles: :thumbsup: :sparkles:
:cookie: 466 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 2247 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 6768 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 2014 | @heroiczero |http://www.freecodecamp.com/heroiczero
Long Nguyen
@longnt80
Nov 05 2017 03:54
Use const (almost) always
Use let when you need it
Never use var
It’s dead ☠️
Forever undefined
Pour one out for var
korzo
@korzo
Nov 05 2017 03:56
@Manish-Giri thanks
CamperBot
@camperbot
Nov 05 2017 03:56
korzo sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6769 | @manish-giri |http://www.freecodecamp.com/manish-giri
Long Nguyen
@longnt80
Nov 05 2017 04:09
@Manish-Giri
@DarrenfJ @korzo @thekholm80 @Marmiz @heroiczero @alexanderkopke @daddycardona @khaduch @Manish-Giri thank you and have a good weekend !
CamperBot
@camperbot
Nov 05 2017 04:11
longnt80 sends brownie points to @darrenfj and @korzo and @thekholm80 and @marmiz and @heroiczero and @alexanderkopke and @daddycardona and @khaduch and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 741 | @korzo |http://www.freecodecamp.com/korzo
:star2: 1086 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 1715 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
:star2: 6770 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 2015 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 467 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 1577 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 3463 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 2248 | @darrenfj |http://www.freecodecamp.com/darrenfj
Kyle Holm
@thekholm80
Nov 05 2017 04:14
@Manish-Giri @heroiczero @DarrenfJ @GitHub-Henry @longnt80 @daddycardona ty
CamperBot
@camperbot
Nov 05 2017 04:14
thekholm80 sends brownie points to @manish-giri and @heroiczero and @darrenfj and @github-henry and @longnt80 and @daddycardona :sparkles: :thumbsup: :sparkles:
:cookie: 468 | @daddycardona |http://www.freecodecamp.com/daddycardona
:cookie: 467 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 2249 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 6771 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 2016 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 653 | @longnt80 |http://www.freecodecamp.com/longnt80
Jansan Selvasingam
@JansanSelva
Nov 05 2017 04:15

can someone help me go in the right direction i need to format this text

Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00
,,"Venture ""Extended Edition""","",4900.00

and make it output a file looking like this

[Year,Make,Model,Description,Price]
[1997,Ford,E350,ac,abs,moon,3000.00]
[1999,Chevy,Venture "Extended Edition",null,4900.00]
[1996,Jeep,Grand Cherokee,MUST SELL!]
[air,moon roof,loaded,4799.00]
[null,Venture "Extended Edition",null,4900.00]

Im trying to do it with tokenizer but im confused on how i would go about it

using Java
Manish Giri
@Manish-Giri
Nov 05 2017 04:18
just override the toString() method in the class
@Override
public String toString() {
  return "[" + this.year + " " + ....  + "]";
}
Jansan Selvasingam
@JansanSelva
Nov 05 2017 04:23
@Manish-Giri is that for my code with the text formatting?
Manish Giri
@Manish-Giri
Nov 05 2017 04:23
yes
its not complete though
Jansan Selvasingam
@JansanSelva
Nov 05 2017 04:23
i have a file im scanning
which has the first set of texts
and im outputting a new file with the 2nd set of texts by formatting the input file
Manish Giri
@Manish-Giri
Nov 05 2017 04:24
okay
Jansan Selvasingam
@JansanSelva
Nov 05 2017 04:25
im using scanner and assuming i use tokenizer
for example the 1999,Chevy,"Venture ""Extended Edition""","",4900.00 has to be [1999,Chevy,Venture "Extended Edition",null,4900.00] in the new output file. what would i do to remove the extra " and add null
Manish Giri
@Manish-Giri
Nov 05 2017 04:30
I haven't used ElasticSearch, so i'm not sure how tokenizer scans things, but in java, assuming you scan this whole line as a string
1999,Chevy,"Venture ""Extended Edition""","",4900.00
you can first split it on ,
then on the array of strings, you can check if a string is just "" using .isEmpty()
it will return true when it is ""
if it returns true, you can place null
Henry
@GitHub-Henry
Nov 05 2017 06:16
@heroiczero @thekholm80 @DarrenfJ
@alexanderkopke @Manish-Giri @longnt80
@korzo @daddycardona @khaduch @sjames1958gm
hello & thank you to some of the folks that
keep this place alive and active,
your activities are appreciated,
:shipit: :sparkles:
CamperBot
@camperbot
Nov 05 2017 06:16
github-henry sends brownie points to @heroiczero and @thekholm80 and @darrenfj and @alexanderkopke and @manish-giri and @longnt80 and @korzo and @daddycardona and @khaduch and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1578 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:cookie: 654 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 2017 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 1716 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
:cookie: 469 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 2250 | @darrenfj |http://www.freecodecamp.com/darrenfj
:cookie: 742 | @korzo |http://www.freecodecamp.com/korzo
:star2: 3465 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 8667 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 6772 | @manish-giri |http://www.freecodecamp.com/manish-giri
Jansan Selvasingam
@JansanSelva
Nov 05 2017 09:30
how do i remove quotations from a string
the regex for it confuses me
String temp = scan.nextLine();
 temp = temp.replaceAll("[^,a-zA-Z0-9.]","");
this removes all the " but i also need to replace it with white space
Jansan Selvasingam
@JansanSelva
Nov 05 2017 09:36
trying to go from
1999,Chevy,"Venture ""Extended Edition""","",4900.00
to this output
[1999,Chevy,Venture "Extended Edition",null,4900.00]
okay nvm figured out the " marks forgot it was a meta character and had to escape it with \
Jansan Selvasingam
@JansanSelva
Nov 05 2017 09:44
but now my output looks like
1999,Chevy,Venture Extended Edition,,4900.00
... lol im lost
heroiczero
@heroiczero
Nov 05 2017 10:32
@thekholm80 @DarrenfJ @daddycardona @longnt80 @khaduch @GitHub-Henry @sjames1958gm @Marmiz @Manish-Giri @longnt80 @sjames1958gm @Marmiz @korzo @alexanderkopke TY. Your daily dose of brownies for the regulars :)
CamperBot
@camperbot
Nov 05 2017 10:32
heroiczero sends brownie points to @thekholm80 and @darrenfj and @daddycardona and @longnt80 and @khaduch and @github-henry and @sjames1958gm and @marmiz and @manish-giri and @korzo and @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 470 | @daddycardona |http://www.freecodecamp.com/daddycardona
:star2: 1579 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:cookie: 468 | @github-henry |http://www.freecodecamp.com/github-henry
:star2: 6773 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 1717 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
:star2: 8668 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3466 | @khaduch |http://www.freecodecamp.com/khaduch
:cookie: 655 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 743 | @korzo |http://www.freecodecamp.com/korzo
:star2: 2251 | @darrenfj |http://www.freecodecamp.com/darrenfj
:star2: 1087 | @marmiz |http://www.freecodecamp.com/marmiz
Jansan Selvasingam
@JansanSelva
Nov 05 2017 10:34
import java.io.File;
import java.io.PrintWriter;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class CarInfoText {

    public static void main(String[] args) throws FileNotFoundException{
        File inFile = new File("C:\\Users\\Jansan\\Documents\\input.txt");// path
         File outFile = new File("C:\\Users\\Jansan\\Documents\\output.txt");
         PrintWriter newPrint = new PrintWriter(outFile);
         Scanner scan = new Scanner(inFile);
         while (scan.hasNextLine())
         {
             String temp = scan.nextLine();
             temp = temp.replaceAll("\"","");
            // System.out.println(temp);
              String[] words = temp.split(",");
              for(int i=0;i<words.length;i++)
                {
                    if(words[i].isEmpty())
                        words[i] = "null";
                 }

             System.out.println("[" + words[0]+","+words[1]+"," + words[2]+","+ words[3]+ "," + words[4]+"]");
            // [Year,Make,Model,Description,Price]
            // [1997,Ford,E350,ac, abs]
            //[1999,Chevy,Venture Extended Edition,null,4900.00]
            // Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
            //at CarInfoText.main(CarInfoText.java:26)

         }
        scan.close();
         }
    }
not sure why im getting the java.lang.ArrayIndexOutOfBoundsException: 4

my input:
Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00
,,"Venture ""Extended Edition""","",4900.00

trying to get this output
[Year,Make,Model,Description,Price]
[1997,Ford,E350,ac,abs,moon,3000.00]
[1999,Chevy,Venture "Extended Edition",null,4900.00]
[1996,Jeep,Grand Cherokee,MUST SELL!]
[air,moon roof,loaded,4799.00]
[null,Venture "Extended Edition",null,4900.00]

Marcius
@marciusl
Nov 05 2017 12:08
Hello! Can anyone tell me why i get: fromCharCode is not a function
arr[i][j].fromCharCode(code);
Alex
@alexandrupintilei
Nov 05 2017 12:25
Why height of card-blocks is higher on 1st card after each row,and not equals with other ones?https://codepen.io/balexoy/full/xPVoZm/
sol: card-decks
korzo
@korzo
Nov 05 2017 12:34
@heroiczero @GitHub-Henry @longnt80 Thank you guys
CamperBot
@camperbot
Nov 05 2017 12:34
korzo sends brownie points to @heroiczero and @github-henry and @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 656 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 2018 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 470 | @github-henry |http://www.freecodecamp.com/github-henry
Victor Abeledo
@victorja
Nov 05 2017 12:48
Hi guys, I have a project that can add, edit or delete movies from a list. I'm having trouble with the edit part of the component, next to every movie I added a text input to edit that movie if wanted, but I don't know how to pass that value to the other component in order to change the old value for the new one. Here is what I got for now
https://plnkr.co/edit/0R9WhYnzQN7OgkxqE01r?p=catalogue
Alex
@alexandrupintilei
Nov 05 2017 13:03
Can someone tell me why group class resize all cols? https://codepen.io/balexoy/pen/YEqooG
Victor Abeledo
@victorja
Nov 05 2017 13:19
I have this declaration:
this.editMovie.bind(this,key)
How can I use those bind parameters inside editMovie()?
Garrus Napp
@GarrusNapp
Nov 05 2017 13:41
@victorja you need to pass the parents method that uses setState as a prop to your child, that will call it with the value of text field
Victor Abeledo
@victorja
Nov 05 2017 13:43
@GarrusNapp Thanks !
CamperBot
@camperbot
Nov 05 2017 13:43
victorja sends brownie points to @garrusnapp :sparkles: :thumbsup: :sparkles:
:cookie: 849 | @garrusnapp |http://www.freecodecamp.com/garrusnapp
Victor Abeledo
@victorja
Nov 05 2017 13:46
@GarrusNapp What should I return from edit in order to just change the text of my previous item in the list?

This is edit:

Wait I'll paste it in plunker, it's unreadable here

Garrus Napp
@GarrusNapp
Nov 05 2017 13:53
@victorja as I understand, you need to edit the state
@victorja can you show me how does movies array look like
Victor Abeledo
@victorja
Nov 05 2017 13:57
    this.state = {
        movieText: '',
        movies: [],
    };
let moviesArr = this.state.movies;
moviesArr.push(this.state.movieText);
first chunk is how I declared the object which contains the array, second chunk is part of the addMovie function
tell me if you need to see the whole component and i'll paste it
Garrus Napp
@GarrusNapp
Nov 05 2017 14:06
you need to change this.state.movies in the component where you map them
so, I'd create an edit method that would take the index of a movie
and a event.target.value of the form input
So new component FORM so you can send that as a prop to it
Victor Abeledo
@victorja
Nov 05 2017 14:11
what's the difference between event.target.value and binding the value to the text input to the edit function?
gishy1
@gishy1
Nov 05 2017 19:04
hello world !!!
function chunkArrayInGroups(arr, size) {
  // split arr into size
  // so create an empty array
  // array positions i.e [i].length=size
  var arrEmpty=[];
for(var i =0;i<(arr.length/size);i++){

  arrEmpty[i]=arr.slice(i,i+size);  

}  


  return arrEmpty;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
so close yet so far!!!
need help
so close yet so far!!!
Victor Abeledo
@victorja
Nov 05 2017 19:07
I think you dont need the for loop
Arrays don't have fixed sizes
gishy1
@gishy1
Nov 05 2017 19:09
@victorja not understanding what u mean bro please break it down a bit
Victor Abeledo
@victorja
Nov 05 2017 19:11
do you want to split one array in two?
arrays in javascript aren't the same from other languages like C
function (oldArr,endOf1stArr){
var newArr1 = oldArr.slice(0,endOf1stArr);
var newArr2 = oldArr.slice(endOf1stArr,oldArr.length);
return [newArr1,newArr2];
}
gishy1
@gishy1
Nov 05 2017 19:15
@victorja bro im this is my first proper language
Victor Abeledo
@victorja
Nov 05 2017 19:17
ok, so in arrays you can store data, and you get data from the indexes of the array, array[0] is the first element you stored
array[1] the second
gishy1
@gishy1
Nov 05 2017 19:35
@victorja yes that i get
Jansan Selvasingam
@JansanSelva
Nov 05 2017 21:25
how do i read a text file and store it in an arraylist
 while (scan.hasNextLine())
         {
             String temp = scan.nextLine();
             temp = temp.replaceAll("\"\"","");
              ArrayList<String> listS = new ArrayList<String>();
              listS = temp.split(",");
basically tryna add
Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00
,,"Venture ""Extended Edition""","",4900.00
to the arraylist
Daniel
@dkapexhiu
Nov 05 2017 21:51
hi! how to reduce space between two divs and divider in html bootstrap?
korzo
@korzo
Nov 05 2017 22:47
Mastering Git free for last hour https://www.packtpub.com/packt/offers/free-learning
Jansan Selvasingam
@JansanSelva
Nov 05 2017 23:40
for(int i=0;i<words.length;i++)
                {
                     words[i] = words[i].trim();
                      if(words[i] == "Venture Extended Edition")
                        {
                            words[i] = "Venture Extended";
                        }
                    if(words[i].isEmpty())
                        words[i] = "null";
                                   }
im trying to make an element check if it has a particular string and replace it if it does how would i do that