InkStitch - Tin tổng hợp Bất Động Sản, Công Nghệ, Giải Trí đầy đủ nhất
  • Trang Chủ
  • Công Nghệ
No Result
View All Result
  • Trang Chủ
  • Công Nghệ
No Result
View All Result
InkStitch - Tin tổng hợp Bất Động Sản, Công Nghệ, Giải Trí đầy đủ nhất
No Result
View All Result

For…in and Math.abs in JavaScript. Codingame: Temperatures – Solved

admin by admin
February 8, 2020
in Công Nghệ
0
For…in and Math.abs in JavaScript. Codingame: Temperatures – Solved



Hi! Let’s play and solve a puzzle titled “Temperatures” by Codingame.
I’m Anatol and you are watching the Good Parts of the FrontEnd development.

The story tells: It’s freezing cold out there! Will you be able to find the temperature closest to zero in a set of temperatures readings?

This puzzle teaches you how to compare a list of values and an Absolute value.

To win this game my program must analyze records of temperatures to find the closest to zero.

Let’s start with one trick. I have a string of values, separated by whitespaces. I create an array from this string using a “split” operator. I omit brackets and use the backtick (a template literal) instead. This function makes code a bit shorter.

Let’s use a “for…in” for looping. The “for…in” statement iterates over the enumerable properties of an object. For each distinct property, statements can be executed.

Be aware, that for…in should not be used to iterate over an Array where the index order is important. Array indexes are enumerable properties with integer names and there is no guarantee that for…in will return the indexes in any particular order. But this isn’t our case.

Besides of that I use Math method “absolute”. It returns an absolute value derived from a given variable or function.

And one more useful shorthand: Logical OR. This means: assign to a variable “a” the value of variable “b”. When variable “b” is undefined, use a value of a variable “c”.

My code is available on GitHub
Documentation is available in the Internet
Follow the links if you’re eager to get more.

If you like this video give it “thumbs up”. Thanks for watching and dive deeper.
Subscribe to the channel:
Watch other episodes:
Follow on Twitter:

Used:
Mendum by Jakebur4, Belles Bells by Loupin, Video Game Forest by AcidParadox
Arcade Town, Police Radio Sound, Small Bell by Alexander
Come and Find Me by Eric Skiff

Nguồn:https://inkstitch.net/

Xem Thêm Bài Viết Khác:https://inkstitch.net/cong-nghe

Tags: Youtube
Previous Post

Múa : Bông hồng tặng cô - Lớp 4B Tiểu học Phú Lãm

Next Post

Phim 3D Kien Truc- Lumion 8 Pro: Nha Van Hoa Thanh Nien Nam Sai Gon

Next Post
Phim 3D Kien Truc- Lumion 8 Pro: Nha Van Hoa Thanh Nien Nam Sai Gon

Phim 3D Kien Truc- Lumion 8 Pro: Nha Van Hoa Thanh Nien Nam Sai Gon

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Về Chúng Tôi

ink stitch

Tin tổng hợp Bất Động Sản, Công Nghệ, Kinh Doanh, Giải Trí, Làm Đẹp đầy đủ nhất ở Ink Stitch. Đặc biệt chúng tôi có chuyên mục tin hot cập nhật những xu thế tin nổi bật nhất từng giờ

  • Giới Thiệu
  • Liên Hệ
  • Chính Sách Bảo Mật

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Trang Chủ
  • Công Nghệ

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.