Any suggestions about this two simple javascript functions? (beginner asks)

I’m building up a simple blog from scratch. I’ve noticed that the blog needs JS to update the new posts section and to update some descriptive meta tags. I like to set up meta tags properly so when somebody shares the page, they get some details along with the URL.

So the two functions I’ve written are supposed to solve the previous issues, and are named:

  • updatePosts
  • setCurrentPostMetaTags

Both functions take an input object named posts. This object is modified by hand when a new post is created. The newest posts are on the start of the object. (new to old).

It with be impossible to share a working code, but the code is properly updating everything.
What I’m looking for is any advice on the way I’m writing the JS, or setting things up.

I’d be happy to update this post with any extra requirement. Below it’s the posts object plus the two functions.

//posts object containing metadata for posts. 
//New posts should be added on the top of the object
const posts = (
    {
        title:"Mr. Nobody: The Concept of Temperature",
        brief:"Mr. Nobody takes the thermometer into apart to answer. What is Temperature?",
        publishIn:"July 6th, 2020",
        folder:"post3"
    },
    {
        title:"Mr. Nobody: Pink Floyd Cover", 
        brief:"Guitar cover of Wish You Were Here By Mister Nobody",
        publishIn:"May 24th, 2020", 
        folder:"post2" //this isn't strictly necessary.
    }, {
        title:"Mr. Nobody: Thoughts on Web Dev", 
        brief:"Let's tell the story from the looser point of view. And Mr. Nobody comes in.",
        publishIn:"May 16th, 2020", 
        folder:"post1" //this isn't strictly necessary.
    }
        
    )


const updatePosts = (posts) => {    
    //index.html file is a directory up, I'm taking 
    // care of that fact using setStartDir
    let ul = document.getElementsByClassName("newposts")(0).getElementsByTagName("ul")(0)
    ul.innerHTML=""
    let setStartDir=".."
    if(window.location.pathname.endsWith("dist/")){
        setStartDir="."
    }
    for (let i=0; i<5 && i<posts.length; i++){
    //we only want 4 posts in the new posts section       
    ul.innerHTML += `
    <li><a href="${setStartDir}/post${posts.length - i}/">
    ${posts(i).publishIn}: ${posts(i).title}
    </a></li>n
    `
    }
    return 1
}

const setCurrentPostMetaTags = (posts) => {
    //next element contains all properties that vary between posts
    //and can be set using posts object information.
     let metaProps = {
        page:{
            description:'meta(name="description")'
        },
        og:{
            title:'meta(property="og:title")', 
            description:'meta(property="og:description")', 
            image:'meta(property="og:image")'
        },
        twitter:{
            title:'meta(name="twitter:title")'
        }
    }
for(let i = 0; i<posts.length; i++){
if(window.location.pathname.endsWith(`post${posts.length - i}`))
    {
        document.querySelector(metaProps.page.description).setAttribute("content", `${posts(i).title}`)
        console.log("updated")
        document.querySelector(metaProps.og.title).setAttribute("content", `${posts(i).title}`)
        console.log("updated")
        document.querySelector(metaProps.og.description).setAttribute("content", `${posts(i).brief}`)
        console.log("updated")
        document.querySelector(metaProps.og.image).setAttribute( "content", "../images/cartoon-min.jpg")
        console.log("updated")
        document.querySelector(metaProps.twitter.title).setAttribute("content", `${posts(i).title}`)
        console.log("updated")
        return 1
    }
}
return -1
}

updatePosts(posts)
setCurrentPostMetaTags(posts)

certificates – VPN provider asks to install RootCertificate. How is it safe?

I want to use VPN provider (ProtonVPN), and don’t want to use an app. They ask user to install their Root Ca. How safe is it? What type of info could they get from my laptop? If I have their certificate installed, does that means they can see and get all info from my browser, including passwords and https sites? And what about other non browser traffic? How safe is it? What are the risks?

I don't have a password on my Mac but when I try to uninstall the software it asks me for a password which does not exist

I have a mac configuration to run musical programs. It works very well and because I hate having to enter passwords, I have none on anything. No problem here and every time I installed programs, it asked for the password, I just pushed enter and it installed no problems. Now, however, I am trying to uninstall a program and when I do, a terminal screen appears where it asks for a password … this 3 times before closing because I haven't entered the password. The problem is that there is no password, so what is the way to skip this stupid loop anywhere?

beginner – PYTHON A program that first asks the user how much change is due, then spits out the minimum number of pieces with which said change can be made

Suppose that the only coins available are the quarters (25 ¢), the ten sous (10 ¢), the nickels (5 ¢) and the sous (1 ¢).

change = float(input('change='))
list =(.25,.1,.05,.01)
list.sort(reverse=True)
print(list)
count=0
for i in range(len(list)):

a = int(change/list(i))
costa = float(a*list(i))
change= change- costa
count=count+a
print(count) 

macos – GPG Tools never asks for a password during encryption or decryption

My secret key is password protected. When I import it into pgp tools on Windows every time I have to use the key, I am asked for the password.

On Mac, I have NEVER been asked for a password. Does this mean that the password for the private key is stored in Apple's keychain? If so, is there a way to NOT do it, so I have to enter a password?

registration – Connection / registration form inspired by Etsy which only asks for the email address in the first step

I am a UI designer, I study to improve my UX knowledge and I have a doubt on a project.
I have a login / registration modal window that works like the Etsy login / registration modal to the payment process. In the first step, it only contains a field for the email address and a "Continue" button.

enter description of image here

Then, if the email is already registered, the modal says "Welcome again" and asks the user to enter the password.

enter description of image here

If the e-mail is not registered on the site, the modal says "You are new here" and asks the customer to create an account and enter a password.

enter description of image here

What do you think of such a solution? Can it be confusing for customers? Is this an unusual model? Thank you for your help!

WordPress asks to connect to public pages on localhost

I started learning wordpress custom theme development a few weeks ago. And I have a wordpress installation on my local host running XAMPP on Ubuntu 18.04.
My problem is that when I disconnect from wp-admin, I can not access the public pages of my website (and they are all set as public). WordPress simply shows a simple login form, and this is not even the one with the wordpress logo, just basic fields with a description.
It is only after logging in that I can browse my website again.
My other wordpress installation (just a different folder in the htdocs lampp folder) doesn't have this problem. But I do not know why the first one … And I could not find any help on the web.
Clues?

authentication – Western Union asks for bank connection information – a ridiculously bad practice?

I was trying to initiate a Western Union transaction from my bank account, but by the end of the process, this query asked me to enter my bank's login information.

image of a login screen from a third party asking me to enter my bank identifier

The request is obviously from PayWithMyBank, which Western Union uses to process bank transfers.

I can not imagine how it goes for any type of security – disclose the connection information of his bank to a third party? It sounds ridiculous, and I can not even imagine what they do with the login credentials. (And this is not even a bank, as in this related question.)

(Security certificates of the two sites extracted, BTW.)

Is there an angle under which this scenario is not completely crazy?

python 3.x – Python3: Required while: Program that asks for two numbers, displays the values ​​between them in descending order.

As I indicated in the title, use obligatorily while I have to create a program that asks me for two numbers x and z, print all the numbers between x and z and order them in descending order. Do the descent but do not stop it according to the lower value. I leave what I have until now. Thank you in advance the community.

n1=int(input("num"))
n2=int(input("num"))

i=0
while i < n1:
    n1=n1-1
    print (n1)