I am new to Julia. How do I fix this function?
function count(word, ltr)
ncounter = 0;
for letter in word
if letter == “a”
global ncounter = ncounter + 1
end
result = ncounter
end
return result
end
wcount = count(“banana”,‘a’)
julia> include(“scratchpad.jl”)
ERROR: LoadError: UndefVarError: ncounter not defined
Stacktrace:
[1] count(::String, ::Char) at c:\Projects\PHYBUDGET\pam4_j\scratchpad.jl:9
[2] top-level scope at c:\Projects\PHYBUDGET\pam4_j\scratchpad.jl:14
[3] include(::String) at .\client.jl:457
[4] top-level scope at REPL[2]:1
in expression starting at c:\Projects\PHYBUDGET\pam4_j\scratchpad.jl:14