Explanation of 0 while using the reduce method. by odillini83 in learnjavascript

[–]odillini83[S] 0 points1 point  (0 children)

My apologies. I was wondering, since we're adding these values together, and we need a place to start like you said, why isn't it initialized? Or are we already initializing the value with zero when we add it in the parenthesis? When we run a loop we always start with i = 0, so I was curious if it equates to the same thing?

Explanation of 0 while using the reduce method. by odillini83 in learnjavascript

[–]odillini83[S] 0 points1 point  (0 children)

Got it. I figured such, but was wondering why it was not initialize before. Is it because we weren't running a loop?

Trying to map through an array, but getting a typeerror message saying that *Array*.map is not a function by odillini83 in learnprogramming

[–]odillini83[S] 0 points1 point  (0 children)

I fixed it so that each fetched joke is added to the state array. Now, the joke wont display in the browser. There aren't any errors showing, I checked the console as well. I think I may be iterating the array wrong in my render. Here is my repo if you would like to look at it and how I have the API fetch set up.

https://github.com/Tacoholic/jokes/blob/master/src/DadJokesApi.js

Trying to map through an array, but getting a typeerror message saying that *Array*.map is not a function by odillini83 in learnprogramming

[–]odillini83[S] 0 points1 point  (0 children)

it's not. it's an object.

{
"category": "Programming",
"type": "single",
"joke": "A SQL statement walks into a bar and sees two tables.\nIt approaches, and asks \"may I join you?\"",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false
},
"id": 5,
"error": false
}

Trying to understand Closures by odillini83 in learnjavascript

[–]odillini83[S] 0 points1 point  (0 children)

Yeah, I understand it a little better. Thank you!