Skip to content
Advertisement

Tag: javascript

JSX template literals for an inline style

I’m trying to add an inline style on an element which includes variables. Hard-coding the values works: But I need a way for both of the numbers in this style to pull from variables. I’ve tried a variety of curly braces and backticks – I think I need template literals, but am not sure how the syntax works for them

A very big sum – Hacker Rank

I am trying to solve “A very big sum” challenge on Hacker Rank: https://www.hackerrank.com/challenges/a-very-big-sum/problem In there I have to sum all the numbers in the array given so I came up with two solutions: First solution Second Solution But none of them work and I donĀ“t know why, I am thiniking maybe I am not writing it as Hacker Rank

This document requires ‘TrustedScriptURL’ assignment

After adding require-trusted-types-for ‘script’; in my Content-Security-Policy header, which introduced from Chrome 83 Beta to help lock down DOM XSS injection sinks, when I open my website, it becomes a blank page. I got many these three kinds of errors in my console. (Chrome version 83.0.4103.61) This document requires ‘TrustedScript’ assignment. This document requires ‘TrustedScriptURL’ assignment. TypeError: Failed to set

Can you print a page in a function being defined in javascript?

I have (had 2 years ago lol) been working on a web page that prints everything on it, and need to define a function that gets a value, replaces the text box with the value, hides the print button, and prints the page. It works perfectly–with the exception of printing the page, the most important part. Thanks in advance. Answer

Add Buy Me A Coffee Widget to React application

I am trying to create a component that renders the Buy Me A Coffee widget in some routes of my react single page application. This is my component so far: When I inspect the page with the developer tools, the tag is at the end of the head section and everything seems correct but the widget doesn’t show in the

Jest: shared async code between test blocks

I have some test code like this: I would like to break apart the code into multiple test blocks (because I can’t even add a description message to each expect statement). If Jest supported async describe, I could do this: I could duplicate the setup call for each test of course, but that would slow down the test considerable (I’m

Advertisement