Using string with boolean operator

I’m making my first app, a nutrition app that asks the user’s gender and added sugar consumed. It gives a grade (sugarValue) based on four possible outputs.

Here is an example using 1 for genderField it runs fine, The problem arises when I try to enter “female” for genderField. It can’t use strings with boolean operators. How do I rewrite so the user can enter female instead of a 1 (in my example)? Thanks so much!

var sugarField = 8.0

var sugarValue = 5.0

var genderField = 1.0

if genderField == 1.0 && sugarField >= 16.6 * calorieRatio { sugarValue = 0.01 }

if genderField == 1.0 && sugarField >= 11.0 * calorieRatio && sugarField < 16.6 { sugarValue = 1 }

   if genderField == 1.0 && sugarField > 8.3 * calorieRatio && sugarField < 11 * calorieRatio { sugarValue = 2 }

       if genderField == 1.0 && sugarField <= 8.3 { sugarValue = 3 }

You declared genderField as a double when you set it to 1.0 initially.

This means you can NOT try to use the word “female” instead because that variable is defined as a double, not a string

You either need to change your logic to use “female” instead of checking for 1.0

OR change how your text field works and change “female” into a 1.0 instead