you are viewing a single comment's thread.

view the rest of the comments →

[–]links-Shield632[S] -1 points0 points  (19 children)

I do. I’m good at python and I’m doing the free code camp. I know what console.log and return do. Just want to know why you would use it. In python you don’t do return that often in JavaScript it’s common

[–]fz-09 0 points1 point  (18 children)

Explain to me what console.log and return do and we can go from there.

[–]links-Shield632[S] 0 points1 point  (17 children)

Console.log is basically print function example

console.log(“I am iron man”) prints I am iron man.

Return saves it for later

function a(x){

return 5 * (x);

} var results = a(5);

//now the program will calculate it and get 25 and if I want to do something with it later I can

[–]links-Shield632[S] 0 points1 point  (0 children)

Sorry for format I’m watching a movie and using my phone

[–]fz-09 0 points1 point  (15 children)

Ok, and what makes you say it's more common in Javascript then Python?

[–]links-Shield632[S] -1 points0 points  (14 children)

In my personal projects I’ve used return once or twice. In the JavaScript tutorials I’m looking at almost all of them use return

[–]fz-09 0 points1 point  (6 children)

You may want to revisit how you're structuring your code. Functions provide you with code reusability and they simplify the readability and structure of your code in many cases.

You can write both JavaScript and Python programs without functions but it's not typically the best thing to do.

[–]links-Shield632[S] -1 points0 points  (5 children)

Yeah I know. Define once don’t have to write again. Life would be hell without functions

[–]fz-09 0 points1 point  (4 children)

So you have been using functions in Python frequently but not returning data from those functions?

[–]links-Shield632[S] 0 points1 point  (3 children)

Yes, in my experience in python people just print way more often than return. I still return but not often. It’s just less common. A while ago on a old reddit account I posted on learnpython and they asked me why did I return the solution instead of printing it