Week 3, module 2 - Planar data classification with one hidden layer, 4.4 - Compute the Cost

The order of variables also matters. Check this for further guidance.

Also, you are computing one term only. This is the full formula:

J = - \frac{1}{m} \sum\limits_{i = 1}^{m} \large{(} \small y^{(i)}\log\left(a^{[2] (i)}\right) + (1-y^{(i)})\log\left(1- a^{[2] (i)}\right) \large{)}