TGViewer
Channel Public Channel
JavaScript

JavaScript

@javascript

A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript πŸš€ Don't miss our Quizzes!

Let's chat: @nairihar
Subscribers
31K
Photos
1.2K
Videos
10
Links
899

Showing posts older than #2092 Β· Back to latest

Older Posts 19 shown
Post #2091 6.04K
  • πŸ€” 30
  • πŸ‘ 16
  • ❀ 2
  • πŸ”₯ 2
Post #2090 5.96K
CHALLENGE

function trickyFunction(num) {  
let result = 0;
for (let i = 0; i < num; i++) {
result += i;
if (i % 2 === 0) {
result *= 2;
} else {
result -= 1;
}
}
return result;
}
console.log(trickyFunction(4));
  • πŸ‘ 7
  • ❀ 2
  • πŸ”₯ 1
Post #2088 5.49K
  • ❀ 19
  • πŸ‘ 11
  • πŸ”₯ 6
  • πŸ€” 1
Post #2087 5.89K
CHALLENGE

function trickyScope() {
var a = 10;
let b = 20;
const c = 30;

if (true) {
var a = 40;
let b = 50;
const c = 60;
console.log(a, b, c);
}

console.log(a, b, c);
}

trickyScope();
  • πŸ‘ 18
  • 🀣 9
  • ❀ 6
  • πŸ€” 2
Post #2085 6.27K
  • πŸ”₯ 10
  • πŸ€” 7
  • πŸ‘ 5
  • 🀣 5
  • ❀ 3
Post #2084 5.93K
CHALLENGE

function trickyScope() {
var x = 10;
if (true) {
let x = 5;
console.log(x);
}
console.log(x);
}

trickyScope();
  • πŸ”₯ 9
  • ❀ 4
Post #2082 6.27K
  • 🀣 16
  • πŸ‘ 9
  • πŸ€” 4
  • ❀ 1
Post #2081 6.02K
CHALLENGE

const sym1 = Symbol('description');
const sym2 = Symbol('description');

const obj = {
[sym1]: 'value1',
[sym2]: 'value2'
};

console.log(obj[sym1]);
  • πŸ‘ 8
  • πŸ”₯ 3
  • ❀ 1
Post #2080 6.52K
  • πŸ”₯ 25
  • πŸ‘ 8
  • πŸ€” 8
  • ❀ 2
  • 🀣 1
Post #2079 6K
CHALLENGE

const numbers = [1, 2, 3, 4, 5];

const result = numbers
.filter(num => num % 2 === 0)
.map(num => num * num)
.reduce((acc, num) => acc + num, 0);

console.log(result);
  • πŸ‘ 13
  • ❀ 2
  • 🀣 1
Post #2078 6.09K
About the post above ☝️ πŸ˜‚
  • 🀣 39
  • πŸ‘ 8
  • πŸ”₯ 6
  • ❀ 2
Post #2076 6.1K
  • 🀣 30
  • ❀ 22
  • πŸ‘ 7
  • πŸ”₯ 5
  • πŸ€” 4
Post #2075 5.87K
  • 🀣 32
  • πŸ€” 23
  • πŸ‘ 12
  • ❀ 3
Post #2074 5.9K
CHALLENGE

let person = {
name: 'Alice',
age: 30,
valueOf: function() {
return this.age;
}
};

let result = person + 10;
console.log(result);
  • πŸ‘ 10
  • ❀ 5
  • πŸ”₯ 1
  • πŸ€” 1
Post #2073 6.07K
πŸ€” How and Why to Build 'Copy Code' Buttons

A commonly encountered way to give readers easier access to source shared on the Web. David Bushell has an interesting followup reflecting on his own experiences implementing the same feature.

Salma Alam-Naylor
  • πŸ‘ 8
  • ❀ 2
  • πŸ”₯ 2
Post #2072 5.93K
  • πŸ”₯ 16
  • πŸ‘ 11
  • 🀣 8
  • ❀ 5
  • 🀩 2
Older posts β†’
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’