These are chat archives for FreeCodeCamp/HelpFrontEnd

29th
Jan 2018
iziz040501
@iziz040501
Jan 29 2018 00:19

hi,

-I am trying to do angular upgrade from angular 2 to angular 5

function getHttp(): HttpClient {
  let providers = [
    {
      provide: HttpClient, useFactory: (backend: XHRBackend, options: RequestOptions) => {

          //error
          //[ts] Expected 1 arguments, but got 2.
        //(parameter) backend: XHRBackend

        return new HttpClient(backend, options);
      },
      deps: [XHRBackend, RequestOptions]
    },
    BrowserXhr,
    { provide: RequestOptions, useClass: BaseRequestOptions },
    { provide: ResponseOptions, useClass: BaseResponseOptions },
    XHRBackend,
    { provide: XSRFStrategy, useValue: new NoopCookieXSRFStrategy() },
  ];

  //return StaticInjector.re

  return ReflectiveInjector.resolveAndCreate(providers).get(Http);
}
Ricky Januari
@rickyjanuari
Jan 29 2018 01:57

Hey everyone!

Can I get some feedback on my portfolio?

https://rickyjanuari.com

is my profile ready for work?

Aditya
@ezioda004
Jan 29 2018 02:12
@rickyjanuari Looks really good, although there's one http image in your work section at the end which is being blocked.
Ken Haduch
@khaduch
Jan 29 2018 03:38
@rickyjanuari - I think that your site looks good, there are some typos if you are interested in knowing about that. For example, the word "Responsive" in your work projects is not spelled correctly. "Website" is misspelled "wesbite" in the apmotor-jpauc.com site page. And it looks like you have repeated that text on the crauc.com site (same typo). As I narrow the screen, some of your blog page text (the "Tutorial Gatsby Reactjs" and "Tutorial Hexo" seem to overlap each other at the bottom. I think that it's interesting that on your "Work" thumbnails, on a wide screen you show them without the green overlay until you hover over them, and on the narrow view they are all overlaid with the green until you hover over them? I like the non-overlay better until hovering then it shows that caption of explanation of what you did on the site. And that one insecure image that is being blocked as @ezioda004 mentioned. But overall it looks impressive and is good work!
Ricky Januari
@rickyjanuari
Jan 29 2018 04:12
thanks @ezioda004 @khaduch i will try to fix again
CamperBot
@camperbot
Jan 29 2018 04:12
rickyjanuari sends brownie points to @ezioda004 and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 421 | @ezioda004 |http://www.freecodecamp.org/ezioda004
:star2: 3701 | @khaduch |http://www.freecodecamp.org/khaduch
German Gamboa Gonzalez
@germangamboa95
Jan 29 2018 04:20
can I get a hand on why my timer is not executing? https://codepen.io/germangamboa95/pen/wpVLvY
it is supposed to activate once the click event happens but it is not.
ehutchllew
@ehutchllew
Jan 29 2018 04:33
@germangamboa95 you're not calling your init function.
@germangamboa95 once you create an instance of Timer, use t.init();
German Gamboa Gonzalez
@germangamboa95
Jan 29 2018 05:06
@ehutchllew init() is part of the constructor though?
aRtoo
@artoodeeto
Jan 29 2018 05:08
hey bros i redo my simon game. i want to change the JS to a module pattern . im starting right not but i have this error.
heres the pen https://codepen.io/artoo/pen/xYKvKX
but  this example i made i dont have an error

let modPat = (function() {

    "use strict";
    // console.log(this);
    // let btn; //working get the DOM elem first then before adding a event
    let a = 2; //this is working
    let b = 3; //this is working

    return {
        init: function (){
            console.log(this);
            this.cacheDOM();
            this.bindEvents();
          },
          cacheDOM: function(){
           let btn = document.getElementById('btn'); //you can put let here too
         },
          bindEvents: function(){
            btn.addEventListener('click', this.displayLog);
          },
          displayLog: function(){
            console.log('yes you made it', a + b);
          }
    }

  }());

  modPat.init();
Michael Cordero
@CyberPutty
Jan 29 2018 05:31
var tempPlayer=[];
var tempAI=[];
var empty=[];
function AITurn(event)
{
while (enemyTurn===true)
  {
    for (i=0;i<8;i++) //8 
    { 
      for (j=0;j<3;j++)//3
      {
        for(k=0;k<player[0].length;k++)
        {
          if (player[0][k]==winList[i][j])
          {
            tempPlayer.push(winList[i][j]);

          }
          else if (player[1][k]==winList[i][j])
          {
            tempAI.push(winList[i][j]);
          }
          else{
            empty.push(winList[i][j]);
          }
      }
    }
      alert("tempPlayer=="+ tempPlayer.length== true);
     if(tempPlayer.length==2)
     {
       position=empty[0];
       tempPos=(event.parent.querySelector(position));
       alert("my alert"+ event.parent.querySelector(position));
       score();
       enemyTurn=false;
     }
      tempPlayer=[];
      tempAI=[];
      emty=[];
    }

 enemyTurn=false;
     // end 3 pos
    }



}
why is tempPlayer.length false?
UnorthodoxThing
@UnorthodoxThing
Jan 29 2018 06:45
Can someone help me with my html and css? My nav menu is cluttered in a corner and Im not sure what's the problem -- is it to do with the property 'position' or 'display'. :/
Tim Rodenbröker
@timrodenbroeker
Jan 29 2018 06:51
Hi coders! I have a question: Could you help me to translate a block of code depending on jQuery into vanilla Javascript? I use the .get()-function but i need to get rid of it:
$.get('img/8.svg', function(svgXml) {
    var knopf = (new XMLSerializer).serializeToString(svgXml);
    var img = new Image();
    var newKnopf = knopf.replace(/#ff0000/g, fg);
    img.src = "data:image/svg+xml;charset=utf-8," + newKnopf;

    setTimeout(function(){ 
        ctx.drawImage(img, 0-svgW/2, 0-svgH/2, svgW, svgH);
    }, 10);
});
The reason is that i use react and i do not need jQuery at all
Markus Kiili
@Masd925
Jan 29 2018 07:56
@timrodenbroeker The JS syntax for making an ajax get request is like:
function loadDoc(url, cFunction) {
  var xhttp;
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      cFunction(this);
    }
  };
  xhttp.open("GET", url, true);
  xhttp.send();
}
Bilal Mahmood Malik
@BilalMalik10
Jan 29 2018 08:05
Hi, please help me to fix nav-bar. i don't know what i am doing wrong. please have a look at my code.
https://codepen.io/bilalmalik/pen/ZrEEmQ
Heathercoraje
@Heathercoraje
Jan 29 2018 08:08
Hi, everyone
I am working on Twitchtv project and I was wondering if this api is working
I am passing url:'https://wind-bow.gomix.me/twitch-api/streams' this url but it says forbidden/403 error
abraham anak agung
@padunk
Jan 29 2018 08:25
@Heathercoraje it work allright, you just need to add username https://wind-bow.gomix.me/twitch-api/streams/freecodecamp
Heathercoraje
@Heathercoraje
Jan 29 2018 08:29
hi @padunk
I have tried that but it still doesnt have anything
abraham anak agung
@padunk
Jan 29 2018 08:30
@Heathercoraje it because the user don't stream anything live
Heathercoraje
@Heathercoraje
Jan 29 2018 08:30
Uhm, sorry I am not getting it. What I am supposed be doing instead?
["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"]
abraham anak agung
@padunk
Jan 29 2018 08:32
@Heathercoraje try https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2 and you will have the data, because the user is streaming live
Heathercoraje
@Heathercoraje
Jan 29 2018 08:33
Is this array of users who stream tv from freecodecamp?
I think I didn't fully understand the spec of project.
abraham anak agung
@padunk
Jan 29 2018 08:33
No, this is an array of users name
Heathercoraje
@Heathercoraje
Jan 29 2018 08:34
usernames of freecodecamp channel..?
abraham anak agung
@padunk
Jan 29 2018 08:34
No
Heathercoraje
@Heathercoraje
Jan 29 2018 08:34
They are just regular users who stream tv..
abraham anak agung
@padunk
Jan 29 2018 08:34
you need to check for each users if they are online or offline. And if they are online, show what that user stream
Heathercoraje
@Heathercoraje
Jan 29 2018 08:35
Then isn't that there are many many users..?
why Is that we are given this array?
abraham anak agung
@padunk
Jan 29 2018 08:35
This is just a sample of users, you could add any users you like
Heathercoraje
@Heathercoraje
Jan 29 2018 08:36
by using api to get user name I guess?
I am sorry. I am having difficulty understand the docs..
abraham anak agung
@padunk
Jan 29 2018 08:36
That is not on the spec of project
Heathercoraje
@Heathercoraje
Jan 29 2018 08:36
True. I could just use that array you are right.
abraham anak agung
@padunk
Jan 29 2018 08:37
you don't need to get more user name. With username provided to you, check if the user is online or offline. That's it
Coy Sanders
@coymeetsworld
Jan 29 2018 08:37
Some of the users in that list continuously stream I believe, so that's why they give some of those so that's it's easier to test
Heathercoraje
@Heathercoraje
Jan 29 2018 08:37
I understand.
Coy Sanders
@coymeetsworld
Jan 29 2018 08:37
and some are defunct which you can also test
Heathercoraje
@Heathercoraje
Jan 29 2018 08:37
I understand now. Thank you.
abraham anak agung
@padunk
Jan 29 2018 08:38
@Heathercoraje you are welcome, happy coding :smile:
Heathercoraje
@Heathercoraje
Jan 29 2018 08:39
@padunk @coymeetsworld Thank you!
CamperBot
@camperbot
Jan 29 2018 08:39
heathercoraje sends brownie points to @padunk and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 420 | @padunk |http://www.freecodecamp.org/padunk
:star2: 3018 | @coymeetsworld |http://www.freecodecamp.org/coymeetsworld
Coy Sanders
@coymeetsworld
Jan 29 2018 08:39
yw @Heathercoraje gl
Tim Rodenbröker
@timrodenbroeker
Jan 29 2018 09:40
Thank you @Masd925 !!!
CamperBot
@camperbot
Jan 29 2018 09:40
timrodenbroeker sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4675 | @masd925 |http://www.freecodecamp.org/masd925
Flipback8
@Flipback8
Jan 29 2018 10:55
I was trying to get a Certificate for HTML/CSS . I start doing the course. I do HTML first then I do CSS and then I do Bootstrap and Now it want's me to do JQuery and the list goes on. I thought I was going to be able to get an HTML/CSS Certificate. Is there such a thing? or do I have to put in hundreds of hours to get the front end Developer Certificate?
abyshukla
@abyshukla
Jan 29 2018 11:22
It's best if you put in the hours.
@Flipback8
Trust me. They'll not be wasted.
UnorthodoxThing
@UnorthodoxThing
Jan 29 2018 11:46
Does anyone know how to display html files with the chrome browser? For me, it's only accessible in the explorer browser. Everytime I try to open with chrome it keeps giving me the message 'Class is not registered'
Chris Cullen
@123xylem
Jan 29 2018 13:45
Hi QUICK API QUESTION:
Chris Cullen
@123xylem
Jan 29 2018 13:50

How do i pull data from etherscan api and put it into a dynamically renderd web page EG
```
app.get("/results",function(req,res){ //We ask for result page
var query=req.query.result; //saves the result of our search box query as query
var url = "https://api.etherscan.io/api?module=account&action=balance&address=" + query +"&tag=latest&apikeyR8X7ZJGWZQZRSDAA4C8T16NMII1W4BIW6R"; //results url goes to omdb api and adds the query from search box to get data
request(url, function (error, response, body) { //That page asks omdb Api for movie data-pending on our query string

if (!error && response.statusCode == 200) { //if the data is good
var data = JSON.parse(body); //make the json a js readable object not string

console.log( data.result);   

if(!data["result"]){
    res.send("No wallets Match your Search!")
}

else{

var number= data.result;
res.render('home',{data:number});
console.log(data.result);
}}
})})
``
Imtrying to pull data off etherscan using their API and put it into a web page.
But the webpage I render doesnt recognise the data input?

Quick API QUestion:
How do i pull data from etherscan api and use it in a dynamically rendered webpage?

When i use render("page",{data:dataFrom API}
It doesnt work as the new page doesnt know what data is?

Stephen James
@sjames1958gm
Jan 29 2018 14:03
@123xylem res.render assumes a template engine? Then the template page would have to know the format of the data
Chris Cullen
@123xylem
Jan 29 2018 14:04
@sjames1958gm
res.render('home',{data:number});
Isnt this saying render home page using the data we just made... for the number var on home page?
theres ejs on homepage
Ray LeDuc
@MrRSLeduc
Jan 29 2018 14:52
Hey everyone, I am wanting to set up a web development environment and was wondering is there an industry standard that most companies use. would be nice to nail some of this down so I don't have to learn 50 different frameworks and workflows? I kind of want to learn the right way from the beginning.
VaseJS
@VaseJS
Jan 29 2018 15:01
@MrRSLeduc you will get a lot of opinions so let me give mine first. Don’t learn frameworks, learn how to program (not just code). For you IDE, there are lots of choices. I’m a minimalist so I say go for VIM. it can do anything any feature rich IDE can do. workflows? That will vary from person to person and some companies have a grand workflow that you must fit yours within. as your learn more, you will learn a workflow that works for you. make sure your folder system makes sense. learn git well, then github. to avoid headaches.
there are no standards to these things, mainly what people find popular at the moment. if you have a proper foundation, you will be able to adopt to any situation
Ray LeDuc
@MrRSLeduc
Jan 29 2018 15:07
@VaseJS thanks for the input
CamperBot
@camperbot
Jan 29 2018 15:07
mrrsleduc sends brownie points to @vasejs :sparkles: :thumbsup: :sparkles:
:cookie: 482 | @vasejs |http://www.freecodecamp.org/vasejs
VaseJS
@VaseJS
Jan 29 2018 15:07
:+1:
kartikv20
@kartikv20
Jan 29 2018 15:10
@MrRSLeduc yea im stuck on that path too
@VaseJS explained it nicely
Stephen James
@sjames1958gm
Jan 29 2018 15:22
@123xylem the ejs file has to know what to do with data in order to render.
Fedoua Jnt
@FedouaJnt
Jan 29 2018 15:57
hey ! please anyone had worked with framework php symfony 2.7
iziz040501
@iziz040501
Jan 29 2018 15:57
hi,

@Injectable()
export class NoopInterceptor implements HttpInterceptor {
  intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    return next.handle(req);
  }
}
Heathercoraje
@Heathercoraje
Jan 29 2018 15:59
Hi, can anyone help me wit this error message with url?
Failed to load https://wind-bow.gomix.me/twitch-api/streams/origin=*?OgamingSC2?callback=?: Redirect from 'https://wind-bow.gomix.me/twitch-api/streams/origin=*?OgamingSC2?callback=?' to 'https://wind-bow.glitch.me/twitch-api/streams/origin=*?OgamingSC2?callback=?' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I am trying to fetch data with such url suggested in spec.
Tiago Correia
@tiagocorreiaalmeida
Jan 29 2018 16:03
are you using codepen?
Heathercoraje
@Heathercoraje
Jan 29 2018 16:04
No.. I Just doing it locally.
Is that the problem?
Stephen James
@sjames1958gm
Jan 29 2018 16:05
@Heathercoraje Can you paste in your URL - some invalid looking characters
Tiago Correia
@tiagocorreiaalmeida
Jan 29 2018 16:05
or maybe the request code
and hey @sjames1958gm
Stephen James
@sjames1958gm
Jan 29 2018 16:05
@Heathercoraje codepen makes it easier to help you debug.
@tiagocorreiaalmeida :wave:
Heathercoraje
@Heathercoraje
Jan 29 2018 16:07
https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?
this is the url I was testing with. It worked on terminal with request module..
Tiago Correia
@tiagocorreiaalmeida
Jan 29 2018 16:08
I mean the entire request code @Heathercoraje
Stephen James
@sjames1958gm
Jan 29 2018 16:10
@Heathercoraje Are you using jquery?
Heathercoraje
@Heathercoraje
Jan 29 2018 16:11
Neither.. just vanilla
Stephen James
@sjames1958gm
Jan 29 2018 16:14
@Heathercoraje
jquery will use the callback=? to trigger jsonp processing, your code will have to do the same.
You might try a quick test without callback=?
Tiago Correia
@tiagocorreiaalmeida
Jan 29 2018 16:14
uh sooo, can we see the code?:D
will be easier to open a file a test it here myself and see if I stop the issue
Pranav Bhaskar
@CoderPrans
Jan 29 2018 16:25

I am trying to use the minimax alogorithm for the Tic Tac Toe project. and
`` for (var i = 0; i < emptySpots.length; i++){
var move = {};
moves.index = emptySpots[i];
newBoard[emptySpots[i]] = player;

var result;
if(player == q){
  result = minimax(newBoard, p);
    move.score = result.score;
}
else {
  result = minimax(newBoard, q);
    move.score = result.score;
}

 newBoard[emptySpots[i]] = ' ';
 moves.push(move);

}` in this snippet earliernewBoard[emptySpots[i]] = player;adds the player token to every index that i refers to in the board array but later callingnewBoard[emptySpots[i]] = ' ';` only removes the replaces the last value i.e, the last value of i of board with ' ' . It is inside the for loop though it should remove everytime it adds, why is it not working properly..

Stephen James
@sjames1958gm
Jan 29 2018 16:35
@CoderPrans Does minimax change newBoard?
Pranav Bhaskar
@CoderPrans
Jan 29 2018 16:36
yes it does but after getting the scores it fixes it. or rather should fix it when i use newBoard[emptySpots[i]] = ' '; setting it back to its previous value. @sjames1958gm
Stephen James
@sjames1958gm
Jan 29 2018 16:38
@CoderPrans maybe pass a copy of the board rather than set / reset which seems prone to error?
var testBoard = newBoard.slice()[emptySpots[i]] = player;
or something like this
Ken Haduch
@khaduch
Jan 29 2018 16:39
@CoderPrans - since it appears that you are declaring var move = {}1 within your for loop, I think that it is not collecting the list of moves but starting with a new array each time. Although I might be confused because you have move and moves and I don't see where moves is declared? (I could just be confused by looking at only that snippet of code.)
Stephen James
@sjames1958gm
Jan 29 2018 16:44
@khaduch move.score = result.score - then pushes move onto moves
Although it doesn't seem to associate a score with a specific move
Ken Haduch
@khaduch
Jan 29 2018 16:45
well if moves is an array, what does moves.index do? I guess I've never used .index with an array?
maybe it should be move.index = emptySpots[i]?
Stephen James
@sjames1958gm
Jan 29 2018 16:49
@khaduch :+1: I think so- good catch
Although it doesn't answer his direct question :)
kartikv20
@kartikv20
Jan 29 2018 17:28
Hello
Trying to make a random quote generator
Ken Haduch
@khaduch
Jan 29 2018 17:29
@CoderPrans - okay, here's the situation as much as I can explain it. I don't see where you are declaring newBoardso it must be implicitly declared when you use it (making it a global, I think?) As you go through your recursive calls to minimax, it builds up the full set of moves in that array, but when you finally return to the last move that is being predicted by the minimax code, you end up back at the place where i is 0 (on the first loop) so the only location that is cleared is location 0, all of the other slots in the array remain set from the minimax calculation. I really didn't pursue it any farther than the first loop and observing what happened there. But maybe that will help you?
kartikv20
@kartikv20
Jan 29 2018 17:29
wtf
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:30
wut
kartikv20
@kartikv20
Jan 29 2018 17:30
function changeQuote() { var randomNum = Math.floor(Math.random() * quotes.length); var randomQuote = quotes[randomNum]; }
this is what i have now
i made the function to generate random quote
now how do i bring it to html
Heathercoraje
@Heathercoraje
Jan 29 2018 17:30
@tiagocorreiaalmeida Sorry mate I have been away from the screen.
Ken Haduch
@khaduch
Jan 29 2018 17:31
@kartikv20 - how are you using randomQuote? You are declaring it locally within that function so it will only have a valid value within that function. What does the rest of your code look like?
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:31
@kartikv20 Ok so ... Where is your call to get data?
Heathercoraje
@Heathercoraje
Jan 29 2018 17:31
Will share it tomorrow if I don't find the answer! hope to catch up if we are in the same time zone :)
kartikv20
@kartikv20
Jan 29 2018 17:32

Till now, this is what I have in my JS file:
`` var quotes = [
"Hi",
"Hello",
"Bye",
"See ya"
"Good Game, Well Played"
]

function changeQuote() {
var randomNum = Math.floor(Math.random() * quotes.length);
var randomQuote = quotes[randomNum];

} ``

What do i do next?
I have a button in html
which is set to button onClick = "changeQuote()"
what do i do next?
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:34
well easiest way would be to have a div or some other element that can hold text and do this: document.getElementById("elemID").innerHTML = randomQuote;
kartikv20
@kartikv20
Jan 29 2018 17:34
what does innerHTML do?
Ken Haduch
@khaduch
Jan 29 2018 17:34
@kartikv20 - to be able to access the value that you are probably storing in randomQuote you need to either return that value to wherever you call that function, or use it within the function to set a value (you can try console.log(randomQuote); within the function and look at the browser console). Or make randomQuote a "global" within your code and then it will retain the value for you to access outside the function.
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:36
@kartikv20 innerHTML sets complete content of that element you get. If you do .innerHTML = ... This will replace all content you already have there with new content ... if you do .innerHTML += it will add new content without replacing old content of the element.
Abhi
@abhishek737
Jan 29 2018 17:36
How to integrate jsembed code in angular ?
kartikv20
@kartikv20
Jan 29 2018 17:39
@khaduch right now, in HTML I have this:
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>Random Quote Generator</title>
</head>
<body>
    <script type="text/javascript" src="javascript.js"></script>

    <div class="container">
        <button onclick="changeQuote()">New Quote</button>

    </div>

</body>
</html>
what do i pass in argument of changeQuote() here
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:40
nothing
kartikv20
@kartikv20
Jan 29 2018 17:40
the thing i want is, when user click on that New Quote button, a quote should come below the button
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:40
you can add another div inside container, under the buttonm
please read what @khaduch and I wrote earlier
Ken Haduch
@khaduch
Jan 29 2018 17:42
@kartikv20 - you cannot use that effectively. Create another div below the button. <div id="quoteText"></div> then use @mbosnjak01 suggestion document.getElementById("quoteText").innerHTML = randomQuote; within that click handler function and see what the result is.
kartikv20
@kartikv20
Jan 29 2018 17:44
 var quotes = [
    "Hi",
    "Hello",
    "Bye",
    "See ya",
    "Good Game, Well Played"
    ];
var randomQuote;

function changeQuote() {
    var randomNum = Math.floor(Math.random() * quotes.length);
    randomQuote = quotes[randomNum];
    console.log(randomQuote);


}

document.getElementById(root).innerHTML = randomQuote;
is this okay?
made randomquote global
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:44
doc.getelement put inside changeQuote
function changeQuote() {
    var randomNum = Math.floor(Math.random() * quotes.length);
    randomQuote = quotes[randomNum];
    console.log(randomQuote);
document.getElementById("root").innerHTML = randomQuote;
}
Ken Haduch
@khaduch
Jan 29 2018 17:45
@kartikv20 - as long as you have an element in your HTML with the id="root" and use getElementById("root:") - in other words, put the string in quotes within that call, it should work. Do you see your quote coming out in the console?
oh, yes, as @mbosnjak01 is saying - the only way to get the element updated is to have the code within the click handler function, because you have to run that code somehow... sorry I missed that!
kartikv20
@kartikv20
Jan 29 2018 17:47
Works, thanks! :D
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:47
Yes. It should work now.
@kartikv20 What would I suggest to you is this: Try to recreate this app
kartikv20
@kartikv20
Jan 29 2018 17:47
Oh! Like how?
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:47
Try to use Jquery ajax call and JSON data
you had that challenges before this
kartikv20
@kartikv20
Jan 29 2018 17:48
I was thinking of getting quotes from a website rather than putting your own
Im avoiding jQuery actually!
Is there any other way?
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:48
you should really not.
I mean
I personaly use jQuery for Ajax calls and few other stuff
kartikv20
@kartikv20
Jan 29 2018 17:49
I mean, is there an API to get quotes from a website?
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:49
cause it's way much simpler than doing ajax call with plain JS, and faster as well
kartikv20
@kartikv20
Jan 29 2018 17:49
How do I do that?
I havent done the Ajax course tho :/
Kaz Baig
@kbaig
Jan 29 2018 17:49
@mbosnjak01 the fetch api makes life a lot simpler
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:50
@kbaig Well, we all have our habbits :P I got used to ajax and writting calls is like drinking watter to me now :(
kartikv20
@kartikv20
Jan 29 2018 17:50
So, how do i fetch random quotes from a website?
Instead of putting my own in array
Matej Bošnjak
@mbosnjak01
Jan 29 2018 17:51
@kartikv20 https://www.w3schools.com/jquery/ajax_getjson.asp This first example is one way, and it's really simple way to do. Furthermore for that you should have .json file where you would store quotes inside an json object
Stephen James
@sjames1958gm
Jan 29 2018 17:52
@kartikv20 This site has an API which you use AJAX to fetch quotes from.
https://forismatic.com/en
kartikv20
@kartikv20
Jan 29 2018 17:53
Ehh, I wanna use the quotes from a quotes website, like the website will change quotes periodically and hence my button should generate the new quotes too
instead of just generating the same old quotes
Stephen James
@sjames1958gm
Jan 29 2018 17:53
@kartikv20 the one I post above is just that
kartikv20
@kartikv20
Jan 29 2018 17:54
Cool, thanks @mbosnjak01 @sjames1958gm ! Need to first learn about APIs first :P
CamperBot
@camperbot
Jan 29 2018 17:54
kartikv20 sends brownie points to @mbosnjak01 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 223 | @mbosnjak01 |http://www.freecodecamp.org/mbosnjak01
:star2: 8914 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Jan 29 2018 17:54
@kartikv20 :+1:
kartikv20
@kartikv20
Jan 29 2018 19:04
@sjames1958gm hey im not able to get data from https://forismatic.com/en/api/
Matej Bošnjak
@mbosnjak01
Jan 29 2018 19:05
https://forismatic.com/en/api/ looks like it's not maintained and is shut down, also old stuff. Just my observation
kartikv20
@kartikv20
Jan 29 2018 19:05
Oh :(
Where do I get API for quotes?
Mel Macaluso
@MelMacaluso
Jan 29 2018 19:10
btw there are tons of examples in google with a 2 minutes research of "quotes api"
@mbosnjak01 exactly
c0c0c0c0
@c0c0c0c0
Jan 29 2018 19:12

code function nextInLine(arr, item) {
var addIt;
var finalArr;

addIt = arr.push(item);
finalArr = addIt.shift();
return finalArr;
}
code

Hi it's some js, and i don't understand why it's isn't working. The var FinalArr is an Array right ?

Matej Bošnjak
@mbosnjak01
Jan 29 2018 19:17

@kartikv20 Before you search for some quotes API, you should try to make your own as I mentioned earlier to you. create quotes.json file, add JSON object there and inside it, add quotes. ... for example

{
"quotes":[
{"qtext": "text1", "author": "someguy"},
{"qtext": "text2", "author": "someguy2"}
]
}

And then call it via jquery $.ajax or $.getJSON (check w3schools or other documentation)

Ken Haduch
@khaduch
Jan 29 2018 19:17
@c0c0c0c0 - check the return value from .shift() and what are you actually supposed to return?
@c0c0c0c0 - actually, what you need to make sure of is the return value from arr.push(item); You want to work with the resulting array, not the return value from the .push().
c0c0c0c0
@c0c0c0c0
Jan 29 2018 19:20
the result of arr.push(item) isn't the var addIt ?
Ken Haduch
@khaduch
Jan 29 2018 19:21
@c0c0c0c0 - what I mean is what the contents of the var addit will be - that method .push() returns the length of the new array, it mutates the array that you are using, so you would want to continue using the variable arr in your next line of code.
@c0c0c0c0 - and the .shift() method returns the element that you are removing from the array, so it contains the contents of arr[0] and that is the value that you want to return. So you are a little bit off in your understanding of what is going on there, but close to a working solution.
c0c0c0c0
@c0c0c0c0
Jan 29 2018 19:26
ok i get it ty, i passed my exercise, but why we don't stock the result of arr.push(item) in an variable ?
Ken Haduch
@khaduch
Jan 29 2018 19:26
@c0c0c0c0 - in this case you do not need that value for anything. In some instances you might want to use that return, which is the array length, but it is not useful here.
c0c0c0c0
@c0c0c0c0
Jan 29 2018 19:28
oh i get it, really this time :) thanks a lot. i didn't see things like that
Stephen James
@sjames1958gm
Jan 29 2018 19:46
@kartikv20 https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&lang=en&jsonp=?
this url will request values from this API - using $.ajax or $.getJSON (jquery)
aRtoo
@artoodeeto
Jan 29 2018 20:35

help fam. i have a branch on a my project. then i push my change to my branch then instead merging it on master i merge the master to the branch. i tried reseting it but it wont. this is the link artoodeeto/Simon-Game-@e4dade5

and this is the hash i want to reset e4dade5621706894a03e5d

i tried doing the git reset --head e4dade5621706894a03e5d it didnt change my file locally

Brad
@bradtaniguchi
Jan 29 2018 20:58
@artoodeeto Its kinda hart to understand what you did, but I assume what you want to do now is to undo what you just did right?
aRtoo
@artoodeeto
Jan 29 2018 21:14
@bradtaniguchi yes bro. i just copy paste i cant find the in google.
Brad
@bradtaniguchi
Jan 29 2018 21:15
You can try this: git reset --hard <SHA-1>
sorry that's what you did
git revert <SHA-1>
Alternativly you can reset back a number of commits (if you have 1 or 2 its simplier)
with git reset --hard HEAD@{1} where 1 can be the number of commits back you want to revert. You can try it with the argument --soft instead of hard, or without it and see what happens
aRtoo
@artoodeeto
Jan 29 2018 21:18
@bradtaniguchi thanks bro. appreciate it. but i want it on my branch. can i do that on my branch or master
CamperBot
@camperbot
Jan 29 2018 21:18
artoodeeto sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 352 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Brad
@bradtaniguchi
Jan 29 2018 21:18
Yes you should be able to do that on any branch
HEAD is just the pointer of where you are in the current branches history
aRtoo
@artoodeeto
Jan 29 2018 21:19
thanks bro appreciate the help
Brad
@bradtaniguchi
Jan 29 2018 21:20
goodluck, hopefully that works
aRtoo
@artoodeeto
Jan 29 2018 21:23
@bradtaniguchi hey bro one more question. how can i update my head? i cant push on my master
Brad
@bradtaniguchi
Jan 29 2018 21:24
what do you get when you try to push to master? does it say your behind?
aRtoo
@artoodeeto
Jan 29 2018 21:24
@bradtaniguchi it says this one bro.
To https://github.com/artoodeeto/Simon-Game-.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/artoodeeto/Simon-Game-.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Brad
@bradtaniguchi
Jan 29 2018 21:27
It says do a git pull, so try it
aRtoo
@artoodeeto
Jan 29 2018 21:30
@bradtaniguchi hey bro i got it now. thanks again bro. appreciate. but one more question. what is the right way to merge? i tried following the step on SO got me some problems.
CamperBot
@camperbot
Jan 29 2018 21:30
artoodeeto sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
api offline
Ken Haduch
@khaduch
Jan 29 2018 21:30
@artoodeeto - if you have local changes that you don't want to lose, I would definitely make a separate copy of the local changes....
I would also suggest going through the github tutorials, I'm sure that they cover that
aRtoo
@artoodeeto
Jan 29 2018 21:32
on my bracnh i need to push my changes then do checkout master and then do git merge branch and then push?
@khaduch aight bro. thanks ye i need to watch it again
CamperBot
@camperbot
Jan 29 2018 21:33
artoodeeto sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3702 | @khaduch |http://www.freecodecamp.org/khaduch
Ken Haduch
@khaduch
Jan 29 2018 21:44
@artoodeeto :+1:
Chris Cullen
@123xylem
Jan 29 2018 21:59
@sjames1958gm I told the ejs file to use data and do things to it but I get a data is not defined error
Evan
@evfrenkel
Jan 29 2018 22:06
Hi I am wondering if there is a way to search for js modules that work in the browser, as there are some on npm that only work in node and not a browser.
Alexander Jarman
@HeinousTugboat
Jan 29 2018 22:56
@evfrenkel https://jspm.io/ I think is for that.
Stephen James
@sjames1958gm
Jan 29 2018 22:57
@123xylem which templating engine are you using?
Alexander Jarman
@HeinousTugboat
Jan 29 2018 22:57
Otherwise generally browser modules and node modules.. don't really do things you want in the other context, and if they do, should mostly work fine in that context.