1

Problem

I'm trying to loop through an array of Elements in VueJS and return the first one that does not have a given class. However, whenever I use Break, Vue refuses to compile

Code

let section = null;

this.sectionList.forEach(s => {
    if(!s.classList.contains('complete')){
       section = s;
       break;
    }
});

return section;

The Error

app.js:73816 Uncaught Error: Module build failed: SyntaxError: C:/Users/Lewis/homestead/projects/bookitzone/resources/js/frontend/components/sections/form-section.vue: Unsyntactic break (72:20)

enter image description here

4
  • Fair enough. I though this was Vue related. Thanks for the links. Commented Jun 21, 2019 at 14:06
  • 1
    Vue is just a javascript framework, so the same things apply (at least in this case) as with javascript... Commented Jun 21, 2019 at 14:10
  • you should use return instead of break. and btw this is just js its not related to vuejs Commented Jun 21, 2019 at 14:21
  • let section = null; this.sectionList.forEach(s => { if(!s.classList.contains('complete')){ section = s; return true } }); return section; Commented Apr 21, 2022 at 5:18

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.