0

In my javascript i want something like this

SomeFunction(attribute){
    var prev_rating = {{ u_list.attribute }};
}

The function can have three different inputs... beauty, wealth, age . So if I pass attribute = beauty to the function, var prev_rating should be set to

var prev_rating = {{ u_list.beauty }};

How can I achieve this ?

1 Answer 1

1

You have to write the value selection in Javascript:

var ratings = {beauty: {{u_list.beauty}}, wealth: {{u_list.wealth}}, age: {{u_list.age}} }
function SomeFunction(attribute) {
    var prev_rating = ratings[attribute]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.