Vandana
Vandana
KPCKevin Powell - Community
Created by Vandana on 9/13/2024 in #front-end
setInterval()
Steps to reproduce:title of the document should be changing as new messages every second. But it doesnt happen here ,only on the initial refresh after 1 sec the title changes and remains num
setInterval(() =>
document.title = '(2) New Messages', 1000)
setInterval(() =>
document.title = '(2) New Messages', 1000)
143 replies
KPCKevin Powell - Community
Created by Vandana on 9/11/2024 in #front-end
Condition overlaps?
if (randomNum >= 0 && randomNum <= 1 / 3) {
compMove = 'Rock';
}
else if (randomNum > 1 / 3 && randomNum <= 2 / 3) {
compMove = 'Paper';
}
else {
compMove = 'Scissors';
}
if (randomNum >= 0 && randomNum <= 1 / 3) {
compMove = 'Rock';
}
else if (randomNum > 1 / 3 && randomNum <= 2 / 3) {
compMove = 'Paper';
}
else {
compMove = 'Scissors';
}
Can anyone confirm this as the above code will not cause any overlap in value
90 replies
KPCKevin Powell - Community
Created by Vandana on 9/5/2024 in #front-end
CallBack Functions
What are callback functions in js and when do we use it ? Can anyone explain in brief with an example.
64 replies
KPCKevin Powell - Community
Created by Vandana on 9/4/2024 in #front-end
Check if two strings are Anagram.
Can anyone help me further i have found the occurances of each character.

function areAnagrams(str1, str2) {
const result1 = {};
const result2 = {};
for (let i = 0; i <= str1.length - 1; i++) {

if (!result1[str1[i]]) {
result1[str1[i]] = 1;
}
else {
result1[str1[i]] += 1
}
}
console.log(result1);
for (let i = 0; i <= str2.length - 1; i++) {
if (!result2[str2[i]]) {
result2[str2[i]] = 1
}
else {
result2[str2[i]] += 1;

}
}
console.log(result2);



}
console.log(areAnagrams("listen", "silent"))

function areAnagrams(str1, str2) {
const result1 = {};
const result2 = {};
for (let i = 0; i <= str1.length - 1; i++) {

if (!result1[str1[i]]) {
result1[str1[i]] = 1;
}
else {
result1[str1[i]] += 1
}
}
console.log(result1);
for (let i = 0; i <= str2.length - 1; i++) {
if (!result2[str2[i]]) {
result2[str2[i]] = 1
}
else {
result2[str2[i]] += 1;

}
}
console.log(result2);



}
console.log(areAnagrams("listen", "silent"))
33 replies
KPCKevin Powell - Community
Created by Vandana on 8/31/2024 in #front-end
findIndex()
can anyone explain findIndex in js how is the workflow in brief.
4 replies
KPCKevin Powell - Community
Created by Vandana on 8/26/2024 in #os-and-tools
autoformatting which can be easily set up in VS Code and in Codepen
which makes debugging and reading your code 10x easier any suggestions of now i use beautify and prettier .
9 replies
KPCKevin Powell - Community
Created by Vandana on 8/22/2024 in #front-end
Math in JS.
Can anyone please go through the code and let me know why converting from dollar to cents gives wrong result Steps: $32.5:Converting to cent->32*100=3200. value after decimal point is cent =0005. $10 to be charged extra if cost is less than $40 so $10 gets converted into cents as =1000 Summing up all the above three values we get in cents=4205. convert back to dollars=4205/100=$42.05.This is the process used to convert manually. but in reality ans should be $42.5. https://codepen.io/kvandana451/pen/wvLjBEa
161 replies
KPCKevin Powell - Community
Created by Vandana on 8/9/2024 in #front-end
JS Shorthand
Steps to reproduce: 1]using if statement:
let compValue;
if(randomNum>=0&&randomNum<1/3){
compValue = 'Rock';
}
console.log(compValue)//Rock
let compValue;
if(randomNum>=0&&randomNum<1/3){
compValue = 'Rock';
}
console.log(compValue)//Rock
2]using shorthand
randomNum>=0&&randomNum<1/3 && compValue='Rock';
randomNum>=0&&randomNum<1/3 && compValue='Rock';
=>This statement gives me an error stating ';' expected.javascript let compValue: undefined. Can anyone pls explain me this
102 replies
KPCKevin Powell - Community
Created by Vandana on 7/11/2024 in #front-end
Arrays
Consider an example
const myArray = [1,'hi',true,{name:'socks'},[1,2]]
console.log(type of([1,2])) //object
console.log(myArray.isArray[1,2])//true
const myArray = [1,'hi',true,{name:'socks'},[1,2]]
console.log(type of([1,2])) //object
console.log(myArray.isArray[1,2])//true
What is the difference here in typeof and isArray can anyone pls help.
11 replies
KPCKevin Powell - Community
Created by Vandana on 7/1/2024 in #front-end
Object Conversions
Can anyone pls explain in brief what are the important and necessary object to primitive conversions in brief. or object conversions with egs
16 replies
KPCKevin Powell - Community
Created by Vandana on 6/28/2024 in #front-end
Const objects can be modified
can anyone pls make me understand what is happening under the hood?
77 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
eval()
Why eval js inbuilt function is not recommended to use ??
105 replies
KPCKevin Powell - Community
Created by Vandana on 6/27/2024 in #front-end
variables inside the function and order of Precedence in JS
The variable fahrenheit has function scope i understand but it is still not declared (as a let or const )but works why so?? function convertToFahrenheit(celsius) { fahrenheit = (celsius*9/5)+32; return fahrenheit; } console.log(convertToFahrenheit(25));
76 replies
KPCKevin Powell - Community
Created by Vandana on 6/24/2024 in #front-end
Math.round()
Steps to reproduce: 1]Cost of item1:$20.95 Cost of item2:$7.99 Cost of item3:$18.99 Cost of Shipping:$4.99 Tax:10% Calculating the total cost i am using cents and then converting back to dollars :Math.round((2095+799+1899+499).1)/100=5.29 but this gives a different answer Math.round((2095+799+1899+499).1/100)=5 Can anyone explain what effects the outer bracket of Math.round ??
12 replies
KPCKevin Powell - Community
Created by Vandana on 6/23/2024 in #front-end
trusted HTML Element
Steps to reproduce: 1]As soon as i open the google chrome search engine ,and open a new tab and then open console to type document.body.innerHTML = 'hEY' it gives me an error stating This document requires 'TrustedHTML' assignment. 2]But then the same process when i open the new tab and in the URL I type google.com and open the console and type document.body.innerHTML = 'hEY' there is no such error . Could anyone have any idea about this.
17 replies
KPCKevin Powell - Community
Created by Vandana on 6/21/2024 in #front-end
vertical centering
i am always getting stuck to align vertically at the center of the page,can anyone figure out to make it responsive https://codepen.io/kvandana451/pen/yLWKEjg
32 replies
KPCKevin Powell - Community
Created by Vandana on 6/12/2024 in #front-end
small space left at the bottom for the img
No description
16 replies
KPCKevin Powell - Community
Created by Vandana on 6/11/2024 in #front-end
How to make images responsive using srcset and size attribute??
I have tried using srcset but it isnt working the demo link line 37 https://github.com/kvandana451/Assorted-Cards-images/blob/main/index.html
453 replies
KPCKevin Powell - Community
Created by Vandana on 6/11/2024 in #os-and-tools
Emmet Autocomplete for srcset atrribute
Steps to reproduce: Position your cursor inside the " " for srcset & type a /. You cannot use autocomplete to easily enter in the path to the image you wish, e.g., /images/img1.webp. You have to manually type out the path. This is a problem. Autocomplete should work in both src AND in srcset.
6 replies
KPCKevin Powell - Community
Created by Vandana on 6/10/2024 in #front-end
vertical alignment for an element in the middle
Can anyone help me out to center vertically in the middle as i always fail to achieve this.(min-height is given in the requirement) https://codepen.io/kvandana451/pen/pomWzgK
88 replies