Skip to content

Commit

Permalink
03: Кодирование чисел
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzimys committed Apr 13, 2024
1 parent ed31fa2 commit dba38c3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 03-Кодирование чисел/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function fizzbuzz() {
return {
callCount: 0,
value: 0,

next() {
if (this.callCount === 0) {
value = BigInt(1);
} else if (this.callCount === 1) {
value = BigInt(2);
} else if (this.callCount%2 === 0) {
value = 'Fizz';
} else {
value = 'Buzz';
}

this.callCount++;

return {
done: false,
value,
};
}
}
}

const myFizzBazz = fizzbuzz();

console.log(myFizzBazz.next().value); // 1n
console.log(myFizzBazz.next().value); // 2n
console.log(myFizzBazz.next().value); // Fizz
console.log(myFizzBazz.next().value); // Buzz
14 changes: 14 additions & 0 deletions 03-Кодирование чисел/База#3. ДЗ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ДЗ к лекции База#3

## Написать программу FizzBuzz используя BigInt

```
const myFizzBazz = fizzbuzz();
myFizzBazz.next(); // 1n
myFizzBazz.next(); // 2n
myFizzBazz.next(); // Fizz
myFizzBazz.next(); // Buzz
myFizzBazz.next(); // Fizz
// ...
```

0 comments on commit dba38c3

Please sign in to comment.