question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

for...of doesn't seem to execute the body

See original GitHub issue

Executing the following program:

ask {
    let mySum:float = 0
    for(let price of itemPrices) {
        mySum = mySum:plus(price)
    }
    mySum
}

should lead to an error as itemPrices does not exist and is not defined as resource or value either. Instead, this program return 0.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20

github_iconTop GitHub Comments

1reaction
czerwinskilukasz1commented, Jun 30, 2020

Following our chat, this is how it should work for a string:

const word = 'Hello';
for(const letter of word) {
 log(letter);
}
0reactions
mhagmajercommented, Jun 30, 2020

@czerwinskilukasz1, how would you implement forOf function in AskScript? AskJSX is a reflection of that.

If you find yourself in need of run, you might want to define your own function and then call it. Here’s a sample while implementation in AskScript (based on native implementation of call):

const while = fun (condition, loopFun) {
  if (!condition) {
    return
  }
  loopFun()
  while(condition, loopFun)
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

for...of - JavaScript | MDN - MDN Web Docs
An iterable object. The source of the sequence of values on which the loop operates. statement. A statement to be executed on every...
Read more >
For Loop not executing - Stack Overflow
The body of the loop will only execute when the condition is true. ... The reason the loop doesn't execute is mentioned by...
Read more >
Loops: while and for - The Modern JavaScript Tutorial
A single execution of the loop body is called an iteration. The loop in the example above makes three iterations. If i++ was...
Read more >
Loops in JavaScript - performing repeated operations on a ...
These loops execute the loop's body (the block) for as long as the condition remains truthy. We use the term one iteration to...
Read more >
Depersonalization-derealization disorder - Mayo Clinic
Feelings of depersonalization and derealization can be very disturbing and may feel like you're living in a dream.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found