JSFiddle - React, Tailwind, and code Playground
by Abdul Ahmad
JavaScript
var currentClient = 2;
var clients = {
2035060401: {
name: 'abdul',
numberOfPosts: 2,
posts: {
post1: {
type: 'poll',
title: 'Whats your favorite chocolate'
},
post2: {
type: 'diary',
title: 'my eyebrows r on fleek'
},
post3: {
}
},
},
2035060439: {
name: 'ibtihaj',
numberOfPosts: 999,
},
}
function createNewPost(title, type, phoneNumber) {
var existingPosts = clients[phoneNumber].posts;
if (existingPosts.length > 4) {
alert('You reached the max number of posts for the day');
return;
}
var uniqueId = generateUniqueId();
var newPost = {
title: title,
type: type,
};
clients[phoneNumber].posts[uniqueId] = newPost;
}