-2

When my code like this

var app = angular.module('PhotoViewer', []);
var photos = [

i have error: combine this with previous 'var' statement. When it like this:

var app = angular.module('PhotoViewer', []);
photos = [

i have error: 'photos' was used before defined; What I must to do?

  • 1
    Replace the `;` with a `,`. But I would turn that linting option off. It's much clearer if every variable is declared with its own var keyword. – JB Nizet Jun 27 '17 at 12:28
  • Might you consider using `let` more often? It's the future of non-hoisted goodness. – byxor Jun 27 '17 at 12:33

2 Answers2

1

You need to separate the var using a comma , if you want to declare in single var

var app = angular.module('PhotoViewer', []),
photos = [];

This also works,

var photos = [];
var app = angular.module('PhotoViewer', []);
Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62
-1

The probleem is that you don't close the array brackets.

  • That's not _the_ problem. It's _a_ problem, but they just didn't paste the code properly. – byxor Jun 27 '17 at 12:34