Skip to content

Commit

Permalink
jhwhScript.v2 works better
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonges committed Nov 5, 2023
1 parent 1a83460 commit 03b6bca
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions docs/Web4university/Web2/00.InTheBeginning/js/jhwhScript.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ let word = {};
// check with profiler if this makes a diffrence
// add lesson how to profile with DevTools
const twoPI = 2 * Math.PI
const week = 7;
let day = 0;


// DONT global variables
//var globalVariable = "globalVariable";

// DONT just modify objects arbitarrily
word.j = 0.01;
word.j = 0.1;
word.h = -Math.PI;
// DONT misspelled creates new element
// word.i = 0.01;
Expand All @@ -19,25 +22,32 @@ jotaView.value = word.j;

word.speak = function breath() {
// DONT calculate 2 * Math.PI each time
while (word.j < 2 * Math.PI) {
while (word.h < Math.PI) {
// DONT use global reference twoPI
//while (word.h < twoPI) {

word.h += word.j;
word.w = Math.sin(word.h);
//console.log("j:", this.j);

//debugger;
console.log("h:", this.h);


// DONT use hard coded HTML ids
heightView.value = word.h;
widthView.value = word.w;
}
this.h = Math.PI;
word.h = -Math.PI;
};
word.speak();

word.live = function eternity() {
while (this.h > 0) {
while (day++ < week) {
console.groupCollapsed("day:", day);
//debugger;

this.speak();
console.groupEnd();
}
};
word.live();

0 comments on commit 03b6bca

Please sign in to comment.