strykes
strykes

Reputation: 3

converting javascript algebraically

I've been trying a very long time and haven't been able to do this.

prize = slices - 1 - Math.floor(degrees / (360 / slices));

Ive been trying to get degrees by itself giving price the value of, lets assume, 3 and slices 8

3 = 8 - 1 - Math.floor(degrees / (360 / 8));

I am trying to get

degrees = 

Upvotes: 0

Views: 32

Answers (1)

Nisarg Shah
Nisarg Shah

Reputation: 14561

Javascript doesn't do algebra internally. You have to solve the equation for that.

You should write a function that takes prize and slices as parameters, and returns the degrees - once you solve the equation.

// prize = slices - 1 - Math.floor(degrees / (360 / slices));

function getDegrees (prize, slices) {
  return -(prize - slices + 1) * (360 / slices);
}

console.log(getDegrees(3,8));

Upvotes: 1

Related Questions