Reputation: 19
I am pretty new to React Native so I am not sure if the if else function works but I tried the following code. LayoutAngle is a user input. So when I keep in 30, I was expecting a1 = 1, a2 = 1, a3 = 1 and a4 = 1. However, that is error occurring, stating that can't find variable a1.
if (LayoutAngle === "30") {
a1 = 1
a2 = 1
a3 = 1
a4 = 1
}
if (LayoutAngle === "60") {
a1 = 2
a2 = 2
a3 = 2
a4 = 2
}
if (LayoutAngle === "30") {
a1 = 3
a2 = 3
a3 = 3
a4 = 3
}
else return(null)
const a = a3/(1-(0.14)*Math.pow(10,a4))
Upvotes: 0
Views: 49
Reputation: 1188
Use switch-case for your problem.
switch (LayoutAngle) {
case '30':
//Some code here
break;
case '60':
//Some code here
break;
case '30':
//Some code here
break;
default:
return null;
}
Upvotes: 1