Floor function: Google Sheets vs PHP

I made a simple weight tracking app in PHP and am comparing it with what I used to have in Google Sheets, and I’m noticing a difference in a number coming back from "floor". In Google Sheets: =FLOOR(84.614285714286 / ((179 / 100) ^ 2)) results in: "26" in PHP 8: floor($currentWeight / (($user[‘height’] / 100)^2));… Read More Floor function: Google Sheets vs PHP

Getting incorrect result when using floor() while calculating compount interest

In my code, I use the well-known formula for calculating compound interest. I used floor() for every element in the result, but I got an unexpected result, i.e. for 6 months I got [1300, 1690, 2197, 2856, 3712, 4826] where the last number should be 4825, if calculating manually every time skipping decimals (what floor()… Read More Getting incorrect result when using floor() while calculating compount interest

How to get Year Mont and Quarter from time series in python

I have this dataset: date_time srch_id 2013-04-04 08:32:15 1 2013-04-04 08:32:15 1 .. 2013-06-30 19:55:18 332785 2013-06-30 19:55:18 332785 And I want to separate date_time into: YM (Year_Month),YMQ(Year_Month_Quarter),Y and M: date_time srch_id YMQ YM Y M 2013-04-04 08:32:15 1 2013-04-2 2013-04 2013 4 2013-04-04 08:32:15 1 2013-04-2 2013-04 2013 4 .. 2013-06-30 19:55:18 332785 2013-06-2… Read More How to get Year Mont and Quarter from time series in python

How to fetch data from API on button click – Javascript?

I’ve got this part of code: fetch(`https/someapi.com/data`) .then(response => { return response.json() }).then(randomProduct => { document.querySelector(‘#list’).innerHTML = ` <span>${randomProduct.value}</span> <button id="refresh-button" type="button">Refresh</button> `; var clickOnButton = document.querySelector("#refresh-button"); clickOnButton.addEventListener("click", () => { }) }) How to I make this onClick event refresh the data the I read from API and display a new one? >Solution :… Read More How to fetch data from API on button click – Javascript?

React problem Cannot read properties of undefined (reading 'map') in a quiz app?

I am working on a quiz project. Particularly I am working on selecting an answer out of 4 options. Whenever I click on an option I am encountering an error which is given below This is my App.js file import { useEffect, useState } from "react"; import Quiz from "./components/Quiz"; import { nanoid } from… Read More React problem Cannot read properties of undefined (reading 'map') in a quiz app?

Can anyone tell me why this script.js isn't working?

Can anyone tell me why this isn’t working? the intent is to change the title when clicked to a random rgb color (the onclick function doesn’t even appear on my gitpage: https://lucaspaulii.github.io/portfolio/) const title = document.getElementById("title"); let randNum = () => { let num = Math.floor(Math.random() * 255); return num } let randColor = ()… Read More Can anyone tell me why this script.js isn't working?

Can I reduce this 3 functions to only one and create 3 distincts things?

These functions will create divs, and A, B, and C will have different left positions (as in the arrays) and different classes with different dimensions. Another function will call them in a set interval and will decrease all the "–bottom" with time at the same speed (they will move down ). I have a feeling… Read More Can I reduce this 3 functions to only one and create 3 distincts things?

I do not know how to limit the time in between calling my function

//let screenWidth = window.screen.width; //let screenHeight = window.screen.height; let screenWidth = 800; let screenHeight = 600; let assets = {}; let frames = 60; let score = 0; let lives = 3; let player; // let enemie; //let enemies; let bullet; //let bullets; let powerup = 0; let gameOver = true; function drawScoreBoard() { textSize(20);… Read More I do not know how to limit the time in between calling my function

subtract same variables in single object javascript

const token = [ {“token”:”d2r4Z62OTGiPyNmdHTUfny”, “time”:1652767811}, {“token”:”dnl13twkQIqifdvaxp1t6e”, “time”:1652767811}, {“token”:”eDZxQu0FSWm72D2-T1md5X”, “time”:1652767811}, {“token”:”dnl13twkQIqifdvaxp1t6e”, “time”:1652767811}]; // Try edit me const arr = []; for (var i=0; i<=token.length-1; i++) { const millis = Date.now(); const time = Math.floor(millis / 1000); if (token[i].time > time) { arr.push(token[i].token) } } console.log(arr); between these two token variables are the same, I want… Read More subtract same variables in single object javascript