Hi there, New to js and working on using an array with a for loop. In this problem it’s asking me to specifically use a for loop to get a solution. I was able to get my answer using splice. But, to be honest I thought this was a little heavy handed and lazy to me. I didn’t think it
React Boostrap CardDeck does not align horizontally
I am new with React and I am trying to display three cards in a row but they do not align horizontally, they are vertically (from top to bottom). I tried using cardDeck or cardGroup, but they do not work. Below is the code Also, I did a sass file to import in the code above but it seems it
How to write a hook to load more button from fetching a json?
I am calling my fake api using fetch and getting Json data. How can I wire up my load more button so that it it loads more data? Everything works, I just need to add functionality to that load button. I have an empyt function… See code below: Answer So you already have all the data but you need to
How do i hide API key when it must be wrapped in apostrophe?
I’m struggling a bit on how to hide the API key that is located in my header. JavaScript: Because the ‘Authorization’ and ‘Token token=’ are wrapped in apostrophe i can’t put in a variable because it would then be seen as a string and the API will deny my request. I tried u…
Browser shows get request is made but nothing is returned in promise?
Currently stumped on an issue and not finding anything online to help me out. I am making a very basic HTTP get request to get a JSON object from an API I made (express+CORS enabled). I’ve tried with both Axios and VueResource but having the same issue where my browser shows that the request is made and…
In JS ES6, why is it that if I export default, then I cannot export it individually?
I found that I can do: but I cannot move that default to the top: Why is that? They just seem to serve the same purpose: export Foo as default and individually, but the first form is ok while the second form is not. Answer I can’t quite tell if this is a language quirk, because I never see a
sorting a list alphabetically is not sorting anything at all
I’m trying to take a list of cars and sort them alphabetically. So I found this method to sort: But when I write it out to the console, you can see the results below and they are not alphabetically sorted. What could I be doing wrong? Thanks! Answer Your log seems to imply that this data is from immutab…
Javascript: How to use a unique URL taken from different directories
Sorry if the title is not clear I clarify what I want to do. I have a main.js which is used by all my pages. In this main.js I have some URLs: let’s say The problem is that main.js is used by different pages which are in different directories respect to main.js. This means that the path should be differ…
Jest expect to array contains element
Let’s suppose that I have the following code: And I want to check if id is in arrayOfIds Something like this How can I do this with Jest? Answer Use .toContain when you want to check that an item is in an array. For testing the items in the array, this uses ===, a strict equality check.
A function creating variable names for parameters that I never gave
I am learning JavaScript from an eloquent book and in the chapter about higher order functions I found this code: I know that the rest parameter …args takes a number of arguments and groups them into an array, but when did I gave any parameter to the arrow function? Does args automatically contain all t…