I have a viewmodel with a property
public List<string> Answers { get; set; }
How do I pass the values of the list to an array variable?
Currently have this javascript code in my view, but it has error on the answers array inside the foreach loop.
The name answers does not exists in the current context.
<script type="text/javascript">
var answers = [];
@foreach(string answer in Model.Answers)
{
var ans = @answer;
answers.push(ans);
}
</script>