Check out example codes for "r if else". It will help you in understanding the concepts better.

Code Example 1

# Basic syntax if:
if (test_expression) {	
  code to run if test_expression is true
}

# Basic syntax if else:
if (test_expression) {
  code to run if test_expression is true
} 
else {
  code to run if test_expression is false
}

# Basic syntax if else if:
if (test_expression_1) {
  code to run if test_expression_1 is true
} 
else if (test_expression_2) {
  code to run if test_expression_2 is true
}

# Basic syntax if else if else:
if (test_expression_1) {
  code to run if test_expression_1 is true
} 
else if (test_expression_2) {
  code to run if test_expression_1 is true
}
else {
  code to run if both expressions are false
}

Learn ReactJs, React Native from akashmittal.com