I have a code block in some JavaScript on a razor page. Just before the code block I have a normal JavaScript variable. How do I access this variable from withing the Code Block?

I have a code block in some JavaScript on a razor page. Just before the code block I have a normal JavaScript variable. How do I access this variable from withing the Code Block?

I belive you could use @:
Something like this:
if(context.Project.Find("ProjectId"){
@:actionToTake = "ProjectOutcome";
}
or the special text-tag
if(context.Project.Find("ProjectId"){
<text>actionToTake = "ProjectOutcome";</text>
}
$("#next-step").click(function () { document.location.href = "@Url.Action("Read", actionToTake, new { ProjectId = ViewContext.RouteData.Values["ProjectId"] }, null)"; });actionToTake in the first place