{"schemaVersion":1,"contentVersion":"3.4.0","id":"foundation.3","languages":{"javascript":{"id":"foundation.3","title":"Choose a word destination","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Learn where w, e and b stop, including when you start in the middle of a word.</p><p><strong>Before this lesson:</strong> First edits and modes.</p><p>w goes to the start of the next word, e goes to the end of a word, and b goes back to the start of a word. From inside a word, b goes to the start of that same word. Letters, digits and underscores make up a word, and punctuation counts as a word of its own.</p><div class=\"pkeys\"><kbd>w</kbd> <kbd>e</kbd> <kbd>b</kbd></div><h3>Example</h3><p>In “pack small bags”, w from p reaches s. e from s reaches the l at the end of small. From that l, b goes back to s. These keys only move the cursor.</p><h4>Worked text</h4><pre class=\"lesson-example\">const message = \"pack small bags\";</pre><p>Use Start over to try again.</p>","teaches":["word-motion"],"introduces":["w","e","b"],"constraints":[],"drills":[{"task":"Put the cursor on <code>saveCart</code> in the <code>useEffect</code> line.","hint":"w goes to the start of the next word.","mode":"jsx","start":"import { useEffect, useState } from \"react\";\nimport { loadCart, saveCart } from \"../store/cart.js\";\n\n// Keeps the cart in localStorage, so a reload doesn't empty it.\nexport function useCart() {\n  const [items, setItems] = useState(loadCart);\n  useEffect(() => saveCart(items), [items]);\n  return [items, setItems];\n}","startCursor":{"line":6,"ch":15},"paths":[{"keys":["w"],"tier":"idiomatic","technique":"motion:w","core":["motion:w","word-motion"],"note":"w stops at the start of each word."}],"kind":"navigate","land":{"line":6,"ch":18},"language":"javascript","evidence":"guided","canonicalKey":"foundation.3#0","canonicalFingerprint":"13pway3"},{"task":"Put the cursor on the last letter of <code>toLocaleString</code>.","hint":"j keeps your column, so you land inside the word. e goes to its last letter.","mode":"jsx","start":"// Prices are stored in cents, so 1999 is 19.99.\nconst LOCALE = \"nl-NL\";\nconst CURRENCY = \"EUR\";\n\nexport function formatCents(cents) {\n  const amount = cents / 100;\n  return amount.toLocaleString(LOCALE, { style: \"currency\", currency: CURRENCY });\n}","startCursor":{"line":5,"ch":20},"paths":[{"keys":["j","e"],"tier":"idiomatic","technique":"motion:e","core":["motion:e","word-motion"],"note":"e stops on the last letter of a word."}],"kind":"navigate","land":{"line":6,"ch":29},"language":"javascript","evidence":"guided","canonicalKey":"foundation.3#1","canonicalFingerprint":"2669n3"},{"task":"Put the cursor on the start of <code>lowStockThreshold</code>.","hint":"b goes back to the start of a word. A count before it goes back that many words.","mode":"jsx","start":"import { Badge } from \"./Badge.jsx\";\n\n// Shows \"Low stock\" when only a few are left, and \"Sold out\" at zero.\nexport function StockBadge({ product, lowStockThreshold = 5 }) {\n  if (product.stock === 0) return <Badge tone=\"grey\">Sold out</Badge>;\n  if (product.stock <= lowStockThreshold) return <Badge tone=\"amber\">Low stock</Badge>;\n  return null;\n}","startCursor":{"line":4,"ch":30},"paths":[{"keys":["j","b"],"tier":"idiomatic","technique":"motion:b","core":["motion:b","word-motion"],"note":"b goes back to the start of a word, and a count goes back that many."}],"kind":"navigate","land":{"line":5,"ch":23},"language":"javascript","evidence":"guided","canonicalKey":"foundation.3#2","canonicalFingerprint":"layh04"}]},"python":{"id":"foundation.3","title":"Choose a word destination","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Learn where w, e and b stop, including when you start in the middle of a word.</p><p><strong>Before this lesson:</strong> First edits and modes.</p><p>w goes to the start of the next word, e goes to the end of a word, and b goes back to the start of a word. From inside a word, b goes to the start of that same word. Letters, digits and underscores make up a word, and punctuation counts as a word of its own.</p><div class=\"pkeys\"><kbd>w</kbd> <kbd>e</kbd> <kbd>b</kbd></div><h3>Example</h3><p>In “pack small bags”, w from p reaches s. e from s reaches the l at the end of small. From that l, b goes back to s. These keys only move the cursor.</p><h4>Worked text</h4><pre class=\"lesson-example\">message = \"pack small bags\"</pre><p>Use Start over to try again.</p>","teaches":["word-motion"],"introduces":["w","e","b"],"constraints":[],"drills":[{"task":"Put the cursor on <code>save_cart</code> in the <code>return</code> line.","hint":"w goes to the start of the next word.","mode":"python","start":"from shop.cart.store import load_cart, save_cart\n\n\ndef add_to_cart(request, sku, quantity=1):\n    \"\"\"Adds an item to the cart kept in the session.\"\"\"\n    cart = load_cart(request.session, create=True)\n    cart[sku] = cart.get(sku, 0) + quantity\n    return save_cart(request.session, cart)","startCursor":{"line":7,"ch":4},"paths":[{"keys":["w"],"tier":"idiomatic","technique":"motion:w","core":["motion:w","word-motion"],"note":"w stops at the start of each word."}],"kind":"navigate","land":{"line":7,"ch":11},"language":"python","evidence":"guided","canonicalKey":"foundation.3#0","canonicalFingerprint":"13pway3"},{"task":"Put the cursor on the last letter of <code>format_currency</code>.","hint":"j keeps your column, so you land inside the word. e goes to its last letter.","mode":"python","start":"\"\"\"Prices are stored in cents, so 1999 is 19.99.\"\"\"\nfrom babel.numbers import format_currency\n\nLOCALE = \"nl_NL\"\n\n\ndef format_cents(cents, currency=\"EUR\"):\n    amount = cents / 100\n    return format_currency(amount, currency, locale=LOCALE)","startCursor":{"line":7,"ch":14},"paths":[{"keys":["j","e"],"tier":"idiomatic","technique":"motion:e","core":["motion:e","word-motion"],"note":"e stops on the last letter of a word."}],"kind":"navigate","land":{"line":8,"ch":25},"language":"python","evidence":"guided","canonicalKey":"foundation.3#1","canonicalFingerprint":"2669n3"},{"task":"Put the cursor on the start of <code>low_stock_threshold</code>.","hint":"b goes back to the start of a word. A count before it goes back that many words.","mode":"python","start":"\"\"\"Shows \"Low stock\" when only a few are left, and \"Sold out\" at zero.\"\"\"\n\n\ndef stock_badge(product, low_stock_threshold=5):\n    if product.stock == 0:\n        return \"Sold out\"\n    if product.stock <= low_stock_threshold:\n        return \"Low stock\"\n    return None","startCursor":{"line":6,"ch":43},"paths":[{"keys":["b"],"tier":"idiomatic","technique":"motion:b","core":["motion:b","word-motion"],"note":"b goes back to the start of a word, and a count goes back that many."}],"kind":"navigate","land":{"line":6,"ch":24},"language":"python","evidence":"guided","canonicalKey":"foundation.3#2","canonicalFingerprint":"layh04"}]},"text":{"id":"foundation.3","title":"Choose a word destination","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Learn where w, e and b stop, including when you start in the middle of a word.</p><p><strong>Before this lesson:</strong> First edits and modes.</p><p>w goes to the start of the next word, e goes to the end of a word, and b goes back to the start of a word. From inside a word, b goes to the start of that same word. Letters, digits and underscores make up a word, and punctuation counts as a word of its own.</p><div class=\"pkeys\"><kbd>w</kbd> <kbd>e</kbd> <kbd>b</kbd></div><h3>Example</h3><p>In “pack small bags”, w from p reaches s. e from s reaches the l at the end of small. From that l, b goes back to s. These keys only move the cursor.</p><h4>Worked text</h4><pre class=\"lesson-example\">Message: pack small bags</pre><p>Use Start over to try again.</p>","teaches":["word-motion"],"introduces":["w","e","b"],"constraints":[],"drills":[{"task":"Put the cursor on <code>Slack</code> in the second step.","hint":"w goes to the start of the next word.","mode":"text/plain","start":"# Your first week\n\n1. Get your laptop from Kemal on Monday morning.\n2. Join our Slack and say hello in #general.\n3. Read the guide to the order system before your first shift.\n4. Shadow someone at the help desk on Wednesday.","startCursor":{"line":3,"ch":8},"paths":[{"keys":["w"],"tier":"idiomatic","technique":"motion:w","core":["motion:w","word-motion"],"note":"w stops at the start of each word."}],"kind":"navigate","land":{"line":3,"ch":12},"language":"text","evidence":"guided","canonicalKey":"foundation.3#0","canonicalFingerprint":"13pway3"},{"task":"Put the cursor on the last letter of <code>Saturday</code>.","hint":"j keeps your column, so you land inside the word. e goes to its last letter.","mode":"text/plain","start":"# Opening hours\n\nThe shop in Utrecht is open from Tuesday to Sunday.\nOn Saturday it opens an hour early, at 9:00.\nIt's closed on public holidays and between Christmas and New Year.\nPickup orders can be collected until closing time.","startCursor":{"line":2,"ch":4},"paths":[{"keys":["j","e"],"tier":"idiomatic","technique":"motion:e","core":["motion:e","word-motion"],"note":"e stops on the last letter of a word."}],"kind":"navigate","land":{"line":3,"ch":10},"language":"text","evidence":"guided","canonicalKey":"foundation.3#1","canonicalFingerprint":"2669n3"},{"task":"Put the cursor on the start of <code>subscription</code>.","hint":"b goes back to the start of a word. A count before it goes back that many words.","mode":"text/plain","start":"Subject: Your coffee subscription is changing\n\nHi Dana,\n\nFrom 1 December your monthly subscription costs 18 euros instead of 16.\nBeans have become more expensive, and we'd rather not change the coffee.\nYou can pause or cancel any time from your account.\n\nNorthwind Coffee","startCursor":{"line":4,"ch":63},"paths":[{"keys":["5","b"],"tier":"idiomatic","technique":"motion:b","core":["motion:b","word-motion"],"note":"b goes back to the start of a word, and a count goes back that many."}],"kind":"navigate","land":{"line":4,"ch":29},"language":"text","evidence":"guided","canonicalKey":"foundation.3#2","canonicalFingerprint":"layh04"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> First edits and modes.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Learn where w, e and b stop, including when you start in the middle of a word.</p><p>w goes to the start of the next word, e goes to the end of a word, and b goes back to the start of a word. From inside a word, b goes to the start of that same word. Letters, digits and underscores make up a word, and punctuation counts as a word of its own.</p><h2 class=\"prose-subhead\">Example</h2><p>In “pack small bags”, w from p reaches s. e from s reaches the l at the end of small. From that l, b goes back to s. These keys only move the cursor.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> First edits and modes.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Learn where w, e and b stop, including when you start in the middle of a word.</p><p>w goes to the start of the next word, e goes to the end of a word, and b goes back to the start of a word. From inside a word, b goes to the start of that same word. Letters, digits and underscores make up a word, and punctuation counts as a word of its own.</p><h2 class=\"prose-subhead\">Example</h2><p>In “pack small bags”, w from p reaches s. e from s reaches the l at the end of small. From that l, b goes back to s. These keys only move the cursor.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> First edits and modes.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Learn where w, e and b stop, including when you start in the middle of a word.</p><p>w goes to the start of the next word, e goes to the end of a word, and b goes back to the start of a word. From inside a word, b goes to the start of that same word. Letters, digits and underscores make up a word, and punctuation counts as a word of its own.</p><h2 class=\"prose-subhead\">Example</h2><p>In “pack small bags”, w from p reaches s. e from s reaches the l at the end of small. From that l, b goes back to s. These keys only move the cursor.</p><p>Use Start over to try again.</p></div></details>"}}}