@
@
@nonconformiste2022-04-06 01:11:59
JavaScript
@nonconformiste, 2022-04-06 01:11:59

Why is the string not being parsed into JSON?

JSON.parse(["day 1","day 2", "day 3", "day 4"])
//VM48341:1 Uncaught (in promise) SyntaxError: Unexpected token d in JSON at position 0

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
low molecular macro, 2022-04-06
_

because
JSON.parse('["day 1","day 2", "day 3", "day 4"]')

N
Nadim Zakirov, 2022-04-06
@zkrvndm

You are passing an array, but you need to pass a string. Learn the data types in JavaScript so you don't get it wrong again.
https://learn.javascript.ru/types

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question