CSE 331�Software Design & Implementation
Winter 2024
Section 1 – HW1 and Tools
1
UW CSE 331 Winter 2024
Welcome
2
Administrivia
3
Section Grade
Two parts:
4
Coding Setup
Software we will use
Node Demo
const x = {a: 1, b: "two"};
console.log(x.c);
Git Demo
git clone https://gitlab.cs.washington.edu/cse331-24wi-materials/sec-fib.git
NPM Demo
npm install --no-audit
(leaving off --no-audit will generate some bogus error messages)
VSCode Demo
NPM Start
npm run start
http://localhost:8080
Browser Operation
request
response
(HTML)
server name
path
24wi
Browser Operation
request
response
(HTML)
Development Environment
request
response
(HTML)
Starter Code Demo
console.log(new Date());
Global Variables
window.location.hostname “mail.google.com”
window.location.pathname “/mail/u/0”
window.location.search “?zx=ABCD”
window.location.hash “#inbox”
Search String
https://mail.google.com/mail/u/0/?zx=ABCD#inbox
window.location.hostname “mail.google.com”
window.location.pathname “/mail/u/0”
window.location.search “?zx=ABCD”
window.location.hash “#inbox”
Query Parameters
…?a=b&c=d&e=f
const params = new URLSearchParams(window.location.search);
console.log(params.get(“a”)); // prints “b”
Casting
/* Converts string to a Number, returns NaN if not possible */
parseInt(value : string)
/* Converts value to a Number, returns NaN if not possible */
Number(value: any)
/* Converts value to a BigInt, throws error if not possible */
BigInt(value: string | number | bigint | boolean)
Problem 1
Problem 2
const elem: HTMLElement | null = document.getElementById(‘main’);
if (elem !== null) {
const root: Root = createRoot(elem);
root.render(<p>Fibonacci number 5 is 8.</p>);
}
HTML Literals
const name = “Fred”;
root.render(<p>Hi, {name}!</p>); // says Hi, Fred!
Problem 3
<p>Show <a href=“/index.html?n=3”>previous</a></p>
Exam Question