Assuming there is an array A = [1,3,-1,4,2]
, We have the linked list built as following,
A[0] = 1
A[1] = 3
A[3] = 4
A[4] = 2
A[2] = -1
.fc-time-grid .fc-event, .fc-time-grid .fc-bgevent { | |
position: relative; | |
width: 100%; | |
left: 0 !important; | |
right: 0 !important; | |
height: 40px; | |
margin-bottom: 2px; | |
} |
// Final code | |
var MayApp = {}; | |
MyApp.Base = { | |
data: { | |
rules: { | |
FirstSet:{ | |
"0-12": { | |
"0-12000":{ | |
"0-90" :{ | |
fixedVal: 0.4 |
var MyApp = {}; | |
MyApp.Base = { | |
getFixedVal: function(){ | |
//Javascript code before refactoring | |
var myDataVal = someCalculationHere(); | |
var amount = someInputFieldValue; | |
var fixedVal = 0; | |
if(myDataVal > 12){ | |
if(0 < amount && amount <= 12000){ |
DEFINE amount, fixedVal, myDataVal | |
IF RANGE(0 - 12) INCLUDES myDataVal | |
IF RANGE(0,12000) INCLUDES amount | |
IF RANGE(0,95) INCLUDES calculatedVal | |
RETURN 0.8 | |
ELSEIF RANGE(95,*) INCLUDES calculatedVal | |
RETURN 0.7 |
// intermediate code | |
var MyApp = {}; | |
MyApp.Base = { | |
data: { | |
rules: { | |
FirstSet:{ | |
"0-12": { | |
"0-12000":{ | |
"0-90" :{ |
// Final code | |
var MayApp = {}; | |
MyApp.Base = { | |
data: { | |
rules: { | |
FirstSet:{ | |
"0-12": { | |
"0-12000":{ | |
"0-90" :{ | |
fixedVal: 0.4 |
~$ node | |
> var calculatedChecksum = 1513135 | |
// Anding an integer with 0xFF leaves only the least significant byte. | |
// For example, to get the first byte, we can write "<int value> & 0xFF" | |
// This is typically referred to as "masking" | |
> var firstByte = calculatedChecksum & 0XFF | |
// 0XFF00 is hexadecimal, We are masking out the lower byte of your number, | |
// then bit-shifting all of the bits to the right by 8. |
# | |
# Old code, which has a loop and sends API call for each video ID | |
# | |
video_ids.map do |video_id| | |
Yt::Video.new(id: video_id).select(:snippet, :content_details, :statistics, :status) | |
end | |