# My function used to print to console but now wont even work

Hi all,

I wrote this function and it was working perfectly fine and then i came back a few days later and when i ran it the result wont show in the console like it used to before. I didn't change a single thing. Any insight would be greatly appreciated.

`Grade_Analyzer <- function(S, R, P, B)`

`{`

`PB <- P+B`

`SB <- S+B`

`if(S < P)`

`{`

`print("The highest possible score you can get is P + B:")`

`print(PB)`

`if(R == PB)`

`{`

`new_score <- PB`

`print("score 1")`

`return(new_score)`

`}`

`else if(R < PB)`

`{`

`print("score 2")`

`return(R)`

`} #END ELSE IF`

`else if(R > PB)`

`{`

`print("score 3")`

`return(PB)`

`}#end Else IF`

`else`

`{`

`print("score 4")`

`return(R)`

`}#End Else`

`} #end IF`

`if(S == P)`

`{`

`if(R == SB)`

`{`

`print("score 5")`

`return(SB)`

`} #end IF`

`else`

`{`

`print("score 6")`

`return(R)`

`#End Else`

`}`

`if(S > P)`

`{`

`print("score 7")`

`return(S)`

`#end IF`

`}`

`} #end IF`

`}#End Function`

`P <- 22`

`B <- 30`

`S <- 54`

`R <- 67`

`Grade_Analyzer(S,R,P,B)`

It looks like a closing bracket was left off for the scenario if(S == P). If you add a ` } ` before if(S > P) and eliminate the second-to-last ` } #end IF` line in your function, I believe it will work as intended. I made these changes in the condensed version below, adding comments where the two changes were made.

``````Grade_Analyzer <- function(S, R, P, B) {

PB <- P+B
SB <- S+B

# scenario 1
if(S < P) {
print("The highest possible score you can get is P + B:")
print(PB)

if(R == PB) {
new_score <- PB
print("score 1")
return(new_score)
} else if(R < PB) {
print("score 2")
return(R)
} else if(R > PB) {
print("score 3")
return(PB)
} else {
print("score 4")
return(R)
}
}

# scenario 2
if(S == P) {

if(R == SB) {
print("score 5")
return(SB)
} else {
print("score 6")
return(R)
}

# scenario 3
if(S > P) {
print("score 7")
return(S)
}

# } #end if  -THIS IS REMOVED

} # End Function

P <- 22
B <- 30
S <- 54
R <- 67
I don't wanna talk about it. 