Code Monkey home page Code Monkey logo

Comments (4)

Fooidge avatar Fooidge commented on July 21, 2024

So in JavaScript, and many other languages when you call a function they return a value to you.

Please.make_color() currently returns a color to you as a hex value string.

so

var aNiceColor = Please.make_color(); 

would store the result of make_color() is the variable aNiceColor.

But you don't always need the variable!

Here's a more complicated example:

Please.make_scheme(Please.make_color({format: 'hsv'}),{scheme_type: 'analogous'});

In here we don't store to a variable. Instead, the return value of one function is immediately consumed by the next in order to fuel it's code.

I hope this makes sense.

from pleasejs.

fluxxus avatar fluxxus commented on July 21, 2024

Thanks for the explanation!! I get the variables bit, although feeling a bit stupid that didn't crossed my mind.

If it is not a problem to clarify the second example in more detail, where is the result stored and how should I fetch it?

Thanks

from pleasejs.

NadyaNayme avatar NadyaNayme commented on July 21, 2024

I call the function, store it as a variable, and then write the result as the contents of a div. I assume this is what you want?
http://jsfiddle.net/9588evd6/

Each time you press "Run" you'll get a new color. You can change the parameter and return amounts to change the number and type of colors you get.

It can be modified to also set the div to be a square and set the background color to the color as well if you'd like it to be a bit more visual.

from pleasejs.

fluxxus avatar fluxxus commented on July 21, 2024

@kyokou Thanks, that is exactly what I needed. I think I will have something to play with tonight by setting up a test page with colored divs and changing their bg color!

Thanks

from pleasejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.