Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add section on timers #1201

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add section on timers #1201

wants to merge 1 commit into from

Conversation

Dedekind561
Copy link
Contributor

@Dedekind561 Dedekind561 commented Nov 18, 2024

What does this change?

Address #1115

Common Content?

  • Block/s

Common Theme?

Yes - it adds to the js2 section.

Issue number: #1115

Org Content?

Updates Data Groups -> Section 3 -> prep

Module | Sprint | Page Type | Block Type

Checklist

Who needs to know about this?

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-sdc ready!

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-sdc/deploys/673bbf49af84250008501880
😎 Deploy Preview https://deploy-preview-1201--cyf-sdc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-curriculum canceled.

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-curriculum/deploys/673bbf490dc1a70008c12013

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-launch ready!

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-launch/deploys/673bbf4907f4060008abd478
😎 Deploy Preview https://deploy-preview-1201--cyf-launch.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-programming ready!

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-programming/deploys/673bbf494ab2230008fbb158
😎 Deploy Preview https://deploy-preview-1201--cyf-programming.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 14 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-tracks ready!

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-tracks/deploys/673bbf49cbe97d00086e8a01
😎 Deploy Preview https://deploy-preview-1201--cyf-tracks.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Dedekind561 Dedekind561 requested a review from a team November 18, 2024 22:28
Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-common canceled.

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-common/deploys/673bbf4957a087000880d14c

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-piscine ready!

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-piscine/deploys/673bbf496889150008f656ea
😎 Deploy Preview https://deploy-preview-1201--cyf-piscine.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 85 (🔴 down 12 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for cyf-itd canceled.

Name Link
🔨 Latest commit 8a45ac5
🔍 Latest deploy log https://app.netlify.com/sites/cyf-itd/deploys/673bbf49a328580008249151

Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

console.log(`My name is ${name}`);
}

setTimeout(printMessage, 3000, "Sally"); // <-- Call printMessage after at least 3000ms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setTimeout(printMessage, 3000, "Sally"); // <-- Call printMessage after at least 3000ms
setTimeout(printMessage, 3000, "Sally"); // <-- Call printMessage after at least 3000ms, with the argument "Sally"

}

setTimeout(printMessage, 3000, "Sally"); // <-- Call printMessage after at least 3000ms
printName("Daniel");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printName("Daniel");
printMessage("Daniel");

printName("Daniel");
```

In this example, we define the function and call `printMessage` just once. However, we're also using a built-in function called `setTimeout`. `setTimeout` allows us to set a minimum amount of time after which a function will be called back.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this example, we define the function and call `printMessage` just once. However, we're also using a built-in function called `setTimeout`. `setTimeout` allows us to set a minimum amount of time after which a function will be called back.
In this example, we define the function and call `printMessage` just once. We also call it ourselves once. We're also using a built-in function called `setTimeout`. `setTimeout` allows us to set a minimum amount of time after which a function will be called back.


> "After at least 3000 ms, call the function `printMessage`, and when you call back `printMessage`, pass the input of `"Sally"` to `printMessage`."

Notice we're saying _at least_ 3000 ms because `setTimeout` guarantees a minimum amount of time: it doesn't say that `printMessage` muse be called _exactly_ after 3000 ms. In this example, we say that `printMessage` is a {{<tooltip title="callback function">}}A callback function is a function that is passed as an argument to another function and gets executed after the main function has finished its execution.{{</tooltip>}} as it is _called back_ after 3000 miliseconds. In the terminal, we'll see "Daniel" appear first and then after an at least 3000 ms delay, we'll see the console log of "Sally"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Notice we're saying _at least_ 3000 ms because `setTimeout` guarantees a minimum amount of time: it doesn't say that `printMessage` muse be called _exactly_ after 3000 ms. In this example, we say that `printMessage` is a {{<tooltip title="callback function">}}A callback function is a function that is passed as an argument to another function and gets executed after the main function has finished its execution.{{</tooltip>}} as it is _called back_ after 3000 miliseconds. In the terminal, we'll see "Daniel" appear first and then after an at least 3000 ms delay, we'll see the console log of "Sally"
Notice we're saying _at least_ 3000 ms because `setTimeout` guarantees a minimum amount of time: it doesn't say that `printMessage` muse be called _exactly_ after 3000 ms. In this example, we say that `printMessage` is a {{<tooltip title="callback function">}}A callback function is a function that is passed as an argument to another function. We ourselves don't call the callback function - something else will call it for us at the right time.{{</tooltip>}} as it is _called back_ after 3000 miliseconds. In the terminal, we'll see "Daniel" appear first and then after an at least 3000 ms delay, we'll see the console log of "Sally".

A callback function is more general than this... In the context of setTimeout this tooltip seems correct, but more generally "some other code" will call a callback "when it should", right? Like [1, 2, 3].map(x => x + 1) - the arrow function there is still a callback function, but it will be executed before the main function finishes. And [].map(x => x + 1) - the callback function is never actually called. But these are still callback functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

Successfully merging this pull request may close these issues.

2 participants