I wonder why my js file work when I call it in the view:
@section Scripts {
Its better practice to place your Js file in Script folder and access it from there. You could write this code in view's head to use the js file
@Scripts.Render("~/Scripts/script.js")