title: MVC Core Retrieve ListOfNames from Controller to View, so View can accessed the List and do JavaScript
body: <p>need help here.
  May I know if I did anything wrong. Apparently, it's not working.</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>[HttpGet]
  public IActionResult Index()
  {
  
      var data = new List&lt;String&gt;();
      data.Add("No");
      data.Add("Yes");
      data.Add("543");
  
  
      ViewBag.Name= data;
      return View(model);
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>        function Validation(IsValid) {
           var test = '@ViewBag.Name';
           var a = "Yes"
           for (var z = 0; z &lt; test.length; z++)
           {
             if (a == test[z]) {
             ...then..
             }
           }
          }
  </code></pre>
  
  <p>How do I accessed the "No", "Yes", and "543" inside the JavaScript?</p>